sdk/emulator/qemu.git
13 years agoMerge remote-tracking branch 'qmp/queue/qmp-1.0' into staging
Anthony Liguori [Fri, 18 Nov 2011 19:23:38 +0000 (13:23 -0600)]
Merge remote-tracking branch 'qmp/queue/qmp-1.0' into staging

13 years agoMakefile: fix qga dependencies
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:31 +0000 (23:58 +0200)]
Makefile: fix qga dependencies

.c files include .h files, so .o depends on .h,
and the linked result depends on .o.
We got it wrong for qga rules, fix it up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
13 years agoMakefile: dependency fix
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:24 +0000 (23:58 +0200)]
Makefile: dependency fix

qga/guest-agent-commands.c includes qga-qmp-commands.h,
but it was missing in its dependencies. Add it in QGALIB_GEN.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
13 years agoMakefile: fix dependencies for generated .h, .c
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:18 +0000 (23:58 +0200)]
Makefile: fix dependencies for generated .h, .c

We have a single rule generating .c and .h files,
so .h doesn't depend on .c: both depend on the
source schema.

Fix Makefile to reflect that - without this,
if .c is there and .h is missing, Makefile does
not know how to remake .h and assumes it's
a dummy target, triggering endless rebuilds.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
13 years agoMakefile: remove more generated files on clean
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:46 +0000 (23:58 +0200)]
Makefile: remove more generated files on clean

make clean missed the source qmp files generated
by python. Fix that.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
13 years agoqapi: Check for negative enum values
Luiz Capitulino [Mon, 14 Nov 2011 13:25:09 +0000 (11:25 -0200)]
qapi: Check for negative enum values

We don't currently check for negative enum values in qmp_output_type_enum(),
this will very likely generate a segfault when triggered.

However, it _seems_ that no code in tree can trigger this today.

Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
13 years agomonitor: Fix file_completion() to check for stat() failure
Markus Armbruster [Wed, 16 Nov 2011 14:43:47 +0000 (15:43 +0100)]
monitor: Fix file_completion() to check for stat() failure

stat() can fail for a file name just read with readdir().  Easiest way
to trigger is a dangling symbolic link --- look ma, no race!  When it
fails, file_completion() uses sb.st_mode uninitialized.  If the
directory bit happens to be set, it appends a "/" to the completed
name.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoFixing some spelling in docs/libcacard.txt
Matthias Brugger [Tue, 15 Nov 2011 11:57:14 +0000 (11:57 +0000)]
Fixing some spelling in docs/libcacard.txt

Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoFix typo: runnning -> running
Vagrant Cascadian [Mon, 14 Nov 2011 22:06:23 +0000 (14:06 -0800)]
Fix typo: runnning -> running

One n too many for running, need we say more.

Signed-Off-By: Vagrant Cascadian <vagrant@freegeek.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoFix some spelling bugs in documentation and comments
Stefan Weil [Sun, 13 Nov 2011 21:24:27 +0000 (22:24 +0100)]
Fix some spelling bugs in documentation and comments

These errors were detected by codespell:

remaing -> remaining
soley -> solely
virutal -> virtual
seperate -> separate

libcacard.txt still needs some more patches.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoFix spelling in documentation and comments (similiar -> similar)
Stefan Weil [Sun, 13 Nov 2011 21:24:26 +0000 (22:24 +0100)]
Fix spelling in documentation and comments (similiar -> similar)

This bug was detected by codespell.
In mips_mipssim.c a grammatical error was fixed, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoUpdate version to 1.0-rc2
Anthony Liguori [Mon, 14 Nov 2011 17:02:38 +0000 (11:02 -0600)]
Update version to 1.0-rc2

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agopc_piix: set qxl revision to 2 for pc-0.14
Alon Levy [Sun, 13 Nov 2011 13:27:51 +0000 (15:27 +0200)]
pc_piix: set qxl revision to 2 for pc-0.14

The default is still 3, and I didn't change older machine types.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/omap_gpio: Fix infinite recursion when doing 8/16 bit reads
Peter Maydell [Mon, 7 Nov 2011 13:25:45 +0000 (13:25 +0000)]
hw/omap_gpio: Fix infinite recursion when doing 8/16 bit reads

Fix a long-standing bug which meant that any attempt to do an
8 or 16 bit read from the OMAP GPIO module would cause qemu to
crash due to an infinite recursion.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoRevert bugfix e7852674d5 until tested or until after the release.
Andrzej Zaborowski [Mon, 14 Nov 2011 17:17:59 +0000 (18:17 +0100)]
Revert bugfix e7852674d5 until tested or until after the release.

Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agohw/onenand: reject read-only drives
Juha Riihimäki [Thu, 20 Oct 2011 12:53:35 +0000 (14:53 +0200)]
hw/onenand: reject read-only drives

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agohw/nand: reject read-only drives
Juha Riihimäki [Thu, 20 Oct 2011 12:53:34 +0000 (14:53 +0200)]
hw/nand: reject read-only drives

also gracefully fail on nand_device_init() for unsupported block
size instead of aborting.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agohw/arm_sysctl: Fix RESETCTL for realview-pb-a8 and -pbx-a9
Jean-Christophe DUBOIS [Mon, 14 Nov 2011 02:09:20 +0000 (03:09 +0100)]
hw/arm_sysctl: Fix RESETCTL for realview-pb-a8 and -pbx-a9

Depending on the considered baseboard the bit used to
reset the platform is different.

Here is the list of considered Realview/Versatile platforms:

Realview/Versatile AB for ARM926EJ-S: BOARD_ID = 0x100 = BOARD_ID_PB9
http://infocenter.arm.com/help/topic/com.arm.doc.dui0225d/CACCIFGI.html

RealView Emulation Baseboard: BOARD_ID = 0x140 = BOARD_ID_EB
No reset register

RealView PB for Cortex-A8: BOARD_ID = 0x178 = BOARD_ID_PBA8
http://infocenter.arm.com/help/topic/com.arm.doc.dui0417d/BBACIGAD.html

RealView PB for Cortex-A9: BOARD_ID = 0x182 = BOARD_ID_PBX
http://infocenter.arm.com/help/topic/com.arm.doc.dui0440b/CACCHBFB.html

Motherboard Express =C2=B5ATX: BOARD_ID = 0x190 = BOARD_ID_VEXPRESS
No reset register

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agohw/pxa2xx.c: Fix handling of RW bits in PMCR
Peter Maydell [Sun, 13 Nov 2011 14:18:39 +0000 (14:18 +0000)]
hw/pxa2xx.c: Fix handling of RW bits in PMCR

Fix an error in commit afd4a6522 which meant that writing a zero
to the RW bits in the PMCR wouldn't actually clear them. (Error
spotted by Andrzej Zaborowski.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agohw/usb-net.c: Fix precedence bug when checking rndis_state
Peter Maydell [Wed, 9 Nov 2011 21:09:23 +0000 (21:09 +0000)]
hw/usb-net.c: Fix precedence bug when checking rndis_state

"!X == 2" is always false (spotted by Coverity), so the checks
for whether rndis is in the correct state would never fire.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agomemory: fix 'info mtree' segfaults
Avi Kivity [Sun, 13 Nov 2011 10:00:55 +0000 (12:00 +0200)]
memory: fix 'info mtree' segfaults

'info mtree' accesses invalid memory in two cases, both due to incorrect
(and unsafe) usage of QTAILQ_FOREACH_SAFE().

Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoMerge remote-tracking branch 'kwolf/block-stable' into staging
Anthony Liguori [Fri, 11 Nov 2011 23:26:37 +0000 (17:26 -0600)]
Merge remote-tracking branch 'kwolf/block-stable' into staging

13 years agovl.c: prohibit simultaneous use of -icount with kvm or xen
Max Filippov [Thu, 10 Nov 2011 11:38:42 +0000 (15:38 +0400)]
vl.c: prohibit simultaneous use of -icount with kvm or xen

With -icount, The vm_clock is updated with help from TCG (it counts
instructions at 2^ICOUNT ns/instructions). With KVM, the instruction
count is not available so KVM cannot provide this help.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/arm_timer.c: Fix bounds check for Integrator timer accesses
Peter Maydell [Fri, 11 Nov 2011 13:30:15 +0000 (13:30 +0000)]
hw/arm_timer.c: Fix bounds check for Integrator timer accesses

There are only three counter/timers on the integrator board:
correct the bounds check to avoid an array overrun. (Spotted
by Coverity, see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/pxa2xx.c: Fix handling of R/WC bits in PMCR
Peter Maydell [Wed, 9 Nov 2011 20:46:35 +0000 (20:46 +0000)]
hw/pxa2xx.c: Fix handling of R/WC bits in PMCR

Fix a bug in handling the write-one-to-clear bits in the PMCR
which meant that we would always clear the bit even if the
value written was a zero. Spotted by Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/pl061: Remove pointless comparison of array to null
Peter Maydell [Wed, 9 Nov 2011 20:04:54 +0000 (20:04 +0000)]
hw/pl061: Remove pointless comparison of array to null

Remove a pointless comparison of an array to null. (There is
no need to check whether s->out[i] is non-null as qemu_set_irq
will do that for us.) Spotted by Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/tc58128.c: Remove unnecessary check for g_malloc failure
Peter Maydell [Wed, 9 Nov 2011 19:34:28 +0000 (19:34 +0000)]
hw/tc58128.c: Remove unnecessary check for g_malloc failure

Remove a check for g_malloc failing: this never happens.
Also use g_malloc rather than g_malloc0 as we immediately
memset the entire region and so zero-initialising it is pointless.
Spotted by Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agolinux-user/elfload.c: Don't memset(NULL..) if malloc() failed
Peter Maydell [Wed, 9 Nov 2011 19:22:11 +0000 (19:22 +0000)]
linux-user/elfload.c: Don't memset(NULL..) if malloc() failed

If a malloc() in copy_elf_strings() failed we would call memset()
before the "did malloc fail?" check. Fix this by moving to the
glib alloc/free routines for this memory so we can use g_try_malloc0
rather than having a separate memset(). Spotted by Coverity (see
bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/omap_intc.c: Avoid crash on access to nonexistent banked registers
Peter Maydell [Wed, 9 Nov 2011 18:45:38 +0000 (18:45 +0000)]
hw/omap_intc.c: Avoid crash on access to nonexistent banked registers

Avoid a crash due to null pointer dereference if a guest attempts
to access banked registers for a nonexistent bank. Spotted by
Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoos-posix: Plug fd leak in qemu_create_pidfile()
Markus Armbruster [Fri, 11 Nov 2011 09:40:09 +0000 (10:40 +0100)]
os-posix: Plug fd leak in qemu_create_pidfile()

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoposix-aio-compat: Plug memory leak on paio_init() error path
Markus Armbruster [Fri, 11 Nov 2011 09:40:08 +0000 (10:40 +0100)]
posix-aio-compat: Plug memory leak on paio_init() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqemu-sockets: Plug fd leak on unix_connect_opts() error path
Markus Armbruster [Fri, 11 Nov 2011 09:40:07 +0000 (10:40 +0100)]
qemu-sockets: Plug fd leak on unix_connect_opts() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoui: Plug memory leaks on parse_keyboard_layout() error path
Markus Armbruster [Fri, 11 Nov 2011 09:40:06 +0000 (10:40 +0100)]
ui: Plug memory leaks on parse_keyboard_layout() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqemu-char: Plug memory leak on qemu_chr_open_pty() error path
Markus Armbruster [Fri, 11 Nov 2011 09:40:05 +0000 (10:40 +0100)]
qemu-char: Plug memory leak on qemu_chr_open_pty() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agomigration: fix detached migration with fd
Juan Quintela [Wed, 9 Nov 2011 20:29:01 +0000 (21:29 +0100)]
migration: fix detached migration with fd

Migration with fd uses s->mon to pass the fd.  But we only assign the
s->mon for !detached migration.  Fix it.  Once there add a comment
indicating that s->mon has two uses.

Bug reported by:  Wen Congyang <wency@cn.fujitsu.com>

Signed-off-by: Juan Quintela <quintela@redhat.com>
CC: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoconfigure: Do not use 'sed -i'
Pavel Borzenkov [Thu, 10 Nov 2011 20:26:59 +0000 (00:26 +0400)]
configure: Do not use 'sed -i'

'sed -i' is not defined in POSIX. It doesn't work on Mac OS X the way
it's used in configure (without suffix argument). This patch implements
Peter Maydell's idea of xattr.h detection.

Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovl.c: Fail gracefully if no machine is found
Andreas Färber [Thu, 10 Nov 2011 15:35:32 +0000 (16:35 +0100)]
vl.c: Fail gracefully if no machine is found

machine defaults to find_default_machine(),
then gets overridden via -M and machine_parse().

If no -M is specified and find_default_machine() returns NULL
(when no machine compiled in), exit with an error.

Avoids a segfault when setting machine->max_cpus.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoblock: Make cache=unsafe flush to the OS
Kevin Wolf [Thu, 10 Nov 2011 17:13:59 +0000 (18:13 +0100)]
block: Make cache=unsafe flush to the OS

cache=unsafe completely ignored bdrv_flush, because flushing the host disk
costs a lot of performance. However, this means that qcow2 images (and
potentially any other format) can lose data even after the guest has issued a
flush if the qemu process crashes/is killed. In case of a host crash, data loss
is certainly expected with cache=unsafe, but if just the qemu process dies this
is a bit too unsafe.

Now that we have two separate flush functions, we can choose to flush
everythign to the OS, but don't enforce that it's physically written to the
disk.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Introduce bdrv_co_flush_to_os
Kevin Wolf [Thu, 10 Nov 2011 17:10:11 +0000 (18:10 +0100)]
block: Introduce bdrv_co_flush_to_os

qcow2 has a writeback metadata cache, so flushing a qcow2 image actually
consists of writing back that cache to the protocol and only then flushes the
protocol in order to get everything stable on disk.

This introduces a separate bdrv_co_flush_to_os to reflect the split.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Rename bdrv_co_flush to bdrv_co_flush_to_disk
Kevin Wolf [Thu, 10 Nov 2011 16:25:44 +0000 (17:25 +0100)]
block: Rename bdrv_co_flush to bdrv_co_flush_to_disk

There are two different types of flush that you can do: Flushing one level up
to the OS (i.e. writing data to the host page cache) or flushing it all the way
down to the disk. The existing functions flush to the disk, reflect this in the
function name.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agohw/pc.c: Fix use-while-uninitialized of fd_type[]
Peter Maydell [Wed, 9 Nov 2011 21:59:50 +0000 (21:59 +0000)]
hw/pc.c: Fix use-while-uninitialized of fd_type[]

Fix a use-while-uninitialized of the fd_type[] array (introduced
in commit 34d4260e1, noticed by Coverity). This is more theoretical
than practical, since it's quite hard to get here with floppy==NULL
(the qdev_try_create() of the isa-fdc device has to fail).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Fix vpc initialization of the Dynamic Disk Header
Charles Arnold [Wed, 9 Nov 2011 16:32:25 +0000 (09:32 -0700)]
block: Fix vpc initialization of the Dynamic Disk Header

The Data Offset field in the Dynamic Disk Header is an 8 byte field.
Although the specification (2006-10-11) gives an example of initializing
only the first 4 bytes, images generated by Microsoft on Windows initialize
all 8 bytes.

Failure to initialize all 8 bytes results in errors from utilities
like Citrix's vhd-util which checks specifically for the proper Data
Offset field initialization.

Signed-off-by: Charles Arnold <carnold@suse.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: open the block device after starting the client thread
Paolo Bonzini [Fri, 4 Nov 2011 14:51:24 +0000 (15:51 +0100)]
qemu-nbd: open the block device after starting the client thread

This is cleaner, because we do not need to close the block device when
there is an error opening /dev/nbdX.  It was done this way only to
print errors before daemonizing.

At the same time, use atexit to ensure that the block device is closed
whenever we exit.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: fix socket creation race
Paolo Bonzini [Fri, 4 Nov 2011 14:51:23 +0000 (15:51 +0100)]
qemu-nbd: fix socket creation race

Now that the client and server are in the same process, there is
no need to race on the creation of the socket.  We can open the
listening socket before starting the client thread.

This avoids that "qemu-nbd -v -c" prints this once before connecting
successfully to the socket:

    connect(unix:/var/lock/qemu-nbd-nbd0): No such file or directory

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: print error messages from the daemon through a pipe
Paolo Bonzini [Fri, 4 Nov 2011 14:51:22 +0000 (15:51 +0100)]
qemu-nbd: print error messages from the daemon through a pipe

In order to get nice error messages, keep the qemu-nbd process running
until before issuing NBD_DO_IT and connected to the daemon with a pipe.
This lets the qemu-nbd process relay error messages from the daemon and
exit with a nonzero status if appropriate.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: move client to a thread
Paolo Bonzini [Fri, 4 Nov 2011 14:51:21 +0000 (15:51 +0100)]
qemu-nbd: move client to a thread

This avoids that qemu-nbd uses both forking and threads, which do
not behave well together.

qemu-nbd is already Unix only, and there is no qemu_thread_join,
so for now use pthreads.

Since the parent and child no longer have separate file descriptors,
we can open the NBD device before daemonizing, instead of checking
with access(2) and restricting the open to the client only.

Reported-by: Pierre Riteau <pierre.riteau@irisa.fr>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: rename socket variable
Paolo Bonzini [Fri, 4 Nov 2011 14:51:20 +0000 (15:51 +0100)]
qemu-nbd: rename socket variable

It will be moved to a global variable by the next patch, and it
would conflict with the socket function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-nbd: trap SIGTERM
Paolo Bonzini [Fri, 4 Nov 2011 14:51:19 +0000 (15:51 +0100)]
qemu-nbd: trap SIGTERM

The client process right now uses SIGTERM to interrupt the server side.
This does not affect the exit status of "qemu-nbd -v -c" because the
server is a child process.  This will change when both sides will be
in the same process, and anyway cleaning up things nicely upon SIGTERM
is good practice.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agonbd: treat EPIPE from NBD_DO_IT as success
Paolo Bonzini [Fri, 4 Nov 2011 14:51:18 +0000 (15:51 +0100)]
nbd: treat EPIPE from NBD_DO_IT as success

This can be seen with "qemu-nbd -v -c", which returns 1 instead of 0
when you disconnect with "qemu-nbd -d".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi-disk: implement eject requests
Paolo Bonzini [Tue, 25 Oct 2011 10:53:40 +0000 (12:53 +0200)]
scsi-disk: implement eject requests

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoatapi: implement eject requests
Paolo Bonzini [Tue, 25 Oct 2011 10:53:39 +0000 (12:53 +0200)]
atapi: implement eject requests

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: add eject request callback
Paolo Bonzini [Mon, 7 Nov 2011 16:50:13 +0000 (17:50 +0100)]
block: add eject request callback

Recent versions of udev always keep the tray locked so that the kernel
can observe "eject request" events (aka tray button presses) even on
discs that aren't mounted.  Add support for these events in the ATAPI
and SCSI cd drive device models.

To let management cope with the behavior of udev, an event should also
be added for "tray opened/closed".  This way, after issuing an "eject"
command, management can poll until the guests actually reacts to the
command.  They can then issue the "change" command after the tray has been
opened, or try with "eject -f" after a (configurable?) timeout.  However,
with this patch and the corresponding support in the device models,
at least it is possible to do a manual two-step eject+change sequence.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: Fix read-write mode
Kevin Wolf [Tue, 8 Nov 2011 09:50:12 +0000 (10:50 +0100)]
vvfat: Fix read-write mode

vvfat used to directly call into the qcow2 block driver instead of using the
block.c wrappers. With the coroutine conversion, this stopped working.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agohw/lan9118.c: Add missing 'break' to fix buffer overrun
Peter Maydell [Wed, 9 Nov 2011 18:59:54 +0000 (18:59 +0000)]
hw/lan9118.c: Add missing 'break' to fix buffer overrun

Add a missing 'break' statement to fix a buffer overrun when
executing the EEPROM write-all command. Spotted by Coverity
(see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agox86/cpuid: Fix crash on -cpu ""
Markus Armbruster [Tue, 8 Nov 2011 14:36:50 +0000 (15:36 +0100)]
x86/cpuid: Fix crash on -cpu ""

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agox86/cpuid: Plug memory leak in cpudef_setfield()
Markus Armbruster [Tue, 8 Nov 2011 14:36:49 +0000 (15:36 +0100)]
x86/cpuid: Plug memory leak in cpudef_setfield()

To reproduce the leak, put two name options into the same [cpudef]
section of target-x86_64.conf.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agox86/cpuid: Convert remaining strdup() to g_strdup()
Markus Armbruster [Tue, 8 Nov 2011 14:36:48 +0000 (15:36 +0100)]
x86/cpuid: Convert remaining strdup() to g_strdup()

Fixes missing error checking.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoui/vnc: Convert sasl.mechlist to g_malloc() & friends
Markus Armbruster [Tue, 8 Nov 2011 12:45:21 +0000 (13:45 +0100)]
ui/vnc: Convert sasl.mechlist to g_malloc() & friends

Fixes protocol_client_auth_sasl_mechname() not to crash when malloc()
fails.  Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqdev: Fix crash on -device '?=x'
Markus Armbruster [Tue, 8 Nov 2011 10:00:38 +0000 (11:00 +0100)]
qdev: Fix crash on -device '?=x'

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoconfigure: Show --cpu option on the help list
陳韋任 [Mon, 7 Nov 2011 09:42:05 +0000 (17:42 +0800)]
configure: Show --cpu option on the help list

Signed-off-by: Chen Wen-Ren (陳韋任) <chenwj@iis.sinica.edu.tw>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqemu-tech.texi: Update default code cache size
陳韋任 [Fri, 4 Nov 2011 17:14:44 +0000 (01:14 +0800)]
qemu-tech.texi: Update default code cache size

  Update the document since the default code cache size is 32 MB now.

Signed-off-by: chenwj <chenwj@cs.nctu.edu.tw>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agohpet: fix infinite loop in qemu_run_timers with -icount enabled
Max Filippov [Wed, 9 Nov 2011 01:18:09 +0000 (05:18 +0400)]
hpet: fix infinite loop in qemu_run_timers with -icount enabled

hpet_timer timer callback rearms itself based on difference between
current HPET tick counter and comparator value. Difference calculated by
the hpet_calculate_diff function is limited to non-negative values.

cur_tick is calculated via hpet_get_ticks that uses qemu_get_clock_ns(vm_clock).

With -icount enabled vm_clock doesn't advance during qemu_run_timers
loop thus once difference is zero, qemu_run_timers loops forever
handling hpet_timer.

Limit hpet_calculate_diff results to positive only values to avoid that
infinite loop.

This fixes the following qemu-system-x86_64 hang when it reaches
timer_irq_works() in the linux bootup:

[    0.000000] Fast TSC calibration using PIT
[    0.000000] Detected 1000.054 MHz processor.
[    0.000031] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.10 BogoMIPS (lpj=10000540)
[    0.000404] pid_max: default: 32768 minimum: 301
[    0.001138] Mount-cache hash table entries: 256
[    0.003883] Initializing cgroup subsys ns
[    0.004035] Initializing cgroup subsys cpuacct
[    0.004280] Initializing cgroup subsys freezer
[    0.004790] Performance Events: AMD PMU driver.
[    0.004985] ... version:                0
[    0.005134] ... bit width:              48
[    0.005285] ... generic registers:      4
[    0.005437] ... value mask:             0000ffffffffffff
[    0.005625] ... max period:             00007fffffffffff
[    0.005807] ... fixed-purpose events:   0
[    0.005957] ... event mask:             000000000000000f
[    0.006275] SMP alternatives: switching to UP code

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/omap_gpmc.c: Add missing 'break's to fix 8 bit NAND writes
Peter Maydell [Wed, 9 Nov 2011 17:42:23 +0000 (17:42 +0000)]
hw/omap_gpmc.c: Add missing 'break's to fix 8 bit NAND writes

Add missing 'break' statements which would have meant that writing
to an 8 bit NAND device was broken. Spotted by Coverity (see bug
887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agohw/omap_dss.c: Fix !-vs-~ bug in handling DISPC_CONTROL
Peter Maydell [Wed, 9 Nov 2011 17:20:06 +0000 (17:20 +0000)]
hw/omap_dss.c: Fix !-vs-~ bug in handling DISPC_CONTROL

Fix a bug revealed by a coverity scan (see bug 887883) which meant
that we would never print the warning about unpredictable behaviour
if a nonexistent overlay is enabled.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoi386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID
Avi Kivity [Wed, 9 Nov 2011 13:44:36 +0000 (15:44 +0200)]
i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID

The fact that a host cpu supports a feature doesn't mean that QEMU and KVM
will also support it, yet -cpuid host brings host features wholesale.

We need to whitelist each feature separately to make sure we support it.
This patch adds KVM whitelisting (by simply using KVM_GET_SUPPORTED_CPUID
instead of the CPUID instruction).

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoconfigure: fix detection for xattr.h on modern distributions
Avi Kivity [Wed, 9 Nov 2011 12:44:52 +0000 (14:44 +0200)]
configure: fix detection for xattr.h on modern distributions

Modern distributions place xattr.h in /usr/include/sys, and fold
libattr.so into libc.  They also don't have an ENOATTR.

Make configure detect this, and add a qemu-xattr.h file that
directs the #include to the right place.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoClean up assertion in get_boot_devices_list()
Markus Armbruster [Tue, 8 Nov 2011 09:58:00 +0000 (10:58 +0100)]
Clean up assertion in get_boot_devices_list()

g_strdup() can't fail, remove assertion.  Assert its argument can't be
null, because that's not obvious (add_boot_device_path() ensures it).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoReplace WriteFileEx with WriteFile in qemu_create_pidfile
Fabien Chouteau [Mon, 7 Nov 2011 14:36:14 +0000 (15:36 +0100)]
Replace WriteFileEx with WriteFile in qemu_create_pidfile

The function that writes pidfile for win32 uses WriteFileEx which is an
asynchronous IO function. The arguments given to WriteFileEx are allocated on
the stack and one of them is "in out". When the IO operation is actually
executed the calling function has already returned, so the arguments are no
longer allocated or allocated to another frame.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agowin32: remove broken timers
Paolo Bonzini [Wed, 9 Nov 2011 11:46:56 +0000 (12:46 +0100)]
win32: remove broken timers

The non-dynticks timer variations are broken, so they can be
removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovirtex: Remove memset of clk_setup
Edgar E. Iglesias [Mon, 7 Nov 2011 23:00:55 +0000 (00:00 +0100)]
virtex: Remove memset of clk_setup

clk_setup is now a function. Fixes a segfault.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agoUpdate version for v1.0-rc1
Anthony Liguori [Mon, 7 Nov 2011 16:57:45 +0000 (10:57 -0600)]
Update version for v1.0-rc1

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoconsole: Fix rendering of VGA underline
Markus Armbruster [Fri, 4 Nov 2011 09:38:29 +0000 (10:38 +0100)]
console: Fix rendering of VGA underline

vga_putcharxy()'s underline code sets font_data to 0xffff instead of
0xff.  vga_putcharxy() then reads dmask16[0xffff >> 4] and
dmask4[0xffff >> 6].  In practice, these out-of-bounds subscripts
"only" put a few crap bits into the display surface.

For 32 bit pixels, there's no array access.  font_data's extra bits go
straight into the display surface.

Broken when commit 6d6f7c28 implemented underline.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqemu_timedate_diff() shouldn't modify its argument.
Gleb Natapov [Sun, 6 Nov 2011 16:00:22 +0000 (18:00 +0200)]
qemu_timedate_diff() shouldn't modify its argument.

The caller of qemu_timedate_diff() does not expect that tm it passes to
the function will be modified, but mktime() is destructive and modifies
its argument. Pass a copy of tm to it and set tm_isdst so that mktime()
will not rely on it since its value may be outdated.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoreenable vm_clock when resuming all vcpus
Wen Congyang [Fri, 4 Nov 2011 02:45:58 +0000 (10:45 +0800)]
reenable vm_clock when resuming all vcpus

We disable vm_clock when pausing all vcpus, but we forget to
reenable it when resuming all vcpus. It will cause that the
guest can not be rebooted.

Tested-by: Zhi Yong Wu <zwu.kernel@gmai.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqxl: fix vga port initialization.
Gerd Hoffmann [Thu, 3 Nov 2011 17:21:54 +0000 (18:21 +0100)]
qxl: fix vga port initialization.

Commit 0a039dc70096b768d3810afa50ba1d214768aaf4 broke vga modes for
qxl-vga by loosing vga_ioport_read windup.  qxl needs to hook into
vga port writes only and used to realize that by letting vga_init() do
the work for both reads and writes, then overwrite the write function.
That little detail was missed while doing the conversion ...

This patch fixes it.  It also switch qxl vga ioport registration to
portio lists while being at it.

Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoac97: don't override the pci subsystem id
Gerd Hoffmann [Mon, 7 Nov 2011 15:33:09 +0000 (16:33 +0100)]
ac97: don't override the pci subsystem id

This patch removes the code lines which set the subsystem id for the
emulated ac97 card to 8086:0000.  Due to the device id being zero the
subsystem id isn't vaild anyway.  With the patch applied the sound card
gets the default qemu subsystem id (1af4:1100) instead.

[ v2: old & broken id is maintained for -M pc-$oldqemuversion ]

Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agopc: add 1.0 machine type
Gerd Hoffmann [Mon, 7 Nov 2011 15:33:08 +0000 (16:33 +0100)]
pc: add 1.0 machine type

This patch adds a pc-1.0 machine type.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agodisable automatic loading of sgabios when -nographic
Paolo Bonzini [Thu, 3 Nov 2011 15:00:22 +0000 (16:00 +0100)]
disable automatic loading of sgabios when -nographic

sgabios hasn't gotten a lot of coverage since it was not shipped.  For 1.0,
let's disable the automatic loading of the option ROM in -nographic
mode.  We can put it back for 1.1.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd sgabios blob and submodule
Paolo Bonzini [Thu, 3 Nov 2011 14:14:00 +0000 (15:14 +0100)]
add sgabios blob and submodule

The rom was not added together with the sgabios device and is
not installed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 7 Nov 2011 16:57:27 +0000 (10:57 -0600)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

13 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 7 Nov 2011 16:56:38 +0000 (10:56 -0600)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

13 years agoxen-platform: Fix IO port read/write functions
Anthony PERARD [Fri, 4 Nov 2011 15:35:11 +0000 (15:35 +0000)]
xen-platform: Fix IO port read/write functions

Somehow, the read/write functions handle an offset that does not exist anymore.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoreadline: Fix buffer overrun on re-add to history
Markus Armbruster [Fri, 4 Nov 2011 10:10:01 +0000 (11:10 +0100)]
readline: Fix buffer overrun on re-add to history

readline_hist_add() moves the history entry to the end of history.  It
uses memmove() to move rs->history[idx + 1..] to rs->history[idx..].
However, its size argument is off by two array elements, so it writes
one element beyond rs->history[], and reads two.

On my system, this clobbers rs->hist_entry and the hole right after
it.  Since the function assigns to rs->hist_entry in time, the bug has
no ill effects for me.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocmd: Fix potential memory leak
Pavel Borzenkov [Mon, 31 Oct 2011 18:53:38 +0000 (22:53 +0400)]
cmd: Fix potential memory leak

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocmd: Fix potential NULL pointer dereference
Pavel Borzenkov [Mon, 31 Oct 2011 18:53:37 +0000 (22:53 +0400)]
cmd: Fix potential NULL pointer dereference

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocmd: Fix coding style in cmd.c
Pavel Borzenkov [Mon, 31 Oct 2011 18:53:36 +0000 (22:53 +0400)]
cmd: Fix coding style in cmd.c

Before the next patches, fix coding style of the affected functions.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoarm_gic: handle banked enable bits for per-cpu interrupts
Rabin Vincent [Sun, 6 Nov 2011 16:01:08 +0000 (16:01 +0000)]
arm_gic: handle banked enable bits for per-cpu interrupts

The first enable set/clear register (which controls the PPIs and SGIs)
is supposed to be banked for each processor.  Currently it is just
handled globally and this prevents recent SMP Linux kernels from
booting, because CPU0 stops receiving localtimer interrupts when CPU1
disables them locally.

To fix this, allow the enable bits to be enabled per-cpu.  For SPIs,
always enable/disable ALL_CPU_MASK.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13 years agovvfat: reorganize computation of disk geometry
Paolo Bonzini [Fri, 4 Nov 2011 16:21:53 +0000 (17:21 +0100)]
vvfat: reorganize computation of disk geometry

First determine FAT12/16/32, then compute geometry from that for both
FDD and HDD.  For 1.44MB floppies, and 2.88MB floppies using FAT16,
change to 1 sector/cluster.  The default remains 2.88MB with FAT12
and 2 sectors/cluster.  Both DOS and mkdosfs by default format a 2.88MB
floppy as FAT12.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: do not hardcode sector counts in error message
Paolo Bonzini [Wed, 5 Oct 2011 07:12:07 +0000 (09:12 +0200)]
vvfat: do not hardcode sector counts in error message

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: unify and correct computation of sector count
Paolo Bonzini [Wed, 5 Oct 2011 07:12:06 +0000 (09:12 +0200)]
vvfat: unify and correct computation of sector count

The sector count is stored in the partition and hence must not include the
sectors before its start.  At the same time, remove the useless special
casing for 1.44 MB floppies.  This fixes fsck on VVFAT hard disks,
which otherwise tries to seek past the end of the disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: need to use first_sectors_number to distinguish fdd/hdd
Paolo Bonzini [Wed, 5 Oct 2011 07:12:05 +0000 (09:12 +0200)]
vvfat: need to use first_sectors_number to distinguish fdd/hdd

This is consistent with what "real" floppies have, so file(1)
now actually recognizes the VVFAT image as a 1.44 MB floppy.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: do not fail if the disk has spare sectors
Paolo Bonzini [Wed, 5 Oct 2011 07:12:04 +0000 (09:12 +0200)]
vvfat: do not fail if the disk has spare sectors

If the number of "faked sectors" + the number of sectors that are
part of a cluster does not sum up to the total number of sectors,
qemu-img convert fails.  Read these spare sectors as all zeros.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovvfat: fix out of bounds array_get usage
Paolo Bonzini [Wed, 5 Oct 2011 07:12:03 +0000 (09:12 +0200)]
vvfat: fix out of bounds array_get usage

When reading the address of the first free entry, you cannot
use array_get without first marking all entries as occupied.

This is visible if you change the sectors per cluster on a
floppy from 2 to 1.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/cloop: Use g_free instead of free
Dong Xu Wang [Wed, 2 Nov 2011 08:36:21 +0000 (16:36 +0800)]
block/cloop: Use g_free instead of free

Fix mismatching allocation and deallocation: g_free should be used to pair with
g_malloc.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/cloop: Fix coding style
Dong Xu Wang [Wed, 2 Nov 2011 08:36:20 +0000 (16:36 +0800)]
block/cloop: Fix coding style

Fix coding style in block/cloop.c.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agodma: Avoid reentrancy in DMA transfer handlers
Kevin Wolf [Fri, 28 Oct 2011 09:28:13 +0000 (05:28 -0400)]
dma: Avoid reentrancy in DMA transfer handlers

With the conversion of the block layer to coroutines, bdrv_read/write
have changed to run a nested event loop that calls qemu_bh_poll.
Consequently a scheduled BH can be called while a DMA transfer handler
runs and this means that DMA_run becomes reentrant.

Devices haven't been designed to cope with that, so instead of running a
nested transfer handler just wait for the next invocation of the BH from the
main loop.

This fixes some problems with the floppy device.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-io: Fix multiwrite_f error handling
Kevin Wolf [Mon, 31 Oct 2011 10:49:21 +0000 (11:49 +0100)]
qemu-io: Fix multiwrite_f error handling

Without this fix, some qiovs can be leaked if an error occurs. Also a semicolon
at the end of the command line would make the code walk beyond the end of argv.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-io: Handle create_iovec errors
Kevin Wolf [Mon, 31 Oct 2011 10:36:32 +0000 (11:36 +0100)]
qemu-io: Handle create_iovec errors

Callers of create_iovec() didn't check for failure and continued with
uninitialised data in error cases. This patch adds checks to each call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoMerge branch 'xtensa' of git://jcmvbkbc.spb.ru/dumb/qemu-xtensa
Blue Swirl [Wed, 2 Nov 2011 20:52:23 +0000 (20:52 +0000)]
Merge branch 'xtensa' of git://jcmvbkbc.spb.ru/dumb/qemu-xtensa

* 'xtensa' of git://jcmvbkbc.spb.ru/dumb/qemu-xtensa:
  xtensa_lx60: fix build date code and change memory region names
  xtensa_lx60: pass kernel arguments from -append
  xtensa_lx60: add FLASH support
  target-xtensa: raise an exception for invalid and reserved opcodes
  target-xtensa: handle cache options in the overlay tool
  target-xtensa: mask out undefined bits of WINDOWSTART SR

13 years agoMerge branch 'tci' of git://qemu.weilnetz.de/qemu
Blue Swirl [Wed, 2 Nov 2011 20:52:13 +0000 (20:52 +0000)]
Merge branch 'tci' of git://qemu.weilnetz.de/qemu

* 'tci' of git://qemu.weilnetz.de/qemu:
  tcg: Add tcg interpreter to configure / make
  tcg: Add tci disassembler
  tcg: Add interpreter for bytecode
  tcg: Add bytecode generator for tcg interpreter
  tcg: Make ARRAY_SIZE(tcg_op_defs) globally available
  tcg: TCG targets may define tcg_qemu_tb_exec