summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-07-29vhost-user: check vhost_user_{read,write}() return valueMarc-André Lureau1-16/+34
The vhost-user code is quite inconsistent with error handling. Instead of ignoring some return values of read/write and silently going on with invalid state (invalid read for example), break the code flow when the error happened. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: check qemu_chr_fe_set_msgfds() return valueMarc-André Lureau1-1/+3
Check qemu_chr_fe_set_msgfds() for errors, to make sure the message to be sent is correct. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: call set_msgfds unconditionallyMarc-André Lureau1-3/+1
It is fine to call set_msgfds() with 0 fd, and ensures any previous fd array is cleared. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29qemu-char: fix qemu_chr_fe_set_msgfds() crash when disconnectedMarc-André Lureau1-4/+6
Calling qemu_chr_fe_set_msgfds() on unconnected socket leads to crash since s->ioc is NULL in this case. Return an error earlier instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: use error_report() instead of fprintf(stderr,...)Marc-André Lureau1-10/+9
Let's use qemu proper error reporting API, this ensures the error is reported at the right place (stderr or monitor), with a conventional format. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: add missing VHOST_OPS_DEBUGMarc-André Lureau1-2/+15
Add missing VHOST_OPS_DEBUG() logs, for completeness. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: do not assert() on vhost_ops failureMarc-André Lureau1-17/+32
Calling a vhost operation may fail, for example with disconnected vhost-user backend, but qemu shouldn't abort in this case. Log an error instead, except on error and cleanup code paths where it can be mostly ignored. Let's use a VHOST_OPS_DEBUG macro to easily disable those messages once disconnected backend stabilizes. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: fix calling vhost_dev_cleanup() after vhost_dev_init()Marc-André Lureau1-11/+6
vhost_net_init() calls vhost_dev_init() and in case of failure, calls vhost_dev_cleanup() directly. However, the structure is already partially cleaned on error. Calling vhost_dev_cleanup() again will call vhost_virtqueue_cleanup() on already clean queues, and causing potential double-close. Instead, adjust dev->nvqs and simplify vhost_dev_init() code to not call vhost_virtqueue_cleanup() but vhost_dev_cleanup() instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-net: always call vhost_dev_cleanup() on failureMarc-André Lureau1-3/+3
vhost_dev_init(), calling vhost backend initialization, should be cleaned up after failure too. Call vhost_dev_cleanup() in all failure cases. First, it needs to zero-alloc the struct to avoid the initial garbage. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: make vhost_dev_cleanup() idempotentMarc-André Lureau1-1/+6
It is called on multiple code path, so make it safe to call several times (note: I don't remember a reproducer here, but a function called 'cleanup' should probably be idempotent in my book) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: fix cleanup on not fully initialized deviceMarc-André Lureau1-3/+6
If vhost_dev_init() failed, caller may still call vhost_dev_cleanup() later. However, vhost_dev_cleanup() tries to remove the device from the list even if it wasn't yet added, which may lead to crashes. Similarly for the memory listener. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: assert the log was cleaned upMarc-André Lureau1-0/+1
Make sure the log was released on cleanup, or it will leak (the alternative is to call vhost_log_put() unconditionally, but it may hide some dev state issues). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: make vhost_log_put() idempotentMarc-André Lureau1-5/+2
Although not strictly required, it is nice to have vhost_log_put() safely callable multiple times. Clear dev->log* when calling vhost_log_put() to make the function idempotent. This also simplifies a bit the caller work. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: don't assume opaque is a fd, use backend cleanupMarc-André Lureau1-9/+7
vhost-dev opaque isn't necessarily an fd, it can be a chardev when using vhost-user. Goto fail, so vhost_backend_cleanup() is called to handle backend cleanup appropriately. vhost_set_backend_type() should never fail, use an assert(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: disconnect on HUPMarc-André Lureau1-5/+1
In some cases, qemu_chr_fe_read_all() on HUP event doesn't raise CHR_EVENT_CLOSED because the read/recv function returns -1 on disconnected peers (for example with tch_chr_recv, an ECONNRESET errno overwritten as EIO). It is simpler to explicitely disconnect on HUP, rising CHR_EVENT_CLOSED if it wasn't disconnected already. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: minor simplificationMarc-André Lureau1-2/+1
Shorten the code and make it more clear by using the specialized function g_str_has_prefix(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29misc: indentationMarc-André Lureau1-1/+1
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29virtio: check vring descriptor buffer lengthPrasad J Pandit1-0/+5
virtio back end uses set of buffers to facilitate I/O operations. An infinite loop unfolds in virtqueue_pop() if a buffer was of zero size. Add check to avoid it. Reported-by: Li Qiang <liqiang6-s@360.cn> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-07-29hw/virtio-pci: fix virtio behaviourMarcel Apfelbaum5-26/+45
Enable transitional virtio devices by default. Enable virtio-1.0 for devices plugged into PCIe ports (Root ports or Downstream ports). Using the virtio-1 mode will remove the limitation of the number of devices that can be attached to a machine by removing the need for the IO BAR. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-07-29apb: convert init to realizeWei Jiangang1-3/+2
Convert a device model where initialization obviously can't fail, make it implement realize() rather than init(). Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2016-07-29hw/pci-bridge: Convert pxb initialization functions to ErrorWei Jiangang1-27/+25
Firstly, convert pxb_dev_init_common() to Error and rename it to pxb_dev_realize_common(). Actually, pxb_register_bus() is converted as well. And then, convert pxb_dev_initfn() and pxb_pcie_dev_initfn() to Error, rename them to pxb_dev_realize() and pxb_pcie_dev_realize() respectively. Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29hw/apci: handle 64-bit MMIO regions correctlyMarcel Apfelbaum1-9/+45
In build_crs(), the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately. This fixes 64-bit BARs behind PXBs. Reported-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29acpi: refactor pxb crs computationMarcel Apfelbaum1-31/+50
Instead of always passing both IO and MEM ranges when computing CRS ranges, define a new CrsRangeSet structure that include them both. This is done before introducing a third type of range, 64-bit MEM, so it will be easier to pass them all around. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29hw/acpi: fix a DSDT table issue when a pxb is present.Marcel Apfelbaum1-0/+4
PXBs do not support hotplug so they don't have a PCNT function. Since the PXB's PCI root-bus is a child bus of bus 0, the build_dsdt code will add a call to the corresponding PCNT function. Fix this by skipping the PCNT call for the above case. While at it skip also PCIe child buses. Reported-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29hw/pxb: declare pxb devices as not hot-pluggableMarcel Apfelbaum1-0/+2
Prevent future issues when hotplug will work for devices attached to pxbs. Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29hw/pcie-root-port: Fix PCIe root port initializationMarcel Apfelbaum1-0/+1
Specify the root port interrupt pin as part of the init process for cases when msi/msix are not enabled. Fixes "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative" warning from clang's sanitizer. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29pcie: fix link active status bit migrationMichael S. Tsirkin4-6/+27
We changed link status register in pci express endpoint capability over time. Specifically, commit b2101eae63ea57b571cee4a9075a4287d24ba4a4 ("pcie: Set the "link active" in the link status register") set data link layer link active bit in this register without adding compatibility to old machine types. When migrating from qemu 2.3 and older this affects xhci devices which under machine type 2.0 and older have a pci express endpoint capability even if they are on a pci bus. Add compatibility flags to make this bit value match what it was under 2.3. Additionally, to avoid breaking migration from qemu 2.3 and up, suppress checking link status during migration: this seems sane since hardware can change link status at any time. https://bugzilla.redhat.com/show_bug.cgi?id=1352860 Reported-by: Gerd Hoffmann <kraxel@redhat.com> Fixes: b2101eae63ea57b571cee4a9075a4287d24ba4a4 ("pcie: Set the "link active" in the link status register") Cc: qemu-stable@nongnu.org Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-28target-mips: fix EntryHi.EHINV being cleared on TLB exceptionLeon Alrae1-0/+1
While implementing TLB invalidation feature we forgot to modify part of code responsible for updating EntryHi during TLB exception. Consequently EntryHi.EHINV is unexpectedly cleared on the exception. Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-07-28hw/mips_malta: Fix YAMON API print routinePaul Burton1-1/+1
The print routine provided as part of the in-built bootloader had a bug in that it attempted to use a jump instruction as part of a loop, but the target has its upper bits zeroed leading to control flow transferring to 0xb0000814 rather than the intended 0xbfc00814. Fix this by using a branch instruction instead, which seems more fit for purpose. A simple way to test this is to build a Linux kernel with EVA enabled & attempt to boot it in QEMU. It will attempt to print a message indicating the configuration mismatch but QEMU would previously incorrectly jump & wind up printing a continuous stream of the letter E. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Cc: Leon Alrae <leon.alrae@imgtec.com> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-07-27Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into ↵Peter Maydell12-97/+47
staging x86 and machine queue, 2016-07-27 Highlights: * Fixes to allow CPU hotplug/unplug in any order; * Exit QEMU on invalid global properties. # gpg: Signature made Wed 27 Jul 2016 15:28:53 BST # gpg: using RSA key 0x2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/x86-pull-request: vl: exit if a bad property value is passed to -global qdev: ignore GlobalProperty.errp for hotplugged devices machine: Add comment to abort path in machine_set_kernel_irqchip Revert "pc: Enforce adding CPUs contiguously and removing them in opposite order" pc: Init CPUState->cpu_index with index in possible_cpus[] qdev: Fix object reference leak in case device.realize() fails exec: Set cpu_index only if it's not been explictly set exec: Don't use cpu_index to detect if cpu_exec_init()'s been called exec: Reduce CONFIG_USER_ONLY ifdeffenery Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-27Merge remote-tracking branch ↵Peter Maydell1-0/+5
'remotes/stefanha/tags/CVE-2016-5403-virtio-unbounded-allocation-pull-request' into staging # gpg: Signature made Wed 27 Jul 2016 16:13:02 BST # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/CVE-2016-5403-virtio-unbounded-allocation-pull-request: virtio: error out if guest exceeds virtqueue size Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-27Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into stagingPeter Maydell2-5/+11
# gpg: Signature made Tue 26 Jul 2016 21:51:38 BST # gpg: using RSA key 0xBDBE7B27C0DE3057 # gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>" # gpg: aka "Jeffrey Cody <jeff@codyprime.org>" # gpg: aka "Jeffrey Cody <codyprime@gmail.com>" # Primary key fingerprint: 9957 4B4D 3474 90E7 9D98 D624 BDBE 7B27 C0DE 3057 * remotes/cody/tags/block-pull-request: mirror: double performance of the bulk stage if the disc is full block/gluster: fix doc in the qapi schema and member name Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-27vl: exit if a bad property value is passed to -globalGreg Kurz1-0/+1
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus): qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo: Invalid compatibility mode "foo" ... and QEMU continues execution, ignoring the property. With this patch, we get a single line: qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo: Invalid compatibility mode "foo" ... and QEMU exits. The previous behavior is kept for hotplugged devices since we don't want QEMU to exit when doing device_add. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-27qdev: ignore GlobalProperty.errp for hotplugged devicesGreg Kurz2-3/+5
This patch ensures QEMU won't terminate while hotplugging a device if the global property cannot be set and errp points to error_fatal or error_abort. While here, it also fixes indentation of the typename argument. Suggested-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-27machine: Add comment to abort path in machine_set_kernel_irqchipGreg Kurz1-0/+3
We're not supposed to abort when the user passes a bogus value. Since the checking is done in visit_type_OnOffSplit(), the call to abort() is legitimate. Let's add a comment to make it explicit. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-27virtio: error out if guest exceeds virtqueue sizeStefan Hajnoczi1-0/+5
A broken or malicious guest can submit more requests than the virtqueue size permits, causing unbounded memory allocation in QEMU. The guest can submit requests without bothering to wait for completion and is therefore not bound by virtqueue size. This requires reusing vring descriptors in more than one request, which is not allowed by the VIRTIO 1.0 specification. In "3.2.1 Supplying Buffers to The Device", the VIRTIO 1.0 specification says: 1. The driver places the buffer into free descriptor(s) in the descriptor table, chaining as necessary and Note that the above code does not take precautions against the available ring buffer wrapping around: this is not possible since the ring buffer is the same size as the descriptor table, so step (1) will prevent such a condition. This implies that placing more buffers into the virtqueue than the descriptor table size is not allowed. QEMU is missing the check to prevent this case. Processing a request allocates a VirtQueueElement leading to unbounded memory allocation controlled by the guest. Exit with an error if the guest provides more requests than the virtqueue size permits. This bounds memory allocation and makes the buggy guest visible to the user. This patch fixes CVE-2016-5403 and was reported by Zhenhao Hong from 360 Marvel Team, China. Reported-by: Zhenhao Hong <hongzhenhao@360.cn> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-07-26mirror: double performance of the bulk stage if the disc is fullVladimir Sementsov-Ogievskiy1-2/+8
Mirror can do up to 16 in-flight requests, but actually on full copy (the whole source disk is non-zero) in-flight is always 1. This happens as the request is not limited in size: the data occupies maximum available capacity of s->buf. The patch limits the size of the request to some artificial constant (1 Mb here), which is not that big or small. This effectively enables back parallelism in mirror code as it was designed. The result is important: the time to migrate 10 Gb disk is reduced from ~350 sec to 170 sec. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-id: 1468516741-82174-1-git-send-email-vsementsov@virtuozzo.com CC: Stefan Hajnoczi <stefanha@redhat.com> CC: Fam Zheng <famz@redhat.com> CC: Kevin Wolf <kwolf@redhat.com> CC: Max Reitz <mreitz@redhat.com> CC: Jeff Cody <jcody@redhat.com> CC: Eric Blake <eblake@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com>
2016-07-26block/gluster: fix doc in the qapi schema and member namePrasanna Kumar Kalever1-3/+3
1. qapi @BlockdevOptionsGluster schema member name s/debug_level/debug-level/ 2. rearrange the versioning 3. s/server description/servers description/ Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-Id: <1469198048-8535-1-git-send-email-prasanna.kalever@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com>
2016-07-26Revert "pc: Enforce adding CPUs contiguously and removing them in opposite ↵Igor Mammedov1-34/+0
order" This reverts commit 4da7faaeb0c7dd3f7f233165d336c878f78fd1eb. Since commit: pc: init CPUState->cpu_index with index in possible_cpus[] cpu_index is stable regardless of the order cpus were created and QEMU instance stays migratable always so limitation added by 4da7faaeb could be safely removed. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26pc: Init CPUState->cpu_index with index in possible_cpus[]Igor Mammedov1-0/+4
It will enshure that cpu_index for a given cpu stays the same regardless of the order cpus has been created/deleted. No compat code is needed as for initial cpus index in possible_cpus[] matches cpu_index that's been auto-allocated in cpu_exec_init(). Tha same applies for hotplug with cpu-add command if cpus are added sequentially in increasing order as 'id' matches cpu_index. If cpu-add had been used for creating out-of-order cpus, that created unmigratable instance since it were not possible to start target with the same cpu_index using old way of migrating instance with hotplugged cpus: * source QEMU with CLI (-smp 1,maxcpus=3 and cpu-add id=2) following set of cpu_index is allocated [0, 1] with apics set [0, 2] respectivelly * target QEMU is started with CLI -smp 2,maxcpus=3 resulting in set of cpu_index [0, 1] but with set of apics [0, 1] wich doesn't match source. So we don't need compat code in this case as it's never worked and newelly added device_add support would use stable cpu_index set by machine to begin with, so it won't have above limitation and source QEMU could be migrated to destination regardless of the order cpus were created. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26qdev: Fix object reference leak in case device.realize() failsIgor Mammedov1-1/+7
If device doesn't have parent assined before its realize is called, device_set_realized() will implicitly set parent to '/machine/unattached'. However device_set_realized() may fail after that point at several other points leaving not realized object dangling in '/machine/unattached' and as result caller of obj = object_new() obj->ref == 1 object_property_set_bool(obj,..., true, "realized",...) obj->ref == 2 if (fail) object_unref(obj); obj->ref == 1 will get object leak instead of expected object destruction. Fix it by making device_set_realized() to cleanup after itself in case of failure. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26exec: Set cpu_index only if it's not been explictly setIgor Mammedov3-39/+9
It keeps the legacy behavior for all users that doesn't care about stable cpu_index value, but would allow boards that would support device_add/device_del to set stable cpu_index that won't depend on order in which cpus are created/destroyed. While at that simplify cpu_get_free_index() as cpu_index generated by USER_ONLY and softmmu variants is the same since none of the users support cpu-remove so far, except of not yet released spapr/x86 device_add/delr, which will be altered by follow up patches to set stable cpu_index manually. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26exec: Don't use cpu_index to detect if cpu_exec_init()'s been calledIgor Mammedov1-2/+3
Instead use QTAIL's tqe_prev field to detect if cpu's been placed in list by cpu_exec_init() which is always set if QTAIL element is in list. Fixes SIGSEGV on failure path in case cpu_index is assigned by board and cpu.relalize() fails before cpu_exec_init() is called. In follow up patches, cpu_index will be assigned by boards that support cpu hot(un)plug and need stable cpu_index that doesn't depend on order cpus are created/removed. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reported-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26exec: Reduce CONFIG_USER_ONLY ifdeffeneryIgor Mammedov4-18/+15
Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-07-26Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2016-07-26' ↵Peter Maydell13-37/+290
into staging Block patches for 2.7.0-rc1 # gpg: Signature made Tue 26 Jul 2016 18:11:36 BST # gpg: using RSA key 0x3BB14202E838ACAD # gpg: Good signature from "Max Reitz <mreitz@redhat.com>" # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 # Subkey fingerprint: 58B3 81CE 2DC8 9CF9 9730 EE64 3BB1 4202 E838 ACAD * remotes/maxreitz/tags/pull-block-2016-07-26: iotest: fix python based IO tests block: export LUKS specific data to qemu-img info crypto: add support for querying parameters for block encryption AioContext: correct comments qcow2: do not allocate extra memory Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-26iotest: fix python based IO testsDaniel P. Berrange3-33/+42
The previous commit refactoring iotests.py: commit 66613974468fb6e1609fb3eabf55981b1ee436cf Author: Daniel P. Berrange <berrange@redhat.com> Date: Wed Jul 20 14:23:10 2016 +0100 scripts: refactor the VM class in iotests for reuse was not properly tested and included a number of broken bits. - The 'event_match' method was not moved into qemu.py - The 'self._args' list parameter in QEMUMachine needs to be copied otherwise modifications will affect the global 'qemu_opts' variable in iotests.py - The QEMUQtestMachine class methods had inverted parameter order for the super() calls - The QEMUQtestMachine class forgot to add '-machine accel=qtest' - The QEMUQtestMachine class constructor needs to set a default 'name' value before using it as it may be None - The QEMUQtestMachine class constructor needs to use named parameters when calling the super constructor as it is leaving out some positional parameters. - The 'qemu_prog' variable should be a string not a list in iotests.py - The VM classs constructor needs to use named parameters when calling the super constructor as it is leaving out some positional parameters. - The path to the socket-scm-helper needs to be passed into the QEMUMachine class Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1469549767-27249-1-git-send-email-berrange@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
2016-07-26block: export LUKS specific data to qemu-img infoDaniel P. Berrange2-1/+54
The qemu-img info command has the ability to expose format specific metadata about volumes. Wire up this facility for the LUKS driver to report on cipher configuration and key slot usage. $ qemu-img info ~/VirtualMachines/demo.luks image: /home/berrange/VirtualMachines/demo.luks file format: luks virtual size: 98M (102760448 bytes) disk size: 100M encrypted: yes Format specific information: ivgen alg: plain64 hash alg: sha1 cipher alg: aes-128 uuid: 6ddee74b-3a22-408c-8909-6789d4fa2594 cipher mode: xts slots: [0]: active: true iters: 572706 key offset: 4096 stripes: 4000 [1]: active: false key offset: 135168 [2]: active: false key offset: 266240 [3]: active: false key offset: 397312 [4]: active: false key offset: 528384 [5]: active: false key offset: 659456 [6]: active: false key offset: 790528 [7]: active: false key offset: 921600 payload offset: 2097152 master key iters: 142375 One somewhat undesirable artifact is that the data fields are printed out in (apparently) random order. This will be addressed later by changing the way the block layer pretty-prints the image specific data. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1469192015-16487-3-git-send-email-berrange@redhat.com Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2016-07-26crypto: add support for querying parameters for block encryptionDaniel P. Berrange5-0/+191
When creating new block encryption volumes, we accept a list of parameters to control the formatting process. It is useful to be able to query what those parameters were for existing block devices. Add a qcrypto_block_get_info() method which returns a QCryptoBlockInfo instance to report this data. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1469192015-16487-2-git-send-email-berrange@redhat.com Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2016-07-26AioContext: correct commentsCao jin1-1/+1
Correct comments of field notify_me Cc: Kevin Wolf <kwolf@redhat.com> Cc: Max Reitz <mreitz@redhat.com> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> Message-id: 1468575858-22975-1-git-send-email-caoj.fnst@cn.fujitsu.com Signed-off-by: Max Reitz <mreitz@redhat.com>
2016-07-26qcow2: do not allocate extra memoryVladimir Sementsov-Ogievskiy2-2/+2
There are no needs to allocate more than one cluster, as we set avail_out for deflate to one cluster. Zlib docs (http://www.zlib.net/manual.html) says: "deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full." So, deflate will not write more than avail_out to output buffer. If there is not enough space in output buffer for compressed data (it may be larger than input data) deflate just returns Z_OK. (if all data is compressed and written to output buffer deflate returns Z_STREAM_END). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-id: 1468515565-81313-1-git-send-email-vsementsov@virtuozzo.com Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>