summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2015-01-14atomic: fix position of volatile qualifierPaolo Bonzini1-2/+2
What needs to be volatile is not the pointer, but the pointed-to value! Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 2cbcfb281afa041a41f6e4c4da0f5c9314084604) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2015-01-07block: Make essential BlockDriver objects publicMax Reitz1-0/+8
There are some block drivers which are essential to QEMU and may not be removed: These are raw, file and qcow2 (as the default non-raw format). Make their BlockDriver objects public so they can be directly referenced throughout the block layer without needing to call bdrv_find_format() and having to deal with an error at runtime, while the real problem occurred during linking (where raw, file or qcow2 were not linked into qemu). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit 5f535a941e52229d81e55603eb69b2bd449b937a) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2015-01-07exec: Handle multipage ranges in invalidate_and_set_dirty()Peter Maydell1-0/+25
The code in invalidate_and_set_dirty() needs to handle addr/length combinations which cross guest physical page boundaries. This can happen, for example, when disk I/O reads large blocks into guest RAM which previously held code that we have cached translations for. Unfortunately we were only checking the clean/dirty status of the first page in the range, and then were calling a tb_invalidate function which only handles ranges that don't cross page boundaries. Fix the function to deal with multipage ranges. The symptoms of this bug were that guest code would misbehave (eg segfault), in particular after a guest reboot but potentially any time the guest reused a page of its physical RAM for new code. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1416167061-13203-1-git-send-email-peter.maydell@linaro.org (cherry picked from commit f874bf905ff2f8dcc17acbfc61e49a92a6f4d04b) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2015-01-06hw/core/loader: implement address translation in uimage loaderMax Filippov1-1/+3
Such address translation is needed when load address recorded in uImage is a virtual address. When the actual load address is requested, return untranslated address: user that needs the translated address can always apply translation function to it and those that need it untranslated don't need to do the inverse translation. Add translation function pointer and its parameter to uimage_load prototype. Update all existing users. No user-visible functional changes. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Alexander Graf <agraf@suse.de> (cherry picked from commit 25bda50a0c7241dcb247483af2b7f961632020cc) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2015-01-04qapi: add visit_start_union and visit_end_unionMichael Roth2-0/+4
In some cases an input visitor might bail out on filling out a struct for various reasons, such as missing fields when running in strict mode. In the case of a QAPI Union type, this may lead to cases where the .kind field which encodes the union type is uninitialized. Subsequently, other visitors, such as the dealloc visitor, may use this .kind value as if it were initialized, leading to assumptions about the union type which in this case may lead to segfaults. For example, freeing an integer value. However, we can generally rely on the fact that the always-present .data void * field that we generate for these union types will always be NULL in cases where .kind is uninitialized (at least, there shouldn't be a reason where we'd do this purposefully). So pass this information on to Visitor implementation via these optional start_union/end_union interfaces so this information can be used to guard against the situation above. We will make use of this information in a subsequent patch for the dealloc visitor. Cc: qemu-stable@nongnu.org Reported-by: Fam Zheng <famz@redhat.com> Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> (cherry picked from commit cee2dedb85b97e4976c83bea84064c3921b8b7ac) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-12-24spapr_pci: map the MSI window in each PHBGreg Kurz2-3/+1
On sPAPR, virtio devices are connected to the PCI bus and use MSI-X. Commit cc943c36faa192cd4b32af8fe5edb31894017d35 has modified MSI-X so that writes are made using the bus master address space and follow the IOMMU path. Unfortunately, the IOMMU address space address space does not have an MSI window: the notification is silently dropped in unassigned_mem_write instead of reaching the guest... The most visible effect is that all virtio devices are non-functional on sPAPR since then. :( This patch does the following: 1) map the MSI window into the IOMMU address space for each PHB - since each PHB instantiates its own IOMMU address space, we can safely map the window at a fixed address (SPAPR_PCI_MSI_WINDOW) - no real need to keep the MSI window setup in a separate function, the spapr_pci_msi_init() code moves to spapr_phb_realize(). 2) kill the global MSI window as it is not needed in the end Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de> (cherry picked from commit 8c46f7ec85a4dd9663489b2fa2b425cd7b3653e1) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-12-24Introduce cpu_clean_all_dirtyMarcelo Tosatti2-0/+9
Introduce cpu_clean_all_dirty, to force subsequent cpu_synchronize_all_states to read in-kernel register state. Cc: qemu-stable@nongnu.org Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit de9d61e83d43be9069e6646fa9d57a3f47779d28) Conflicts: kvm-all.c *removed context dependency on kvm_cpu_synchronize_post_init Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-12-24xhci PCIe endpoint migration compatibility fixDr. David Alan Gilbert1-0/+5
Add back the PCIe config capabilities on XHCI cards in non-PCIe slots, but only for machine types before 2.1. This fixes a migration incompatibility in the XHCI PCI devices caused by: 058fdcf52cdbf57b67e7 - xhci: add endpoint cap on express bus only Note that in fixing it for compatibility with older QEMUs, it breaks compatibility with existing QEMU 2.1's on older machine types. The status before this patch was (if it used an XHCI adapter): machine type | source qemu any pre-2.1 - FAIL any 2.1... - PASS With this patch: machine type | source qemu any pre-2.1 - PASS pre-2.1 2.1... - FAIL 2.1 2.1... - PASS A test to trigger it is to add '-device nec-usb-xhci,id=xhci,addr=0x12' to the command line. Cc: qemu-stable@nongnu.org Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> (cherry picked from commit e6043e92c2812a56b8f6cf35d5512067c746ce21) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-09-23Revert "spapr_pci: map the MSI window in each PHB"Greg Kurz2-1/+3
This patch is predicated on cc943c, which was dropped from stable tree for other reasons. This reverts commit 0824ca6bd126b97fac18d12d514823463f415bec. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-09-10spapr_pci: map the MSI window in each PHBGreg Kurz2-3/+1
On sPAPR, virtio devices are connected to the PCI bus and use MSI-X. Commit cc943c36faa192cd4b32af8fe5edb31894017d35 has modified MSI-X so that writes are made using the bus master address space and follow the IOMMU path. Unfortunately, the IOMMU address space address space does not have an MSI window: the notification is silently dropped in unassigned_mem_write instead of reaching the guest... The most visible effect is that all virtio devices are non-functional on sPAPR since then. :( This patch does the following: 1) map the MSI window into the IOMMU address space for each PHB - since each PHB instantiates its own IOMMU address space, we can safely map the window at a fixed address (SPAPR_PCI_MSI_WINDOW) - no real need to keep the MSI window setup in a separate function, the spapr_pci_msi_init() code moves to spapr_phb_realize(). 2) kill the global MSI window as it is not needed in the end Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de> (cherry picked from commit 8c46f7ec85a4dd9663489b2fa2b425cd7b3653e1) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-09-08pc: reserve more memory for ACPI for new machine typesMichael S. Tsirkin1-0/+2
commit 868270f23d8db2cce83e4f082fe75e8625a5fbf9 acpi-build: tweak acpi migration limits broke kernel loading with -kernel/-initrd: it doubled the size of ACPI tables but did not reserve enough memory. As a result, issues on boot and halt are observed. Fix this up by doubling reserved memory for new machine types. Cc: qemu-stable@nongnu.org Reported-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> (cherry picked from commit 927766c7d34275ecf586020cc5305e377cc4af10) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-09-08hw:i386: typo fix: MEMORY_HOPTLUG_DEVICE -> MEMORY_HOTPLUG_DEVICEHu Tao1-1/+1
Cc: qemu-stable@nongnu.org Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> (cherry picked from commit 41d2f71376fe401a1fdb7deda023769207511790) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2014-07-28pc: hack for migration compatibility from QEMU 2.0Paolo Bonzini1-0/+1
Changing the ACPI table size causes migration to break, and the memory hotplug work opened our eyes on how horribly we were breaking things in 2.0 already. The ACPI table size is rounded to the next 4k, which one would think gives some headroom. In practice this is not the case, because the user can control the ACPI table size (each CPU adds 97 bytes to the SSDT and 8 to the MADT) and so some "-smp" values will break the 4k boundary and fail to migrate. Similarly, PCI bridges add ~1870 bytes to the SSDT. This patch concerns itself with fixing migration from QEMU 2.0. It computes the payload size of QEMU 2.0 and always uses that one. The previous patch shrunk the ACPI tables enough that the QEMU 2.0 size should always be enough; non-AML tables can change depending on the configuration (especially MADT, SRAT, HPET) but they remain the same between QEMU 2.0 and 2.1, so we only compute our padding based on the sizes of the SSDT and DSDT. Migration from QEMU 1.7 should work for guests that have a number of CPUs other than 12, 13, 14, 54, 55, 56, 97, 98, 139, 140. It was already broken from QEMU 1.7 to QEMU 2.0 in the same way, though. Even with this patch, QEMU 1.7 and 2.0 have two different ideas of "-M pc-i440fx-2.0" when there are PCI bridges. Igor sent a patch to adopt the QEMU 1.7 definition. I think distributions should apply it if they move directly from QEMU 1.7 to 2.1+ without ever packaging version 2.0. Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-07-22Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell1-0/+11
One of the two pending migration fix, and a small KVM patch. # gpg: Signature made Tue 22 Jul 2014 11:49:30 BST using RSA key ID 9B4D86F2 # gpg: Can't check signature: public key not found * remotes/bonzini/tags/for-upstream: kvm-all: Use 'tmpcpu' instead of 'cpu' in sub-looping to avoid 'cpu' be NULL exec: fix migration with devices that use address_space_rw Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-22exec: fix migration with devices that use address_space_rwPaolo Bonzini1-0/+11
Devices that use address_space_rw to write large areas to memory (as opposed to address_space_map/unmap) were broken with respect to migration since fe680d0 (exec: Limit translation limiting in address_space_translate to xen, 2014-05-07). Such devices include IDE CD-ROMs. The reason is that invalidate_and_set_dirty (called by address_space_rw but not address_space_map/unmap) was only setting the dirty bit for the first page in the translation. To fix this, introduce cpu_physical_memory_set_dirty_range_nocode that is the same as cpu_physical_memory_set_dirty_range except it does not muck with the DIRTY_MEMORY_CODE bitmap. This function can be used if the caller invalidates translations with tb_invalidate_phys_page_range. There is another difference between cpu_physical_memory_set_dirty_range and cpu_physical_memory_set_dirty_flag; the former includes a call to xen_modified_memory. This is handled separately in invalidate_and_set_dirty, and is not needed in other callers of cpu_physical_memory_set_dirty_range_nocode, so leave it alone. Just one nit: now that invalidate_and_set_dirty takes care of handling multiple pages, there is no need for address_space_unmap to wrap it in a loop. In fact that loop would now be O(n^2). Reported-by: Dave Gilbert <dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-18Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-07-18' ↵Peter Maydell1-1/+1
into staging trivial patches for 2014-07-18 # gpg: Signature made Fri 18 Jul 2014 15:04:43 BST using RSA key ID A4C3D7DB # gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>" # gpg: aka "Michael Tokarev <mjt@corpit.ru>" # gpg: aka "Michael Tokarev <mjt@debian.org>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5 # Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514 66A7 BEE5 9D74 A4C3 D7DB * remotes/mjt/tags/trivial-patches-2014-07-18: tests: Add missing 'static' attributes (fix warnings from smatch) migration: Add missing 'static' attribute qga: Add missing 'static' attribute hw/usb: Add missing 'static' attribute doc: slirp supports ICMP echo if enabled in Linux qemu-img: Remove redundancy "ret = -1" Fix new typos in comments (found by codespell) slirp: Give error message if hostfwd_add/remove for unrecognized vlan/stack Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-18Fix new typos in comments (found by codespell)Stefan Weil1-1/+1
arbitary -> arbitrary basicly -> basically Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-07-18block: Add Error argument to bdrv_refresh_limits()Kevin Wolf2-2/+2
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-14Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell1-0/+2
Misc 2.1 fixes regarding character/serial devices and SCSI. # gpg: Signature made Mon 14 Jul 2014 16:26:08 BST using RSA key ID 9B4D86F2 # gpg: Can't check signature: public key not found * remotes/bonzini/tags/for-upstream: serial-pci: remove memory regions from BAR before destroying them virtio-scsi: fix with -M pc-i440fx-2.0 serial: change retry logic to avoid concurrency qemu-char: fix deadlock with "-monitor pty" scsi: Report error when lun number is in use Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-14virtio-scsi: fix with -M pc-i440fx-2.0Paolo Bonzini1-0/+2
Right now starting a machine with virtio-scsi and a <= 2.0 machine type fails with: qemu-system-x86_64: -device virtio-scsi-pci: Property .any_layout not found This is because the any_layout bit was actually never set after virtio-scsi was changed to support arbitrary layout for virtio buffers. (This was just a cleanup and a preparation for virtio 1.0; no guest actually checks the bit, but the new request parsing algorithms are tested even with old guest). Reported-by: David Gilbert <dgilbert@redhat.com> Reviewed-by: David Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-14dma-helpers: Fix too long qiovKevin Wolf1-0/+1
If the size of the scatter/gather list isn't a multiple of 512, the number of sectors for the block layer request is rounded down, resulting in a qiov that doesn't match the request length. Truncate the qiov to the new length of the request. This fixes the IDE qtest case /x86_64/ide/bmdma/short_prdt. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2014-07-14AioContext: do not rely on aio_poll(ctx, true) result to end a loopPaolo Bonzini1-3/+3
Currently, whenever aio_poll(ctx, true) has completed all pending work it returns true *and* the next call to aio_poll(ctx, true) will not block. This invariant has its roots in qemu_aio_flush()'s implementation as "while (qemu_aio_wait()) {}". However, qemu_aio_flush() does not exist anymore and bdrv_drain_all() is implemented differently; and this invariant is complicated to maintain and subtly different from the return value of GMainLoop's g_main_context_iteration. All calls to aio_poll(ctx, true) except one are guarded by a while() loop checking for a request to be incomplete, or a BlockDriverState to be idle. The one remaining call (in iothread.c) uses this to delay the aio_context_release/acquire pair until the AioContext is quiescent, however: - we can do the same just by using non-blocking aio_poll, similar to how vl.c invokes main_loop_wait - it is buggy, because it does not ensure that the AioContext is released between an aio_notify and the next time the iothread goes to sleep. This leads to hangs when stopping the dataplane thread. In the end, these semantics are a bad match for the current users of AioContext. So modify that one exception in iothread.c, which also fixes the hangs, as well as the testcase so that it use the same idiom as the actual QEMU code. Reported-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-07-14virtio-blk: embed VirtQueueElement in VirtIOBlockReqStefan Hajnoczi2-2/+6
The memory allocation between hw/block/virtio-blk.c, hw/block/dataplane/virtio-blk.c, and hw/virtio/dataplane/vring.c is messy. Structs are allocated in different files than they are freed in. This is risky and makes memory leaks easier. Embed VirtQueueElement in VirtIOBlockReq to reduce the amount of memory allocation we need to juggle. This also makes vring.c and virtio.c slightly more similar. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-07-14dataplane: do not free VirtQueueElement in vring_push()Stefan Hajnoczi1-1/+0
VirtQueueElement is allocated in vring_pop() so it seems to make sense that vring_push() should free it. Alas, virtio-blk frees VirtQueueElement itself in virtio_blk_free_request(). This patch solves a double-free assertion in glib's g_slice_free(). Rename vring_free_element() to vring_unmap_element() since it no longer frees the VirtQueueElement. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-07-09AioContext: speed up aio_notifyPaolo Bonzini1-0/+9
In many cases, the call to event_notifier_set in aio_notify is unnecessary. In particular, if we are executing aio_dispatch, or if aio_poll is not blocking, we know that we will soon get to the next loop iteration (if necessary); the thread that hosts the AioContext's event loop does not need any nudging. The patch includes a Promela formal model that shows that this really works and does not need any further complication such as generation counts. It needs a memory barrier though. The generation counts are not needed because any change to ctx->dispatching after the memory barrier is okay for aio_notify. If it changes from zero to one, it is the right thing to skip event_notifier_set. If it changes from one to zero, the event_notifier_set is unnecessary but harmless. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-07-09block: drop aio functions that operate on the main AioContextPaolo Bonzini3-18/+5
The main AioContext should be accessed explicitly via qemu_get_aio_context(). Most of the time, using it is not the right thing to do. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-07-07Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into stagingPeter Maydell4-6/+0
pc,vhost,virtio fixes, test Bugfixes all over the place. There's a non bugfix here: re-enabling the vhost-user test, though the patch just brings back functionality that I disabled earlier to fix mingw build failures. This is now sorted, and keeping the unit test enabled seems important since the feature relies on an external server to work, so isn't easy to test. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Sun 06 Jul 2014 11:01:35 BST using RSA key ID D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" * remotes/mst/tags/for_upstream: qemu-char: add chr_add_watch support in mux chardev virtio-pci: fix MSI memory region use after free qdev: Fix crash when using non-device class name on -global qdev: Don't abort() in case globals can't be set hw/virtio: enable common virtio feature for mmio device acpi: fix typo in memory hotplug MMIO region name pci: assign devfn to pci_dev before calling pci_device_iommu_address_space() Handle G_IO_HUP in tcp_chr_read for tcp chardev virtio: move common virtio properties to bus class device pc-dimm: error out if memory hotplug is not enabled numa: check for busy memory backend qtest: enable vhost-user-test Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-07Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ↵Peter Maydell2-0/+9
staging Block pull request # gpg: Signature made Mon 07 Jul 2014 13:27:20 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: qmp: show QOM properties in device-list-properties dataplane: submit I/O as a batch linux-aio: implement io plug, unplug and flush io queue block: block: introduce APIs for submitting IO as a batch ahci: map memory via device's address space instead of address_space_memory raw-posix: Fix raw_getlength() to always return -errno on error qemu-iotests: Disable Quorum testing in 041 when Quorum is not builtin ahci.c: mask unused flags when reading size PRDT DBC MAINTAINERS: add Stefan Hajnoczi to IDE maintainers mirror: Fix qiov size for short requests Fix nocow typos in manpage Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-07xen_backend: introduce xenstore_read_uint64 and xenstore_read_fe_uint64Stefano Stabellini1-0/+2
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-07block: block: introduce APIs for submitting IO as a batchMing Lei2-0/+9
This patch introduces three APIs so that following patches can support queuing I/O requests and submitting them as a batch for improving I/O performance. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-06Handle G_IO_HUP in tcp_chr_read for tcp chardevKirill Batuzov1-1/+0
Since commit cdaa86a54b232572bba594bf87a7416e527e460c ("Add G_IO_HUP handler for socket chardev") GLib limitation results in a bug on Windows host. Steps to reproduce: Start qemu: qemu-system-i386 -qmp tcp:127.0.0.1:4444:server:nowait Connect with telnet: telnet 127.0.0.1 4444 Try sending some data from telnet. Expected result: answers from QEMU. Observed result: no answers (actually tcp_chr_read is not called at all). Due to GLib limitations it is not possible to create several watches on one channel on Windows hosts. See bug #338943 in GNOME bugzilla for details: https://bugzilla.gnome.org/show_bug.cgi?id=338943 This reimplements commit cdaa86a54b232572bba594bf87a7416e527e460c ("Add G_IO_HUP handler for socket chardev") using a single watch: Handle G_IO_HUP in tcp_chr_read instead. It is already watched by a corresponding watch. Remove the second watch with its handler. Cc: Antonios Motakis <a.motakis@virtualopensystems.com> Cc: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru> Signed-off-by: Nikita Belov <zodiac@ispras.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-07-06virtio: move common virtio properties to bus class deviceMing Lei3-5/+0
The two common virtio features can be defined per bus, so move all into bus class device to make code more clean. As discussed with cornelia, s390-virtio-blk doesn't support the two features at all, so keep s390-virtio as it. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> #for s390 ccw Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ming Lei <ming.lei@canonical.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> MST: rebase and resolve conflicts
2014-07-01Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ↵Peter Maydell4-24/+8
staging Block pull request # gpg: Signature made Tue 01 Jul 2014 09:47:15 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: (23 commits) block: add backing-file option to block-stream block: extend block-commit to accept a string for the backing file block: add helper function to determine if a BDS is in a chain block: add QAPI command to allow live backing file change qapi: Change back sector-count to sectors-count in quorum QAPI events. block/cow: Avoid use of uninitialized cow_bs in error path block: simplify bdrv_find_base() and bdrv_find_overlay() block: make 'top' argument to block-commit optional iotests: Add more tests to quick group iotests: Add qemu tests to quick group iotests: Simplify qemu-iotests-quick.sh qemu-img create: add 'nocow' option virtio-blk: remove need for explicit x-data-plane=on option qdev: drop iothread property type virtio-blk: replace x-iothread with iothread link property virtio-blk: move qdev properties into virtio-blk.c virtio: fix virtio-blk child refcount in transports virtio-blk: drop virtio_blk_set_conf() virtio-blk: use aliases instead of duplicate qdev properties qdev: add qdev_alias_all_properties() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-01Merge remote-tracking branch 'remotes/bonzini/memory' into stagingPeter Maydell3-7/+57
* remotes/bonzini/memory: qdev: correctly send DEVICE_DELETED for recursively-deleted devices memory: do not give a name to the internal exec.c regions memory: MemoryRegion: Add size property memory: MemoryRegion: Add may-overlap and priority props memory: MemoryRegion: Add container and addr props memory: MemoryRegion: replace owner field with QOM parent memory: MemoryRegion: QOMify memory: MemoryRegion: use /machine as default owner libqtest: escape strings in QMP commands, fix leak qom: object: Ignore refs/unrefs of NULL qom: object: remove parent pointer when unparenting mc146818rtc: add "rtc-time" link to "/machine/rtc" qom: allow creating an alias of a child<> property qom: add a generic mechanism to resolve paths qom: add object_property_add_alias() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-07-01block: extend block-commit to accept a string for the backing fileJeff Cody2-2/+4
On some image chains, QEMU may not always be able to resolve the filenames properly, when updating the backing file of an image after a block commit. For instance, certain relative pathnames may fail, or drives may have been specified originally by file descriptor (e.g. /dev/fd/???), or a relative protocol pathname may have been used. In these instances, QEMU may lack the information to be able to make the correct choice, but the user or management layer most likely does have that knowledge. With this extension to the block-commit api, the user is able to change the backing file of the overlay image as part of the block-commit operation. This allows the change to be 'safe', in the sense that if the attempt to write the overlay image metadata fails, then the block-commit operation returns failure, without disrupting the guest. If the commit top is the active layer, then specifying the backing file string will be treated as an error (there is no overlay image to modify in that case). If a backing file string is not specified in the command, the backing file string to use is determined in the same manner as it was previously. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-01block: add helper function to determine if a BDS is in a chainJeff Cody1-0/+1
This is a small helper function, to determine if 'base' is in the chain of BlockDriverState 'top'. It returns true if it is in the chain, and false otherwise. If either argument is NULL, it will also return false. Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-01qdev: correctly send DEVICE_DELETED for recursively-deleted devicesPaolo Bonzini1-0/+1
When a device is unparented (i.e. made completely hidden from management) we want to send a DEVICE_DELETED event only if the device actually was realized. This avoids raising DEVICE_DELETED events when device_add fails. However, this does not work right for recursively-deleted devices: the whole tree is _first_ unrealized, _then_ unparented. Then device_unparent sees realized==false and fails to trigger the event. The solution is simply to move have_realized into the DeviceState struct. If device_add fails, we never set the new field to true and DEVICE_DELETED is not sent. Fixes qemu-iotests testcase 067 (broken by commit 5942a19, though that commit in turn fixed a possible segfault in the same test). Reported-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-01memory: MemoryRegion: Add may-overlap and priority propsPeter Crosthwaite1-1/+1
QOM propertyify the .may-overlap and .priority fields. The setters will re-add the memory as a subregion if needed (i.e. the values change when the memory region is already contained). Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> [Remove setters. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-01memory: MemoryRegion: replace owner field with QOM parentPaolo Bonzini1-1/+0
The two are now the same. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-01memory: MemoryRegion: QOMifyPeter Crosthwaite1-0/+6
QOMify memory regions as an Object. The former init() and destroy() routines become instance_init() and instance_finalize() resp. memory_region_init() is re-implemented to be: object_initialize() + set fields memory_region_destroy() is re-implemented to call unparent(). Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> [Add newly-created MR as child, unparent on destruction. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-01qom: add a generic mechanism to resolve pathsPaolo Bonzini1-5/+29
It may be desirable to have custom link<> properties that do more than just store an object. Even the addition of a "check" function is not enough if setting the link has side effects or if a non-standard reference counting is preferrable. Avoid the assumption that the opaque field of a link<> is a LinkProperty struct, by adding a generic "resolve" callback to ObjectProperty. This fixes aliases of link properties. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-01qemu-img create: add 'nocow' optionChunyan Liu1-0/+1
Add 'nocow' option so that users could have a chance to set NOCOW flag to newly created files. It's useful on btrfs file system to enhance performance. Btrfs has low performance when hosting VM images, even more when the guest in those VM are also using btrfs as file system. One way to mitigate this bad performance is to turn off COW attributes on VM files. Generally, there are two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow, then all newly created files will be NOCOW. b) per file. Add the NOCOW file attribute. It could only be done to empty or new files. This patch tries the second way, according to the option, it could add NOCOW per file. For most block drivers, since the create file step is in raw-posix.c, so we can do setting NOCOW flag ioctl in raw-posix.c only. But there are some exceptions, like block/vpc.c and block/vdi.c, they are creating file by calling qemu_open directly. For them, do the same setting NOCOW flag ioctl work in them separately. [Fixed up 082.out due to the new 'nocow' creation option --Stefan] Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-01qom: add object_property_add_alias()Stefan Hajnoczi1-0/+20
Sometimes an object needs to present a property which is actually on another object, or it needs to provide an alias name for an existing property. Examples: a.foo -> b.foo a.old_name -> a.new_name The new object_property_add_alias() API allows objects to alias a property on the same object or another object. The source and target names can be different. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01qdev: drop iothread property typeStefan Hajnoczi1-3/+0
The iothread property type is no longer used and can be removed. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-07-01virtio-blk: move qdev properties into virtio-blk.cStefan Hajnoczi1-23/+0
There is no need to make DEFINE_VIRTIO_BLK_PROPERTIES() public. Inline it into virtio-blk.c so it cannot be used by mistake from other source files. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01virtio-blk: drop virtio_blk_set_conf()Stefan Hajnoczi1-2/+0
This function is no longer used since parent objects now use child aliases to set the VirtIOBlkConf directly. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01qdev: add qdev_alias_all_properties()Stefan Hajnoczi1-0/+2
The qdev_alias_all_properties() function creates QOM alias properties for each qdev property on a DeviceState. This is useful for parent objects that wish to forward property accesses to their children. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01virtio-blk: move x-data-plane qdev property to virtio-blk.hStefan Hajnoczi1-0/+8
Move the x-data-plane property. Originally it was outside since not every transport may wish to support dataplane. But that makes little sense when we have a dedicated CONFIG_VIRTIO_BLK_DATA_PLANE ifdef already. This move makes it easier to switch to property aliases in the next patch. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01virtio-blk: avoid qdev property definition duplicationStefan Hajnoczi1-8/+6
It becomes unwiedly to duplicate all virtio-blk qdev property definitions due to an #ifdef. The C preprocessor syntax makes it a little hard to resolve this cleanly but we can extract the #ifdef and call a macro it defines later. Avoiding duplication is important since it will only get worse when we move the x-data-plane qdev property here too. We'd have a combinatorial explosion since x-data-plane has its own #ifdef. Suggested-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-07-01irq: Slim conversion of qemu_irq to QOMAndreas Färber1-0/+2
As a prequel to any big Pin refactoring plans, do an in-place conversion of qemu_irq to an Object, so that we can reference it in link<> properties. Signed-off-by: Andreas Färber <afaerber@suse.de> [ PC Changes: * Removed array-alloctor ref counting logic (limit changes just to * single IRQ allocator) * Removed WIP marking from subject line ] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>