sdk/emulator/qemu.git
12 years agolinux-user: Use init_guest_space when -R and -B are specified
Meador Inge [Thu, 26 Jul 2012 16:50:02 +0000 (16:50 +0000)]
linux-user: Use init_guest_space when -R and -B are specified

Roll the code used to initialize the guest memory space when -R
or -B is used into 'init_guest_space' and then call 'init_guest_space'
from the driver.  This way the reserved guest memory space can
be probed for.  Calling 'mmap' just once as is currently done is not
guaranteed to succeed since the host address space validation might fail.

Signed-off-by: Meador Inge <meadori@codesourcery.com>
[PMM: Fixed minor whitespace errors.]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Factor out guest space probing into a function
Meador Inge [Thu, 26 Jul 2012 16:50:01 +0000 (16:50 +0000)]
linux-user: Factor out guest space probing into a function

Signed-off-by: Meador Inge <meadori@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agoflatload: fix bss clearing
Mike Frysinger [Mon, 9 Jul 2012 03:04:57 +0000 (03:04 +0000)]
flatload: fix bss clearing

The current bss clear logic assumes the target mmap address and host
address are the same.  Use g2h to translate from the target address
space to the host so we can call memset on it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
Jing Huang [Tue, 24 Jul 2012 14:01:42 +0000 (14:01 +0000)]
linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
Jing Huang [Tue, 24 Jul 2012 13:59:23 +0000 (13:59 +0000)]
linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: pass sockaddr from host to target
Jing Huang [Tue, 24 Jul 2012 13:58:02 +0000 (13:58 +0000)]
linux-user: pass sockaddr from host to target

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Move target_to_host_errno_table[] setup out of ioctl loop
Peter Maydell [Mon, 23 Jul 2012 08:07:22 +0000 (08:07 +0000)]
linux-user: Move target_to_host_errno_table[] setup out of ioctl loop

The code to initialise the target_to_host_errno_table[] array was
accidentally inside the loop through checking and initialising all
the supported ioctls. This was harmless but meant that we reinitialised the
array several hundred times on startup.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
Peter Maydell [Mon, 23 Jul 2012 08:06:15 +0000 (08:06 +0000)]
linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions

Fix the SNDCTL_DSP_MAP{IN,OUT}BUF ioctl definitions so that they
refer to a suitably defined target struct layout rather than hardcoding
the ioctl number. This fixes complaints from the syscall_init()
consistency check when running an x86_64-to-x86_64 linux-user qemu.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET
Peter Maydell [Mon, 23 Jul 2012 08:05:20 +0000 (08:05 +0000)]
linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET

The definitions for the ioctl numbers TARGET_BLKBSZGET and
TARGET_BLKBSZSET had the wrong size parameters (they are defined
with size_t, not int, even though the ioctl implementations themselves
read and write integers). Since commit 354a0008 we now have an
ioctl wrapper definition for BLKBSZGET and so on an x86-64-to-x86-64
linux-user binary we were triggering the mismatch warning in
syscall_init().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agoqom: Reimplement Interfaces
Anthony Liguori [Fri, 10 Aug 2012 03:16:10 +0000 (13:16 +1000)]
qom: Reimplement Interfaces

The current implementation of Interfaces is poorly designed.  Each interface
that an object implements ends up being an object that's tracked by the
implementing object.  There's all sorts of gymnastics to deal with casting
between these objects.

But an interface shouldn't be associated with an Object.  Interfaces are global
to a class.  This patch moves all Interface knowledge to ObjectClass eliminating
the relationship between Object and Interfaces.

Interfaces are now abstract (as they should be) but this is okay.  Interfaces
essentially act as additional parents for the classes and are treated as such.

With this new implementation, we should fully support derived interfaces
including reimplementing an inherited interface.

PC: Rebased against qom-next merge Jun-2012.

PC: Removed replication of cast logic for interfaces, i.e. there is only
one cast function - object_dynamic_cast() (and object_dynamic_cast_assert())

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agoxilinx_axi*: Re-implemented interconnect
Peter A. G. Crosthwaite [Fri, 10 Aug 2012 03:16:11 +0000 (13:16 +1000)]
xilinx_axi*: Re-implemented interconnect

Re-implemented the interconnect between the Xilinx AXI ethernet and DMA
controllers. A QOM interface "stream" is created, for the two stream interfaces.

As per Edgars request, this is designed to be more generic than AXI-stream,
so in the future we may see more clients of this interface beyond AXI stream.

This is based primarily on Paolos original refactoring of the interconnect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter A.G. Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Sun, 12 Aug 2012 00:49:03 +0000 (19:49 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  target-arm: Fix typos in comments
  arm: translate: comment typo - s/middel/middle/
  vl.c: Exit QEMU early if no machine is found

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Sun, 12 Aug 2012 00:48:50 +0000 (19:48 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  qemu-iotests: skip 039 with ./check -nocache
  block: add BLOCK_O_CHECK for qemu-img check
  qcow2: mark image clean after repair succeeds
  qed: mark image clean after repair succeeds
  blockdev: flip default cache mode from writethrough to writeback
  virtio-blk: disable write cache if not negotiated
  virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
  qemu-iotests: Save some sed processes
  ahci: Fix sglist memleak in ahci_dma_rw_buf()
  ahci: Fix ahci cdrom read corruptions for reads > 128k
  virtio-blk: fix use-after-free while handling scsi commands

12 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Sat, 11 Aug 2012 22:11:23 +0000 (17:11 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

* bonzini/scsi-next:
  scsi-disk: add support for the UNMAP command
  scsi-disk: improve out-of-range LBA detection for WRITE SAME
  scsi-disk: more assertions and resets for aiocb
  virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags
  iscsi: Pick default initiator-name based on the name of the VM
  iscsi: reorganize code for parse_initiator_name
  iscsi: do not leak initiator_name

12 years agoconfigure: fix double check tests with Clang
Blue Swirl [Thu, 9 Aug 2012 20:21:25 +0000 (20:21 +0000)]
configure: fix double check tests with Clang

Configuring with Clang compiler with -Werror would not work after
improved checks:
/tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates
to true [-Werror,-Wtautological-compare]
int main(void) { return preadv == preadv; }
/tmp/qemu-conf--25992-.c:13:26: error: self-comparison always
evaluates to true [-Werror,-Wtautological-compare]
    return epoll_create1 == epoll_create1;
/tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable
of type 'char **' to itself [-Werror,-Wself-assign]
    environ = environ;

Avoid the errors by adjusting the tests.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoconfigure: Check for -Werror causing failures when compiling tests
Peter Maydell [Wed, 18 Jul 2012 14:10:28 +0000 (15:10 +0100)]
configure: Check for -Werror causing failures when compiling tests

Add support for checking whether test case code can compile without
warnings, by recompiling each successful test with -Werror. If the
-Werror version doesn't pass, we bail out. This gives us the same
level of visibility of warnings in test code as --enable-werror
provides for the main compile.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec.c: fix dirty bitmap reallocation
Igor Mitsyanko [Fri, 10 Aug 2012 14:45:11 +0000 (18:45 +0400)]
exec.c: fix dirty bitmap reallocation

For each newly created RAM block, dirty bitmap is reallocated with g_realloc, which doesn't
make any promises on initial content of new extra data in returned buffer. In theory,
we initialize this new data with cpu_physical_memory_set_dirty_range() call. The
problem is, cpu_physical_memory_set_dirty_range() has a side effect of incrementing
ram_list.dirty_pages variable, but only for pages which are not already dirty. And
page "cleanliness" is determined using the same not yet uninitialized dirty bitmap
we've just reallocated. This results in inconsistency between real dirty page number
and value in ram_list.dirty_pages variable, which in turn could (and will) result
in errors during VM migration.
Zero initialize new dirty bitmap bytes to fix this problem.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMakefile: add qapi.py dependencies
Stefan Hajnoczi [Fri, 10 Aug 2012 13:08:42 +0000 (14:08 +0100)]
Makefile: add qapi.py dependencies

Commit 427a1a2cb1d35b83b6302886f46289f6d617134d ("qapi: avoid reserved
keywords") modifies qapi.py, which is used by qapi-types.py and other
Python scripts.  Because Makefile has no dependencies for qapi.py the
qapi code generator will not be rerun and the following build error is
produced:

  net/slirp.c: In function ‘net_init_slirp’:
  net/slirp.c:721:50: error: ‘NetdevUserOptions’ has no member named ‘q_restrict’

Fix this issue by adding the missing qapi.py dependencies.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add a minimal curses screen support
Guan Xuetao [Fri, 10 Aug 2012 06:42:39 +0000 (14:42 +0800)]
unicore32-softmmu: Add a minimal curses screen support

This patch adds a minimal curses screen support for unicore32-softmmu.
We assume 80*30 screen size to minimize the implementation.
Two problems are not solved, but they are innocuous.
1. curses windows will be blank when switching to monitor screen and back
2. backspace is not handled yet

v1->v2: add extra handler for '\r'

Signed-off-by: Zhang Mengchi <zhangmengchi@mprc.pku.edu.cn>
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Close dump-option of cpu_dump_state_ucf64 function
Guan Xuetao [Fri, 10 Aug 2012 06:42:38 +0000 (14:42 +0800)]
unicore32: Close dump-option of cpu_dump_state_ucf64 function

Since of tedious output, we close dump-option of cpu_dump_state_ucf64 function.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Disintegrate cpu_dump_state_ucf64 function
Guan Xuetao [Fri, 10 Aug 2012 06:42:37 +0000 (14:42 +0800)]
unicore32: Disintegrate cpu_dump_state_ucf64 function

This patch disintegrates cpu_dump_state_ucf64 function from cpu_dump_state.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Split UniCore-F64 instruction helpers from helper.c
Guan Xuetao [Fri, 10 Aug 2012 06:42:36 +0000 (14:42 +0800)]
unicore32: Split UniCore-F64 instruction helpers from helper.c

This patch just splits ucf64 instruction simulation helpers from
helper.c.
Also, two checkpatch warnings are solved.

v1->v2: adjust copyright information for new ucf64_helper.c

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add is_default setting for puv3 machine
Guan Xuetao [Fri, 10 Aug 2012 06:42:35 +0000 (14:42 +0800)]
unicore32-softmmu: Add is_default setting for puv3 machine

This patch sets is_default to 1 for puv3 machine, so that
find_default_machine() returns puv3 machine.
Thanks Dunrong for pointing it out.

Cc: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add maintainer information for UniCore32 machine
Guan Xuetao [Fri, 10 Aug 2012 06:42:34 +0000 (14:42 +0800)]
unicore32-softmmu: Add maintainer information for UniCore32 machine

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add ps2 support
Guan Xuetao [Fri, 10 Aug 2012 06:42:33 +0000 (14:42 +0800)]
unicore32-softmmu: Add ps2 support

This patch adds ps2/keyboard support, and enables CONFIG_PCKBD.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 dma support
Guan Xuetao [Fri, 10 Aug 2012 06:42:32 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 dma support

This patch adds puv3 dma (Direct Memory Access) support,
include dma device simulation for kernel booting.

v1->v2: Add initialization to ret in puv3_dma_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 pm support
Guan Xuetao [Fri, 10 Aug 2012 06:42:31 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 pm support

This patch adds puv3 pm (power management) support,
include pm device simulation for kernel booting.
Thank Blue Swirl for pointing out the missing "break".

v1->v2: Add initialization to ret in puv3_pm_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 gpio support
Guan Xuetao [Fri, 10 Aug 2012 06:42:30 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 gpio support

This patch adds puv3 gpio (General Purpose Input/Output) support,
include gpio device simulation and its interrupt support.

v1->v2: Add initialization to ret in puv3_gpio_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 ostimer support
Guan Xuetao [Fri, 10 Aug 2012 06:42:29 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 ostimer support

This patch adds puv3 ostimer support, include os timer
device simulation and ptimer support in puv3 machine.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 interrupt support
Guan Xuetao [Fri, 10 Aug 2012 06:42:28 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 interrupt support

This patch adds puv3 interrupt support, include interrupt controler
device simulation and interrupt handler in puv3 machine.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 soc/board support
Guan Xuetao [Fri, 10 Aug 2012 06:42:27 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 soc/board support

This patch only add puv3 soc/board support, which introduces puv3
machine description, and specifies console type.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Make sure that kernel can access user space
Guan Xuetao [Fri, 10 Aug 2012 06:42:26 +0000 (14:42 +0800)]
unicore32-softmmu: Make sure that kernel can access user space

As a matter of course, we need to access user space in kernel code,
so we need to correct load/store decoders to indicate correct memory
region.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Implement softmmu specific functions
Guan Xuetao [Fri, 10 Aug 2012 06:42:25 +0000 (14:42 +0800)]
unicore32-softmmu: Implement softmmu specific functions

This patch implements softmmu specific functions, include tlb_fill,
switch_mode, do_interrupt and uc32_cpu_handle_mmu_fault.
So the full exception handlers and page table walking could work now.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-unicore32: Drop UC32_CPUID macros
Andreas Färber [Fri, 10 Aug 2012 06:42:24 +0000 (14:42 +0800)]
target-unicore32: Drop UC32_CPUID macros

Any code that depends on a particular CPU type can now go through
callbacks on the QOM UniCore32CPUClass.

Signed-off-by: Andreas Färber <afaerber@suse.de
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable
Guan Xuetao [Fri, 10 Aug 2012 06:42:23 +0000 (14:42 +0800)]
unicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable

This patch initializes the cpuid to exactly correct value because
linux kernel will check it.
In addition, the exception types are specified in proper situations.
Then it could make exceptions generated correctly and timely.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add coprocessor 0(sysctrl) and 1(ocd) instruction support
Guan Xuetao [Fri, 10 Aug 2012 06:42:22 +0000 (14:42 +0800)]
unicore32-softmmu: Add coprocessor 0(sysctrl) and 1(ocd) instruction support

Coprocessor 0 is system control coprocessor, and we need get/set its contents.
Also, all cache/tlb ops shoule be implemented here, but just ignored with no harm.

Coprocessor 1 is OCD (on-chip-debugger), which is used for faked console,
so we could output chars to this console without graphic card.
TODO: curses display should be added lator for screen output.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add unicore32-softmmu build support
Guan Xuetao [Fri, 10 Aug 2012 06:42:21 +0000 (14:42 +0800)]
unicore32-softmmu: Add unicore32-softmmu build support

This patch adds unicore32-softmmu build support, include configure,
makefile, arch_init, and all missing functions needed by softmmu.
Although all missing functions are empty, unicore32-softmmu could
be build successfully.
By 20120804: change QEMU_ARCH_UNICORE32 to 0x4000

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-arm: Fix typos in comments
Peter Maydell [Mon, 6 Aug 2012 16:42:18 +0000 (17:42 +0100)]
target-arm: Fix typos in comments

Fix a variety of typos in comments in target-arm files.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoarm: translate: comment typo - s/middel/middle/
Peter A. G. Crosthwaite [Mon, 6 Aug 2012 07:05:56 +0000 (17:05 +1000)]
arm: translate: comment typo - s/middel/middle/

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agovl.c: Exit QEMU early if no machine is found
Dunrong Huang [Mon, 23 Jul 2012 16:42:20 +0000 (00:42 +0800)]
vl.c: Exit QEMU early if no machine is found

We check whether the variable machine is NULL or not before accessing
it. If machine is NULL, exit QEMU with an error, this can avoids a
segfault error.

Markus Armbruster <armbru@redhat.com> adds that the segfault can be
reproduced as follows:

  $ qemu-system-xtensa -cpu help

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqemu-iotests: skip 039 with ./check -nocache
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:57 +0000 (13:05 +0100)]
qemu-iotests: skip 039 with ./check -nocache

When the qemu-io --nocache option is used the 039 test case cannot abort
QEMU at a point where the image is dirty.  Skip the test case.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: add BLOCK_O_CHECK for qemu-img check
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:56 +0000 (13:05 +0100)]
block: add BLOCK_O_CHECK for qemu-img check

Image formats with a dirty bit, like qed and qcow2, repair dirty image
files upon open with BDRV_O_RDWR.  Performing automatic repair when
qemu-img check runs is not ideal because the bdrv_open() call repairs
the image before the actual bdrv_check() call from qemu-img.c.

Fix this "double repair" since it leads to confusing output from
qemu-img check.  Tell the block driver that this image is being opened
just for bdrv_check().  This skips automatic repair and qemu-img.c can
invoke it manually with bdrv_check().

Update the golden output for qemu-iotests 039 to reflect the new
qemu-img check output.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: mark image clean after repair succeeds
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:55 +0000 (13:05 +0100)]
qcow2: mark image clean after repair succeeds

The dirty bit is cleared after image repair succeeds in qcow2_open().
Move this into qcow2_check() so that all callers benefit from this
behavior when fix mode is enabled.

This is necessary so qemu-img check can call .bdrv_check() and mark the
image clean.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqed: mark image clean after repair succeeds
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:54 +0000 (13:05 +0100)]
qed: mark image clean after repair succeeds

The dirty bit is cleared after image repair succeeds in qed_open().
Move this into qed_check() so that all callers benefit from this
behavior when fix=true.

This is necessary so qemu-img check can call .bdrv_check() and mark the
image clean.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblockdev: flip default cache mode from writethrough to writeback
Paolo Bonzini [Thu, 9 Aug 2012 14:07:21 +0000 (16:07 +0200)]
blockdev: flip default cache mode from writethrough to writeback

Now all major device models (IDE, SCSI, virtio) can choose between
writethrough and writeback at run-time, and virtio will even revert
to writethrough if the guest is not capable of sending flushes.  So
we can change the default to writeback at last.

Tested, for lack of a better idea, with a breakpoint on bdrv_open
and all cache choices one by one.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: disable write cache if not negotiated
Paolo Bonzini [Thu, 9 Aug 2012 14:07:20 +0000 (16:07 +0200)]
virtio-blk: disable write cache if not negotiated

If the guest does not support flushes, we should run in writethrough mode.
The setting is temporary until the next reset, so that for example the
BIOS will run in writethrough mode while Linux will run with a writeback
cache.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
Paolo Bonzini [Thu, 9 Aug 2012 14:07:19 +0000 (16:07 +0200)]
virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE

Also rename VIRTIO_BLK_F_WCACHE to VIRTIO_BLK_F_WCE for consistency with
the spec.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: Save some sed processes
Kevin Wolf [Thu, 9 Aug 2012 11:17:14 +0000 (13:17 +0200)]
qemu-iotests: Save some sed processes

Instead of building a huge pipeline, just pass all expressions to a
single sed process.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
12 years agoahci: Fix sglist memleak in ahci_dma_rw_buf()
Jason Baron [Fri, 3 Aug 2012 19:57:10 +0000 (15:57 -0400)]
ahci: Fix sglist memleak in ahci_dma_rw_buf()

I noticed that in hw/ide/ahci:ahci_dma_rw_buf() we do not free the sglist. Thus,
I've added a call to qemu_sglist_destroy() to fix this memory leak.

In addition, I've adeed a call in qemu_sglist_destroy() to 0 all of the sglist
fields, in case there is some other codepath that tries to free the sglist.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoahci: Fix ahci cdrom read corruptions for reads > 128k
Jason Baron [Fri, 3 Aug 2012 19:57:06 +0000 (15:57 -0400)]
ahci: Fix ahci cdrom read corruptions for reads > 128k

While testing q35, which has its cdrom attached to the ahci controller, I found
that the Fedora 17 install would panic on boot. The panic occurs while
squashfs is trying to read from the cdrom. The errors are:

[    8.622711] SQUASHFS error: xz_dec_run error, data probably corrupt
[    8.625180] SQUASHFS error: squashfs_read_data failed to read block
0x20be48a

I was also able to produce corrupt data reads using an installed piix based
qemu machine, using 'dd'. I found that the corruptions were only occuring when
then read size was greater than 128k. For example, the following command
results in corrupted reads:

dd if=/dev/sr0 of=/tmp/blah bs=256k iflag=direct

The > 128k size reads exercise a different code path than 128k and below. In
ide_atapi_cmd_read_dma_cb() s->io_buffer_size is capped at 128k. Thus,
ide_atapi_cmd_read_dma_cb() is called a second time when the read is > 128k.
However, ahci_dma_rw_buf() restart the read from offset 0, instead of at 128k.
Thus, resulting in a corrupted read.

To fix this, I've introduced 'io_buffer_offset' field in IDEState to keep
track of the offset. I've also modified ahci_populate_sglist() to take a new
3rd offset argument, so that the sglist is property initialized.

I've tested this patch using 'dd' testing, and Fedora 17 now correctly boots
and installs on q35 with the cdrom ahci controller.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Tested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: fix use-after-free while handling scsi commands
Avi Kivity [Mon, 6 Aug 2012 12:49:03 +0000 (15:49 +0300)]
virtio-blk: fix use-after-free while handling scsi commands

The scsi passthrough handler falls through after completing a
request into the failure path, resulting in a use after free.

Reproducible by running a guest with aio=native on a block device.

Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agohandle device help before accelerator set up
Bruce Rogers [Thu, 9 Aug 2012 18:47:40 +0000 (12:47 -0600)]
handle device help before accelerator set up

A command line device probe using just -device "?" gets processed
after qemu-kvm initializes the accelerator. If /dev/kvm is not
present, the accelerator check will fail (kvm is defaulted to on),
which causes libvirt to not be set up to handle qemu guests.

Moving the device help handling before the accelerator set up allows
the device probe to work in this configuration and libvirt succeeds
in setting up for a qemu hypervisor mode.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMerge branch 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu
Blue Swirl [Thu, 9 Aug 2012 18:44:49 +0000 (18:44 +0000)]
Merge branch 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu

* 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu:
  target-i386: move tcg initialization into x86_cpu_initfn()
  cleanup cpu_set_debug_excp_handler
  target-xtensa: drop usage of prev_debug_excp_handler
  target-i386: drop usage of prev_debug_excp_handler

12 years agoqemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX
Stefano Stabellini [Tue, 29 May 2012 03:35:24 +0000 (03:35 +0000)]
qemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX

qemu_rearm_alarm_timer partially duplicates the code in
qemu_next_alarm_deadline to figure out if it needs to rearm the timer.
If it calls qemu_next_alarm_deadline, it always rearms the timer even if
the next deadline is INT64_MAX.

This patch simplifies the behavior of qemu_rearm_alarm_timer and removes
the duplicated code, always calling qemu_next_alarm_deadline and only
rearming the timer if the deadline is less than INT64_MAX.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Tested-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: make 'sim' to be the default machine
Max Filippov [Wed, 8 Aug 2012 23:31:38 +0000 (03:31 +0400)]
target-xtensa: make 'sim' to be the default machine

This fixes the following error:

    $ qemu-system-xtensa -cpu help
    Segmentation fault

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: make default CPU depend on target endianness
Max Filippov [Wed, 8 Aug 2012 10:07:14 +0000 (14:07 +0400)]
target-xtensa: make default CPU depend on target endianness

This makes usable default for -cpu option both for qemu-system-xtensa
and qemu-system-xtensaeb fixing the following error:

    $ qemu-system-xtensaeb -M sim
    Unable to find CPU definition

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMIPS: Correct FCR0 initialization
Nathan Froyd [Thu, 7 Jun 2012 15:04:14 +0000 (15:04 +0000)]
MIPS: Correct FCR0 initialization

 This change addresses a problem where QEMU incorrectly traps on
floating-point MADD group instructions with SIGILL, at least while
emulating MIPS32r2 processors.  These instructions use the COP1X major
opcode and include ones like:

madd.d $f2,$f4,$f2,$f6

 Here's Nathan's original analysis of the problem:

"QEMU essentially does:

  d = find_cpu (cpu_string) // get CPU definition
  fpu_init (env, d) // initialize fpu state (init FCR0, basically)
  cpu_reset (env)

...and the cpu_reset call clears all interesting state that fpu_init
setup, then proceeds to reinitialize all the CP0 registers...but not
FCR0."

 I have verified this change with system emulation running the GDB test
suite for the mips-sde-elf target (o32, big endian, 24Kf CPU emulated),
there were 55 progressions and no regressions.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi-bus: remove overlapping entry
Blue Swirl [Mon, 30 Jul 2012 17:46:06 +0000 (17:46 +0000)]
scsi-bus: remove overlapping entry

LOAD_UNLOAD and START_STOP have same value, so the table
entry is initialized twice. Spotted by Clang compiler.

Remove LOAD_UNLOAD entry since START_STOP entry already
represents both.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoxilinx_axienet: avoid useless self-assignment
Blue Swirl [Mon, 30 Jul 2012 17:28:04 +0000 (17:28 +0000)]
xilinx_axienet: avoid useless self-assignment

Statement s=s; makes little sense, remove it. Spotted by Clang
compiler.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agouser: fix accidental AREG0 use
Blue Swirl [Mon, 30 Jul 2012 15:51:17 +0000 (15:51 +0000)]
user: fix accidental AREG0 use

Global register AREG0 was always assumed to be usable in user-exec.c,
but this is incorrect for several targets.

Fix with #ifdeffery and by using other variables.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoqapi: avoid reserved keywords
Blue Swirl [Mon, 30 Jul 2012 15:46:55 +0000 (15:46 +0000)]
qapi: avoid reserved keywords

Clang compiler complained about use of reserved word 'restrict' in SLIRP
and QAPI.

Prefix C keywords with "q_", adjust SLIRP accordingly.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agosparc: fix expression with uninitialized initial value
Blue Swirl [Mon, 30 Jul 2012 15:29:11 +0000 (15:29 +0000)]
sparc: fix expression with uninitialized initial value

err was uninitialized, it's not OK to use |=. Spotted by Clang
compiler.

Fix by implementing the earlier statement which initializes the variable.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agosparc: fix floppy TC line setup
Blue Swirl [Mon, 30 Jul 2012 15:24:23 +0000 (15:24 +0000)]
sparc: fix floppy TC line setup

The qemu_irq for Terminal Count (TC) line between FDC and Slavio misc
device was created only after use, spotted by Clang compiler. Also,
it was not created if the FDC didn't exist.

Rearrange code to fix order. Always create the TC line.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: add Tekram DC-390 emulation (PC SCSI adapter)
Hervé Poussineau [Sat, 4 Aug 2012 19:10:06 +0000 (21:10 +0200)]
esp: add Tekram DC-390 emulation (PC SCSI adapter)

Difference with AMD PCscsi is that DC-390 contains a EEPROM,
and that a romfile is available to add INT13 support.

This has been successfully tested on:
- MS DOS 6.22 (using DC390 ASPI driver)
- MS Windows 98 SE (using DC390 driver)
- MS Windows NT 3.1 (using DC390 driver)
- MS Windows NT 4.0 (using DC390 driver)
- hard disk and cdrom boot

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoRevert "pci: add some stubs"
Hervé Poussineau [Sat, 4 Aug 2012 19:10:05 +0000 (21:10 +0200)]
Revert "pci: add some stubs"

This reverts commit 0883c5159f1df05d8761014f65451c3c3b77ebcf.

Those stubs were only used by PCI ESP emulation, which is now
not compiled on architectures which have no PCI bus support.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: move PCI emulation to a new file esp-pci.c
Hervé Poussineau [Sat, 4 Aug 2012 19:10:04 +0000 (21:10 +0200)]
esp: move PCI emulation to a new file esp-pci.c

sparc machines loose ability to instanciate PCI ESP SCSI adapter,
which is not a big loose as they don't have PCI bus support.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: move some definitions to header file
Hervé Poussineau [Sat, 4 Aug 2012 19:10:03 +0000 (21:10 +0200)]
esp: move some definitions to header file

These will be used by next commits.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi-disk: add support for the UNMAP command
Paolo Bonzini [Thu, 9 Aug 2012 09:00:22 +0000 (11:00 +0200)]
scsi-disk: add support for the UNMAP command

The unmap command can reuse the same infrastructure as MODE SELECT
for reading the descriptor list into memory.  The descriptors are
processed sequentially.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: improve out-of-range LBA detection for WRITE SAME
Paolo Bonzini [Thu, 9 Aug 2012 11:34:53 +0000 (13:34 +0200)]
scsi-disk: improve out-of-range LBA detection for WRITE SAME

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: more assertions and resets for aiocb
Paolo Bonzini [Thu, 9 Aug 2012 09:33:26 +0000 (11:33 +0200)]
scsi-disk: more assertions and resets for aiocb

Leaving the aiocb to a non-NULL value leads to an assertion failure when
rerror/werror are set to stop or enospc, and the operation is retried.
scsi-disk checks that the aiocb member is NULL before filling it.

This patch correctly resets the aiocb to NULL values everywhere,
and adds the dual assertion that the aiocb was non-NULL before
calling bdrv_acct_done.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags
Paolo Bonzini [Wed, 8 Aug 2012 14:26:16 +0000 (16:26 +0200)]
virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags

This patch fixes a problem in handling task management functions
in virtio-scsi.  The cause of the problem is a mismatch between
the size of the tag in QEMU (32-bit) and virtio-scsi (64-bit).
Changing the QEMU size is hard because the migration format
uses 32 bits to store the tag; so just don't use the QEMU tag
(virtio-scsi only uses the tag for task management functions
anyway) and look up the full 64-bit tag in the hba_private field.

The reproducer is a bit obscure.  If you cause an I/O timeout
(for example with rerror=stop and doing 'cont' on the monitor
continuously without fixing the error), sooner or later the
guest will try to abort the command and reissue it.  At this
point, QEMU will report _two_ errors instead of one when you
hit 'c', because the first error has not been canceled correctly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoiscsi: Pick default initiator-name based on the name of the VM
Ronnie Sahlberg [Mon, 6 Aug 2012 08:24:55 +0000 (18:24 +1000)]
iscsi: Pick default initiator-name based on the name of the VM

This patch updates the iscsi layer to automatically pick a 'unique'
initiator-name based on the name of the vm in case the user has not set
an explicit iqn-name to use.

Create a new function qemu_get_vm_name() that returns the name of the VM,
if specified.

This way we can thus create default names to use as the initiator name
based on the guest session.

If the VM is not named via the '-name' command line argument, the iscsi
initiator-name used wiull simply be

    iqn.2008-11.org.linux-kvm

If a name for the VM was specified with the '-name' option, iscsi will
use a default initiatorname of

    iqn.2008-11.org.linux-kvm:<name>

These names are just the default iscsi initiator name that qemu will
generate/use only when the user has not set an explicit initiator name
via the commandlines or config files.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
12 years agoiscsi: reorganize code for parse_initiator_name
Paolo Bonzini [Mon, 6 Aug 2012 08:54:41 +0000 (10:54 +0200)]
iscsi: reorganize code for parse_initiator_name

Merge the occurrences of the "iqn.2008-11.org.linux-kvm" string
to avoid duplication.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoiscsi: do not leak initiator_name
Paolo Bonzini [Mon, 6 Aug 2012 08:52:22 +0000 (10:52 +0200)]
iscsi: do not leak initiator_name

The argument of iscsi_create_context is never freed by libiscsi,
which in fact calls strdup on it.  Avoid a leak.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoMerge remote-tracking branch 'kraxel/usb.58' into staging
Anthony Liguori [Tue, 7 Aug 2012 14:46:40 +0000 (09:46 -0500)]
Merge remote-tracking branch 'kraxel/usb.58' into staging

* kraxel/usb.58:
  usb-storage: fix SYNCHRONIZE_CACHE
  usb-storage: improve debug logging

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 7 Aug 2012 14:46:24 +0000 (09:46 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
  qemu-iotests: Be more flexible with image creation options
  qemu-iotests: add 039 qcow2 lazy refcounts test
  qemu-io: add "abort" command to simulate program crash
  qcow2: implement lazy refcounts
  qemu-iotests: ignore qemu-img create lazy_refcounts output
  docs: add lazy refcounts bit to qcow2 specification
  qcow2: introduce dirty bit
  docs: add dirty bit to qcow2 specification
  qemu-iotests: add qed.py image manipulation utility
  qapi: generalize documentation of streaming commands
  ide scsi: Mess with geometry only for hard disk devices

12 years agousb-storage: fix SYNCHRONIZE_CACHE
Gerd Hoffmann [Fri, 13 Jul 2012 09:38:13 +0000 (11:38 +0200)]
usb-storage: fix SYNCHRONIZE_CACHE

Commit 59310659073d85745854f2f10c4292555c5a1c51 is incomplete,
we'll arrive in the scsi command complete callback in CSW state
and must handle that case correctly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-storage: improve debug logging
Gerd Hoffmann [Fri, 13 Jul 2012 09:35:51 +0000 (11:35 +0200)]
usb-storage: improve debug logging

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoslirp: fix build on mingw32
Anthony Liguori [Tue, 7 Aug 2012 00:31:55 +0000 (19:31 -0500)]
slirp: fix build on mingw32

in_addr_t isn't available on mingw32.  Just use an unsigned long instead.  I
considered typedef'ing in_addr_t on mingw32 but this would potentially be
brittle if mingw32 did introduce the type.

Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
Dong Xu Wang [Mon, 6 Aug 2012 02:18:42 +0000 (10:18 +0800)]
qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: Be more flexible with image creation options
Kevin Wolf [Fri, 27 Jul 2012 13:14:28 +0000 (15:14 +0200)]
qemu-iotests: Be more flexible with image creation options

qemu-iotests already filters out image creation options that may be
present or not in order to get the same output in both cases. However,
often it only considers the default value of the option. Cover all valid
values instead so that ./check -o name=value can be used successfull for
all of them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: add 039 qcow2 lazy refcounts test
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:24 +0000 (09:05 +0100)]
qemu-iotests: add 039 qcow2 lazy refcounts test

This tests establishes the basic post-conditions of the qcow2 lazy
refcounts features:

  1. If the image was closed normally, it is marked clean.

  2. If an allocating write was performed and the image was not closed
     normally, then it is marked dirty.

     a. Written data can be read back successfully.
     b. The image file can be repaired and will be marked clean again.
     c. The image file is automatically repaired when opened read/write.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-io: add "abort" command to simulate program crash
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:23 +0000 (09:05 +0100)]
qemu-io: add "abort" command to simulate program crash

Avoiding data loss and corruption is the top requirement for image file
formats.  The qemu-io "abort" command makes it possible to simulate
program crashes and does not give the image format a chance to cleanly
shut down.  This command is useful for data integrity test cases.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: implement lazy refcounts
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:22 +0000 (09:05 +0100)]
qcow2: implement lazy refcounts

Lazy refcounts is a performance optimization for qcow2 that postpones
refcount metadata updates and instead marks the image dirty.  In the
case of crash or power failure the image will be left in a dirty state
and repaired next time it is opened.

Reducing metadata I/O is important for cache=writethrough and
cache=directsync because these modes guarantee that data is on disk
after each write (hence we cannot take advantage of caching updates in
RAM).  Refcount metadata is not needed for guest->file block address
translation and therefore does not need to be on-disk at the time of
write completion - this is the motivation behind the lazy refcount
optimization.

The lazy refcount optimization must be enabled at image creation time:

  qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=on a.qcow2 10G
  qemu-system-x86_64 -drive if=virtio,file=a.qcow2,cache=writethrough

Update qemu-iotests 031 and 036 since the extension header size changes
when we add feature bit table entries.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: ignore qemu-img create lazy_refcounts output
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:21 +0000 (09:05 +0100)]
qemu-iotests: ignore qemu-img create lazy_refcounts output

Hide the default lazy_refcounts=off output from qemu-img like we do with
other image creation options.  This ensures that existing golden outputs
continue to pass despite the new option that has been added.

Note that this patch applies before the one that actually introduces the
lazy_refcounts=on|off option.  This ensures git-bisect(1) continues to
work.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agodocs: add lazy refcounts bit to qcow2 specification
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:20 +0000 (09:05 +0100)]
docs: add lazy refcounts bit to qcow2 specification

The lazy refcounts bit indicates that this image can take advantage of
the dirty bit and that refcount updates can be postponed.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: introduce dirty bit
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:19 +0000 (09:05 +0100)]
qcow2: introduce dirty bit

This patch adds an incompatible feature bit to mark images that have not
been closed cleanly.  When a dirty image file is opened a consistency
check and repair is performed.

Update qemu-iotests 031 and 036 since the extension header size changes
when we add feature bit table entries.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agodocs: add dirty bit to qcow2 specification
Stefan Hajnoczi [Fri, 27 Jul 2012 08:05:18 +0000 (09:05 +0100)]
docs: add dirty bit to qcow2 specification

The dirty bit will make it possible to perform lazy refcount updates,
where the image file is not kept consistent all the time.  Upon opening
a dirty image file, it is necessary to perform a consistency check and
repair any incorrect refcounts.

Therefore the dirty bit must be an incompatible feature bit.  We don't
want old programs accessing a file with stale refcounts.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: add qed.py image manipulation utility
Stefan Hajnoczi [Fri, 27 Jul 2012 08:01:27 +0000 (09:01 +0100)]
qemu-iotests: add qed.py image manipulation utility

The qed.py utility can inspect and manipulate QED image files.  It can
be used for testing to see the state of image metadata and also to
inject corruptions into the image file.  It also has a scrubbing feature
to copy just the metadata out of an image file, allowing users to share
broken image files without revealing data in bug reports.

This has lived in my local repo for a long time but could be useful
to others.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqapi: generalize documentation of streaming commands
Paolo Bonzini [Tue, 24 Jul 2012 11:03:39 +0000 (13:03 +0200)]
qapi: generalize documentation of streaming commands

Talk about background operations in general, rather than specifically
about streaming.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoide scsi: Mess with geometry only for hard disk devices
Markus Armbruster [Thu, 12 Jul 2012 16:52:31 +0000 (18:52 +0200)]
ide scsi: Mess with geometry only for hard disk devices

Legacy -drive cyls=... are now ignored completely when the drive
doesn't back a hard disk device.  Before, they were first checked
against a hard disk's limits, then ignored.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio: fix vhost handling
Paolo Bonzini [Mon, 6 Aug 2012 13:26:14 +0000 (15:26 +0200)]
virtio: fix vhost handling

Commit b1f416aa8d870fab71030abc9401cfc77b948e8e breaks vhost_net
because it always registers the virtio_pci_host_notifier_read() handler
function on the ioeventfd, even when vhost_net.ko is using the ioeventfd.
The result is both QEMU and vhost_net.ko polling on the same eventfd
and the virtio_net.ko guest driver seeing inconsistent results:

  # ifconfig eth0 192.168.0.1 netmask 255.255.255.0
  virtio_net virtio0: output:id 0 is not a head!

To fix this, proceed the same as we do for irqfd: add a parameter to
virtio_queue_set_host_notifier_fd_handler and in that case only set
the notifier, not the handler.

Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Tested-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'kiszka/queues/slirp' into staging
Anthony Liguori [Mon, 6 Aug 2012 18:59:59 +0000 (13:59 -0500)]
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

* kiszka/queues/slirp:
  slirp: Handle whole 127.0.0.0/8 network as local addresses.

12 years agoMerge branch 'axp-next' of git://repo.or.cz/qemu/rth
Blue Swirl [Sat, 4 Aug 2012 17:58:23 +0000 (17:58 +0000)]
Merge branch 'axp-next' of git://repo.or.cz/qemu/rth

* 'axp-next' of git://repo.or.cz/qemu/rth:
  alpha-linux-user: Fix the getpriority syscall
  alpha-linux-user: Properly handle the non-rt sigprocmask syscall.
  alpha-linux-user: Fix a3 error return with v0 error bypass.
  linux-user: Translate pipe2 flags; add to strace
  linux-user: Allocate the right amount of space for non-fixed file maps
  linux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATH
  linux-user: Sync fcntl.h bits with the kernel
  alpha-linux-user: Handle TARGET_SSI_IEEE_RAISE_EXCEPTION properly
  alpha-linux-user: Work around hosted mmap allocation problems
  alpha-linux-user: Fix signal handling

12 years agoalpha-linux-user: Fix the getpriority syscall
Richard Henderson [Thu, 7 Jun 2012 22:14:50 +0000 (15:14 -0700)]
alpha-linux-user: Fix the getpriority syscall

Alpha uses unbiased priority values in the syscall, with the a3
return value signaling error conditions.  Therefore, properly
interpret the libc getpriority as needed for the guest rather
than passing the host value through unchanged.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agoalpha-linux-user: Properly handle the non-rt sigprocmask syscall.
Richard Henderson [Thu, 7 Jun 2012 22:02:49 +0000 (15:02 -0700)]
alpha-linux-user: Properly handle the non-rt sigprocmask syscall.

Name the syscall properly for QEMU, kernel source notwithstanding.
Fix syntax errors in the code thus enabled within do_syscall.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agoalpha-linux-user: Fix a3 error return with v0 error bypass.
Richard Henderson [Thu, 7 Jun 2012 21:47:41 +0000 (14:47 -0700)]
alpha-linux-user: Fix a3 error return with v0 error bypass.

We were failing to initialize a3 for syscalls that bypass the
negative return value error check.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agolinux-user: Translate pipe2 flags; add to strace
Richard Henderson [Sat, 2 Jun 2012 01:48:39 +0000 (18:48 -0700)]
linux-user: Translate pipe2 flags; add to strace

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agolinux-user: Allocate the right amount of space for non-fixed file maps
Richard Henderson [Fri, 1 Jun 2012 23:07:52 +0000 (16:07 -0700)]
linux-user: Allocate the right amount of space for non-fixed file maps

If we let the kernel handle the implementation of mmap_find_vma,
via an anon mmap, we must use the size as indicated by the user
and not the size truncated to the filesize.

This happens often in ld.so, where we initially mmap the file to
the size of the text+data+bss to reserve an area, then mmap+fixed
over the top to properly handle data and bss.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agolinux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATH
Richard Henderson [Wed, 25 Jul 2012 21:30:34 +0000 (14:30 -0700)]
linux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATH

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>