Paolo Bonzini [Mon, 12 Dec 2011 16:21:34 +0000 (17:21 +0100)]
ccid: make threads joinable
Destroying a mutex that another thread might have just unlocked
is racy. It usually works, but you cannot do that in general and
can lead to deadlocks or segfaults. Change ccid to use joinable
threads instead.
(Also, qemu_mutex_init/qemu_cond_init were missing).
Paolo Bonzini [Mon, 12 Dec 2011 16:21:33 +0000 (17:21 +0100)]
qemu-thread: implement joinable threads for Win32
Rewrite the handshaking between qemu_thread_create and the
win32_start_routine, so that the thread can be joined without races.
Similar handshaking is done now between qemu_thread_exit and
qemu_thread_join.
This also simplifies how QemuThreads are initialized.
Jan Kiszka [Mon, 12 Dec 2011 16:21:32 +0000 (17:21 +0100)]
qemu-thread: implement joinable threads for POSIX
Allow to control if a QEMU thread is created joinable or not. Make it
not joinable by default to avoid that we keep the associated resources
around when terminating a thread without joining it (what we couldn't do
so far for obvious reasons).
The audio subsystem will need the join feature when converting it to
QEMU threading/locking abstractions, so provide that service.
Jan Kiszka [Mon, 12 Dec 2011 16:21:31 +0000 (17:21 +0100)]
qemu-thread: add API for joinable threads
Split from Jan's original qemu-thread-posix.c patch. No semantic change,
just introduce the new API that POSIX and Win32 implementations will
conform to.
Stefan Hajnoczi [Mon, 12 Dec 2011 12:11:41 +0000 (12:11 +0000)]
syborg: drop support for Symbian Virtual Platform
The Symbian Virtual Platform was an ARM-based development and debugging
board. Since Symbian has been disbanded and the code is no longer being
used it can now be removed.
Stefan Hajnoczi [Wed, 7 Dec 2011 15:01:49 +0000 (15:01 +0000)]
net: take ownership of fd in socket init functions
Today net/socket.c has no consistent policy for closing the socket file
descriptor when initialization fails. This means we leak the file
descriptor in some cases or we could also try to close it twice.
Make error paths consistent by taking ownership of the file descriptor
and closing it on error.
Michael Roth [Wed, 7 Dec 2011 04:03:43 +0000 (22:03 -0600)]
guest agent: add supported command list to guest-info RPC
Not that there is blacklisting functionality we can no longer infer
the agent's capabilities via version. This patch extends the current
guest-info RPC to also return a list of dictionaries containing the name
of each supported RPC, along with a boolean indicating whether or not
the command has been disabled by a guest administrator/distro.
This adds a command-line option, -b/--blacklist, that accepts a
comma-seperated list of RPCs to disable, or prints a list of
available RPCs if passed "?".
In consequence this also adds general blacklisting and RPC listing
facilities to the new QMP dispatch/registry facilities, should the
QMP monitor ever have a need for such a thing.
Ideally, to avoid support/compatability issues in the future,
blacklisting guest agent functionality will be the exceptional
case, but we add the functionality here to handle guest administrators
with specific requirements.
Eduardo Habkost [Thu, 10 Nov 2011 12:41:43 +0000 (10:41 -0200)]
qemu_fclose: return last_error if set (v3)
This will make sure no error will be missed as long as callers always
check for qemu_fclose() return value. For reference, this is the
complete list of qemu_fclose() callers:
- exec_close(): already fixed to check for negative values, not -1
- migrate_fd_cleanup(): already fixed to consider only negative values
as error, not any non-zero value
- exec_accept_incoming_migration(): no return value check (yet)
- fd_accept_incoming_migration(): no return value check (yet)
- tcp_accept_incoming_migration(): no return value check (yet)
- unix_accept_incoming_migration(): no return value check (yet)
- do_savevm(): no return value check (yet)
- load_vmstate(): no return value check (yet)
Changes v1 -> v2:
- Add small comment about the need to return previously-spotted errors
Changes v2 -> v3:
- Add braces to "if" statements to match coding style
Eduardo Habkost [Thu, 10 Nov 2011 12:41:42 +0000 (10:41 -0200)]
migrate_fd_cleanup: accept any negative qemu_fclose() value as error
Also, we now return the qemu_fclose() value unchanged to the caller. For
reference, the migrate_fd_cleanup() callers are the following:
- migrate_fd_completed(): any negative value is considered an
error, so the change is OK.
- migrate_fd_error(): doesn't check the migrate_fd_cleanup() return value
- migrate_fd_cancel(): doesn't check the migrate_fd_cleanup() return
value
Eduardo Habkost [Thu, 10 Nov 2011 12:41:41 +0000 (10:41 -0200)]
exec_close(): accept any negative value as qemu_fclose() error
Note that we don't return the unchanged return value back yet, because
we need to change all qemu_fclose() callers to accept any positive value
as success.
David Gibson [Fri, 4 Nov 2011 01:03:38 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in usb-uhci
This patch removes some unnecessary casts in the usb-uhci device,
introduced by commit fff23ee9a5de74ab111b3cea9eec56782e7d7c50
'usb-uhci: Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:37 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in usb-ehci
This patch removes some unnecessary casts in the usb-ehci device,
introduced by commit 68d553587c0aa271c3eb2902921b503740d775b6
'usb-ehci: Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:36 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in rtl8139
This patch removes some unnecessary casts in the rtl8139 device,
introduced by commit 3ada003aee2004d24f23b9cd6f4eda87d9601ddb
'rtl8139: Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:35 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in lsi53c895a
This patch removes some unnecessary casts in the lsi53c895a device,
introduced by commit 9ba4524cda1348cbe741535f77815dca6a57da05
'lsi53c895a: Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:34 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in PCI IDE
This patch removes some unnecessary casts in the PCI IDE device,
introduced by commit 552908fef5b67ad9d96b76d7cb8371ebc26c9bc8
'PCI IDE: Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:33 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in e1000
This patch removes some unnecessary casts in the e1000 device,
introduced by commit 62ecbd353d25e62c4a6c327ea88ba5404e13507a 'e1000:
Use PCI DMA stub functions'.
David Gibson [Fri, 4 Nov 2011 01:03:32 +0000 (12:03 +1100)]
Remove unnecessary casts from PCI DMA code in eepro100
This patch removes some unnecessary casts in the eepro100 device,
introduced by commit 16ef60c9a8eeee269f7cbc95219a431b1d7cbf29
'eepro100: Use PCI DMA stub functions'.
Peter Maydell [Mon, 5 Dec 2011 13:49:18 +0000 (13:49 +0000)]
hw/mpcore: Clean up mpcore_priv_read/write as they are now SCU only
The only code left in mpcore_priv_read and mpcore_priv_write is now
the implementation of the SCU registers. Clean up by renaming functions
and removing some unnecessary conditionals to make this clearer.
Peter Maydell [Mon, 5 Dec 2011 13:43:26 +0000 (13:43 +0000)]
hw/mpcore.c: Use the GIC memory regions for the CPU interface
Switch to using the GIC memory regions for the CPU interface
rather than hand implementing them as a subcase of mpcore_priv_read()
and mpcore_priv_write().
Peter Chubb [Mon, 12 Dec 2011 10:25:42 +0000 (10:25 +0000)]
Fix sp804 dual-timer
Properly implement dual-timer read/write for the sp804 dual timer module.
Based on ARM specs at
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html
When the i386 cmpxchg instruction is executed with a memory operand
and the comparison result is "unequal", do the memory write before
changing the accumulator instead of the other way around, because
otherwise the new accumulator value will incorrectly be used in the
comparison when the instruction is restarted after a page fault.
This bug was originally reported on 2010-04-25 as
https://bugs.launchpad.net/qemu/+bug/569760
Stefan Weil [Sat, 3 Dec 2011 21:32:37 +0000 (22:32 +0100)]
w32: Disable buffering for log file
W32 does not support line buffering, but it supports unbuffered output.
Unbuffered output is better for writing to qemu.log than fully buffered
output because it also shows the latest log messages when an application
crash occurs.
Instead of a GUI application, a console application is created.
This has disadvantages (there is always an empty console window) and
no obvious reason, so this patch removes the strange flag modification.
The SDL GUI applications still can be run from a console window
and even send stdout and stderr to that console by setting environment
variable SDL_STDIO_REDIRECT=no.
Luiz Capitulino [Fri, 25 Nov 2011 18:15:19 +0000 (16:15 -0200)]
qapi: Convert blockdev_snapshot_sync
Unfortunately, this conversion required an additional change.
In the old QMP command, the 'snapshot-file' argument is specified as
optional. The idea is to take the snapshot internally if 'snapshot-file'
is not passed. However, internal snapshots are not supported yet so
the command returns a MissingParamater error if 'snapshot-file' is not
passed. Which makes the argument actually required and will cause
compatibility breakage if we change that in the future.
To fix this the QAPI converted blockdev_snapshot_sync command makes the
'snapshot-file' argument required. Again, in practice it's actually required,
so this is not incompatible.
If we do implement internal snapshots someday, we'll need a new argument
for it.
Luiz Capitulino [Fri, 25 Nov 2011 16:38:09 +0000 (14:38 -0200)]
qapi: Convert balloon
Note that the command being dropped uses the deprecated MONITOR_CMD_ASYNC
API, but the new command is a regular synchronous command. There shouldn't
be visible differences though, as MONITOR_CMD_ASYNC is internal only.
Luiz Capitulino [Mon, 28 Nov 2011 01:07:45 +0000 (23:07 -0200)]
console: Drop unused prototypes
Commit e235cec3762d2aa20b548114ea7b172113690463 converted the query-mice
command to the QAPI but forgot to remove two prototypes used by the old
QAPI. Drop them.
Luiz Capitulino [Mon, 28 Nov 2011 00:40:03 +0000 (22:40 -0200)]
qapi: Complete system_powerdown conversion
Commit 5bc465e4b1b6f4582a400c0a7033a1c841744278 converted only
the HMP part of the system_powerdown command to the QAPI, this
commit completes it by converting the QMP part too.
Luiz Capitulino [Mon, 21 Nov 2011 16:00:37 +0000 (14:00 -0200)]
configure: Don't mix glib and libcheck tests
test-coroutine is listed as a libcheck test in the 'checks' variable. This
is not right because 'make check' won't run test-coroutine if libcheck
tests are not enabled (either because libcheck isn't detected or because
--disable-check-utests is passed).
Tests using the glib test framework are independent from libcheck and
afaik are always present (although having a configure switch to disable
them is probably worth it).
Untangle test-coroutine from the libcheck tests by introducing the
'test_progs' variable and using it to generate the test list used by
'make check'.
Peter Maydell [Thu, 1 Dec 2011 18:37:17 +0000 (19:37 +0100)]
hw/arm_gic.c: Ignore attempts to complete nonexistent IRQs
Ignore attempts to complete non-existent IRQs; this fixes a buffer
overrun if the guest writes a bad value to the GICC_EOIR register.
(This case is UNPREDICTABLE so ignoring it is a valid choice.)
Note that doing nothing if the guest writes 1023 to this register
is not in fact a change in behaviour: the old code would also
always do nothing in this case but in a non-obvious way.
(The buffer overrun was noted by Coverity, see bug 887883.)
Peter Maydell [Wed, 30 Nov 2011 09:57:48 +0000 (10:57 +0100)]
configure: Drop armv4l/armv4b distinction in $cpu
Drop the distinction between armv4l/armv4b in the $cpu variable
(ie host cpu type) in favour of calling everything 'arm'. This
makes it the same as the ARCH setting and removes some special
casing. The only thing we were using the distinction for was to
decide which endianness to use in cross compilation; do a cpp
define check there instead.
David Gibson [Tue, 29 Nov 2011 06:21:39 +0000 (07:21 +0100)]
pseries: Fix array overrun bug in PCI code
spapr_populate_pci_devices() containd a loop with PCI_NUM_REGIONS (7)
iterations. However this overruns the 'bars' global array, which only has
6 elements. In fact we only want to run this loop for things listed in the
bars array, so this patch corrects the loop bounds to reflect that.
Peter Maydell [Thu, 24 Nov 2011 18:33:31 +0000 (19:33 +0100)]
target-arm/translate.c: Fix slightly misleading comment in Thumb decoder
Clarify some slightly misleading comments in the Thumb decoder's
handling of the memory hint space -- in particular one code path
marked as 'UNPREDICTABLE or unallocated hint' also includes some
legitimate preload instructions.
Stefan Hajnoczi [Wed, 30 Nov 2011 12:23:43 +0000 (12:23 +0000)]
block: convert qemu_aio_flush() calls to bdrv_drain_all()
Many places in QEMU call qemu_aio_flush() to complete all pending
asynchronous I/O. Most of these places actually want to drain all block
requests but there is no block layer API to do so.
This patch introduces the bdrv_drain_all() API to wait for requests
across all BlockDriverStates to complete. As a bonus we perform checks
after qemu_aio_wait() to ensure that requests really have finished.
Debugging a reentrant request deadlock was fun but in the future we need
a quick and obvious way of detecting such bugs. Add an assert that
checks we are not about to deadlock when waiting for another request.
Cases beyond the end of the disk image are only implemented for block
drivers that do not provide .bdrv_co_is_allocated(). It's worth making
these cases generic so that block drivers that do implement
.bdrv_co_is_allocated() also get them for free.
Stefan Hajnoczi [Wed, 23 Nov 2011 15:00:04 +0000 (15:00 +0000)]
cow: use bdrv_co_is_allocated()
Now that bdrv_co_is_allocated() is available we can use it instead of
the synchronous bdrv_is_allocated() interface. This is a follow-up that
Kevin Wolf <[email protected]> pointed out after applying the series that
introduces bdrv_co_is_allocated().
It is safe to make cow_read() a coroutine_fn because its only caller is
a coroutine_fn.
Stefan Hajnoczi [Thu, 17 Nov 2011 13:40:32 +0000 (13:40 +0000)]
block: add -drive copy-on-read=on|off
This patch adds the -drive copy-on-read=on|off command-line option:
copy-on-read=on|off
copy-on-read is "on" or "off" and enables whether to copy read backing
file sectors into the image file. Copy-on-read avoids accessing the
same backing file sectors repeatedly and is useful when the backing
file is over a slow network. By default copy-on-read is off.
Stefan Hajnoczi [Wed, 23 Nov 2011 11:47:56 +0000 (11:47 +0000)]
block: request overlap detection
Detect overlapping requests and remember to align to cluster boundaries
if the image format uses them. This assumes that allocating I/O is
performed in cluster granularity - which is true for qcow2, qed, etc.
Stefan Hajnoczi [Thu, 17 Nov 2011 13:40:29 +0000 (13:40 +0000)]
block: wait for overlapping requests
When copy-on-read is enabled it is necessary to wait for overlapping
requests before issuing new requests. This prevents races between the
copy-on-read and a write request.
Stefan Hajnoczi [Mon, 28 Nov 2011 16:08:47 +0000 (16:08 +0000)]
block: add interface to toggle copy-on-read
The bdrv_enable_copy_on_read()/bdrv_disable_copy_on_read() functions can
be used to programmatically enable or disable copy-on-read for a block
device. Later patches add the actual copy-on-read logic.
Stefan Hajnoczi [Thu, 17 Nov 2011 13:40:27 +0000 (13:40 +0000)]
block: add request tracking
The block layer does not know about pending requests. This information
is necessary for copy-on-read since overlapping requests must be
serialized to prevent races that corrupt the image.
The BlockDriverState gets a new tracked_request list field which
contains all pending requests. Each request is a BdrvTrackedRequest
record with sector_num, nb_sectors, and is_write fields.
Note that request tracking is always enabled but hopefully this extra
work is so small that it doesn't justify adding an enable/disable flag.
Stefan Hajnoczi [Thu, 17 Nov 2011 13:40:26 +0000 (13:40 +0000)]
coroutine: add qemu_co_queue_restart_all()
It's common to wake up all waiting coroutines. Introduce the
qemu_co_queue_restart_all() function to do this instead of looping over
qemu_co_queue_next() in every caller.
Since ALIGN_UP() is a common macro name use the QEMU_* namespace prefix.
Hopefully this will protect us from included headers that leak something
with a similar name.