Commit graph

19729 commits

Author SHA1 Message Date
Blue Swirl 90449c3887 sparc: fix qtest
Initialize TCG only when enabled.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-19 18:52:48 +00:00
Blue Swirl e776bffb53 qtest: add dummy functions for user emulators
Allow qtest to be used also in files used for user emulators by
introducing dummy functions.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-19 18:52:35 +00:00
Blue Swirl 85215d419b qtest: add register fuzzing to RTC test
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-19 18:14:55 +00:00
Michael Roth 4bdd04165a qemu-ga: fix help output
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-04-19 10:45:07 -05:00
Michael Roth d35d4cb517 qemu-ga: generate missing stubs for fsfreeze
When linux-specific commands (including guest-fsfreeze-*) were consolidated
under defined(__linux__), we forgot to account for the case where
defined(__linux__) && !defined(FIFREEZE). As a result stubs are no longer
being generated on linux hosts that don't have FIFREEZE support. Fix
this.

Tested-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-04-19 10:42:59 -05:00
Paolo Bonzini e25ceb76e5 nbd: obey FUA on reads
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 17:19:37 +02:00
Paolo Bonzini 38ceff0412 nbd: do not include block_int.h
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 17:19:37 +02:00
Paolo Bonzini 9eb0bfca96 aio: simplify qemu_aio_wait
The do...while loop can never loop, because select will just not return
0 when invoked with infinite timeout.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:51:47 +02:00
Paolo Bonzini bcdc18578d aio: return "AIO in progress" state from qemu_aio_wait
The definition of when qemu_aio_flush should loop is much simpler
than it looks.  It just has to call qemu_aio_wait until it makes
no progress and all flush callbacks return false.  qemu_aio_wait
is the logical place to tell the caller about this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:50:49 +02:00
Paolo Bonzini bafbd6a1c6 aio: remove process_queue callback and qemu_aio_process_queue
Both unused after the previous patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:37:53 +02:00
Paolo Bonzini 7fe7b68b32 nbd: do not block in nbd_wr_sync if no data at all is available
Right now, nbd_wr_sync will hang if no data at all is available on the
socket and the other side is not going to provide any.  Relax this by
making it loop only for writes or partial reads.  This fixes a race
where one thread is executing qemu_aio_wait() and another is executing
main_loop_wait().  Then, the select() call in main_loop_wait() can return
stale data and call the "readable" callback with no data in the socket.

Reported-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:36:43 +02:00
Paolo Bonzini 185b43386a nbd: consistently return negative errno values
In the next patch we need to look at the return code of nbd_wr_sync.
To avoid percolating the socket_error() ugliness all around, let's
handle errors by returning negative errno values.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:36:43 +02:00
Paolo Bonzini fc19f8a02e nbd: consistently check for <0 or >=0
This prepares for the following patch, which changes -1 return values
to negative errno.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:36:43 +02:00
Paolo Bonzini 94e7340b5d nbd: consistently use ssize_t
GCC (pedantically, but correctly) considers that a negative ssize_t may
become positive when casted to int.  This may cause uninitialized variable
warnings when a function returns such a negative ssize_t and is inlined.
Propagate ssize_t return types to avoid this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:36:43 +02:00
Paolo Bonzini dd3e8ac413 nbd: avoid out of bounds access to recv_coroutine array
This can happen with a buggy or malicious server.

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:36:42 +02:00
Paolo Bonzini adfe92f6d1 posix-aio: merge posix_aio_process_queue and posix_aio_read
posix_aio_read already calls qemu_aio_process_queue, and dually
qemu_aio_process_queue is always followed by a select loop that calls
posix_aio_read.

No races are possible, so there is no need for a separate process_queue
callback.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:35:43 +02:00
Paolo Bonzini 8a83205d34 qemu-tool: map vm_clock to rt_clock
QED uses vm_clock timers so that images are not touched during and after
migration.  This however does not apply to qemu-io and qemu-img.
Treat vm_clock as a synonym for rt_clock there, and enable it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:30:25 +02:00
Paolo Bonzini a5a5238ee4 qemu-io: use main_loop_wait
This will let timers run during aio_read and aio_write commands,
though not during synchronous commands.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:29:33 +02:00
Paolo Bonzini 3e46d87d66 scsi: add SANITIZE command
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:26:33 +02:00
Ronnie Sahlberg f644a2904d SCSI emulation: should tell the guest that we actually support thin provisioning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
[Actually, we should report it only if discard_granularity is nonzero.
 Older SBC drafts assigned 0 to thin provisioning and 1 to thick
 (resource-provisioned, they call it).  Newer drafts assign respectively
 1 and 2 - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:26:29 +02:00
Ronnie Sahlberg c9e4d8284e SCSI emulation: Support unmap via WRITE_SAME_10.
This was added in SBC r26 in place of the reserved bits that were
present up to that version.

It is the same as WRITE_SAME_16 as far as QEMU is concerned.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:16:05 +02:00
Paolo Bonzini 6a2de0f203 scsi: advertise DPOFUA
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:16:05 +02:00
Paolo Bonzini e590ecbed5 scsi: small refactoring of MMC mode-sense
Make DBD a boolean value, and force device-specific parameter to zero.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:16:05 +02:00
Paolo Bonzini ac66842646 scsi: support FUA on reads
To force unit access on reads, flush the cache *before* doing the read.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:16:05 +02:00
Paolo Bonzini a0e66a699e scsi: add a started field to SCSIDiskReq
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:16:05 +02:00
Paolo Bonzini 7f64f8e2c3 scsi: force unit access on VERIFY
Also DMA data from the host, to avoid that the host reports an
underrun.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:15:58 +02:00
Paolo Bonzini 3ed9902528 block: allow interrupting a co_sleep_ns
In the next patch we want to reenter the coroutine from
block_job_cancel_sync and cancel the timer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:03:27 +02:00
Kevin Wolf 2795ecf681 qcow2: Fix return value of alloc_refcount_block
Someone forgot something in commit 29c1a730... Documenting the right
return value is not enough, you also need to actually return it in the
code.

This bug sometimes causes error return values even when everything has
succeeded: The new offset of the refcount block is truncated to 32 bits
and interpreted as signed. At least with small cluster sizes it's easy
to get a negative return value this way.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:03:27 +02:00
Kevin Wolf 8dc0a5e7a0 qcow2: Fix error handling in qcow2_alloc_cluster_offset
If do_alloc_cluster_offset() fails, the error handling code tried to
remove the request from the in-flight queue, to which it wasn't added
yet, resulting in a NULL pointer dereference.

m->nb_clusters really only becomes != 0 when the request is in the list.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:03:27 +02:00
Stefan Hajnoczi e82dabd82e ide: convert ide_sector_write() to asynchronous I/O
The IDE PIO write sector code path uses bdrv_write() and hence can make
the guest unresponsive while the I/O request is in progress.  This patch
converts ide_sector_write() to use bdrv_aio_writev() by using the
BUSY_STAT bit to tell the guest that the request is in progress.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Tested-by: Richard Davies <richard@arachsys.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:03:27 +02:00
Stefan Hajnoczi bef0fd5958 ide: convert ide_sector_read() to asynchronous I/O
The IDE PIO interface currently uses bdrv_read() to perform reads
synchronously.  Synchronous I/O in the vcpu thread is bad because it
prevents the guest from executing code - it makes the guest
unresponsive.

This patch converts IDE PIO to use bdrv_aio_readv().  We simply need to
use the BUSY_STAT status so the guest knows to wait while we are busy.

The only external user of ide_sector_read() is restart behavior on I/O
errors and it is not affected by this change.  We still need to restart
I/O in the same way.

Migration is also unaffected if I understand the code correctly.  We
continue to use the same transfer function and the BUSY_STAT status
should never be migrated since we flush I/O before migrating device
state.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Tested-by: Richard Davies <richard@arachsys.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 16:03:27 +02:00
Kevin Wolf 592fa07043 qemu-io: Add command line switch for cache mode
To be used as in 'qemu-io -t writeback test.img'

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 16:03:16 +02:00
Stefan Weil 4e35b92a51 block: Fix spelling in comment (ineffcient -> inefficient)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19 15:48:52 +02:00
Dong Xu Wang 8ff9ae00da iotests: fix error in 005
According comment, we should not read again, we will write.

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>
2012-04-19 15:48:52 +02:00
Kevin Wolf 7094f12f86 block: Drain requests in bdrv_close
If an AIO request is in flight that refers to a BlockDriverState that
has been closed and possibly even freed, more or less anything could
happen. I have seen segfaults, -EBADF return values and qcow2 sometimes
actually catches the situation in bdrv_close() and abort()s.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:48:52 +02:00
Kevin Wolf aafcdcc9eb qemu-iotests: Test bdrv_close while AIO is in flight
If the BlockDriverState is closed/freed without draining the AIO
requests first, the request coroutines may work on invalid data and file
descriptors or have some dangling pointers that cause segfaults.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:48:52 +02:00
Kevin Wolf 7299550b25 qemu-iotests: Always filter cluster_size out in _make_test_img
Some image formats do have a cluster size, others don't, but there are
tests that work with both sets of images and currently we get failures
because the qemu-img create output doesn't mention the cluster size for
some formats.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:48:52 +02:00
Paolo Bonzini 7e8c49c561 scsi: add support for FUA on writes
To force unit access, add a flush operation after the actual write.
WRITE AND VERIFY commands always flush according to SBC, so do it
even though we do not perform the reread.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:27:20 +02:00
Paolo Bonzini b77912a77a scsi: move scsi_flush_complete around
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:27:20 +02:00
Paolo Bonzini 80624c938d scsi: make code more homogeneous in AIO callback functions
First scsi_flush_complete, like scsi_dma_complete, is always called with
an active AIOCB.

Second, always test for "ret < 0" to check for errors.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:27:20 +02:00
Paolo Bonzini b8aba8d7e3 scsi: add missing test for cancelled request
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 15:27:19 +02:00
Paolo Bonzini d2ad7dd46e virtio-scsi: add multiqueue capability
Adding multiqueue is as simple as creating more than one virtqueues,
and saving the queue number for each request.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 10:31:05 +02:00
Paolo Bonzini c80decdbd9 virtio: add virtio_queue_get_id
Serializing virtio-scsi requests needs a simple way to get from a
VirtQueue to the number of the queue.  The virtio_queue_get_id
provides this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 10:31:05 +02:00
Paolo Bonzini fcf104a74c virtio-scsi: prepare migration format for multiqueue
In order to restore requests correctly from a multitude of virtqueues,
we need to store the id of the request queue that each request came
from.

Do this even for single-queue, by storing a hard-coded zero, to
simplify future implementation of multiqueue.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 10:31:05 +02:00
Paolo Bonzini b7c8c35f0a scsi: fix memory leak
scsibus_get_dev_path is leaking id if it is not NULL.  Fix it.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-04-19 10:31:05 +02:00
Anthony Liguori 51006bbc45 Merge remote-tracking branch 'origin/master' into staging
* origin/master:
  Allow controlling volume with PulseAudio backend
  configure: pa_simple is not needed anymore
  Do not use pa_simple PulseAudio API
  audio/spice: add support for volume control
  hw/ac97: add support for volume control
  hw/ac97: the volume mask is not only 0x1f
  hw/ac97: remove USE_MIXER code
  audio: don't apply volume effect if backend has VOICE_VOLUME_CAP
  audio: add VOICE_VOLUME ctl
2012-04-18 10:06:09 -05:00
Stefan Hajnoczi 256a721d46 tracetool: handle DTrace keywords 'in', 'next', 'self'
Language keywords cannot be used as argument names.  The DTrace backend
appends an underscore to the argument name in order to make the argument
name legal.

This patch adds 'in', 'next', and 'self' keywords to dtrace.py.

Also drop the unnecessary argument name lstrip() call.  The
Arguments.build() method already ensures there is no space around
argument names.  Furthermore it is misleading to do the lstrip() *after*
checking against keywords because the keyword check would not match if
spaces were in the name.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Reviewed-by: Lluís Vilanova <vilanova@ac.upc.edu>
2012-04-18 14:03:00 +01:00
Lluís Vilanova f70fd8fdf6 tracetool: Add MAINTAINERS info
Update the MAINTAINERS file to reflect the new Python tracetool code.

[Commit description written by Stefan Hajnoczi]

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-04-18 14:03:00 +01:00
Lluís Vilanova 52ef093ace tracetool: Add support for the 'dtrace' backend
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-04-18 14:03:00 +01:00
Lluís Vilanova fbc54b9412 tracetool: Add support for the 'ust' backend
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-04-18 14:03:00 +01:00