summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2014-08-22block: do not directly set total_sectorsPeter Wu1-0/+1
To prepare for expressing block sizes in bytes instead of sector counts, this patch replaces all direct assignments of bs->total_sectors. This converts the expression `bs->total_sectors = X` (where X is sector count) to `bdrv_setlength(bs, BDRV_SECTOR_SIZE * X)`. Expressions such as `bs->total_sectors = Y / 512` are changed to `bdrv_setlength(bs, BDRV_SECTOR_SIZE * (Y / 512))` to account for the floor division change. If these conditions can be relaxed, it will be done in the future. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-08-22block: deprecate total_sectors, add total_bytesPeter Wu1-0/+3
This prepares for removal of 512-byte sector units. Since a length unit cannot be negative, let's use an unsigned integer for the new total_bytes unit. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-08-20block: Add bdrv_refresh_filename()Max Reitz2-0/+7
Some block devices may not have a filename in their BDS; and for some, there may not even be a normal filename at all. To work around this, add a function which tries to construct a valid filename for the BDS.filename field. If a filename exists or a block driver is able to reconstruct a valid filename (which is placed in BDS.exact_filename), this can directly be used. If no filename can be constructed, we can still construct an options QDict which is then converted to a JSON object and prefixed with the "json:" pseudo protocol prefix. The QDict is placed in BDS.full_open_options. For most block drivers, this process can be done automatically; those that need special handling may define a .bdrv_refresh_filename() method to fill BDS.exact_filename and BDS.full_open_options themselves. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-08-19Revert "memory: Use canonical path component as the name"Peter Maydell1-0/+1
This reverts commit b0225c2c0d89200a29dc3d0b59d2e87a79cbaeb8 (which breaks building with Xen enabled and also leaks memory). Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-19Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell3-12/+8
SCSI changes that enable sending vendor-specific commands via virtio-scsi. Memory changes for QOMification and automatic tracking of MR lifetime. # gpg: Signature made Mon 18 Aug 2014 13:03:09 BST using RSA key ID 9B4D86F2 # gpg: Good signature from "Paolo Bonzini <pbonzini@redhat.com>" # gpg: aka "Paolo Bonzini <bonzini@gnu.org>" * remotes/bonzini/tags/for-upstream: mtree: remove write-only field memory: Use canonical path component as the name memory: Use memory_region_name for name access memory: constify memory_region_name exec: Abstract away ref to memory region names loader: Abstract away ref to memory region names tpm_tis: remove instance_finalize callback memory: remove memory_region_destroy memory: convert memory_region_destroy to object_unparent ioport: split deletion and destruction nic: do not destroy memory regions in cleanup functions vga: do not dynamically allocate chain4_alias sysbus: remove unused function sysbus_del_io qom: object: move unparenting to the child property's release callback qom: object: delete properties before calling instance_finalize virtio-scsi: implement parse_cdb scsi-block, scsi-generic: implement parse_cdb scsi-block: extract scsi_block_is_passthrough scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo scsi-bus: prepare scsi_req_new for introduction of parse_cdb Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-19Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into stagingPeter Maydell1-1/+1
* remotes/qmp-unstable/queue/qmp: monitor: fix use after free dump.c: Fix memory leak issue in cleanup processing for dump_init() monitor: Remove hardcoded watchdog event names Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-18monitor: fix use after freeMichael S. Tsirkin1-1/+1
The function monitor_fdset_dup_fd_find_remove() references member of 'mon_fdset' which - when remove flag is set - may be freed in function monitor_fdset_cleanup(). remove is set by monitor_fdset_dup_fd_remove which in practice does not need the returned value, so make it void, and return -1 from monitor_fdset_dup_fd_find_remove. Reported-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-08-18virtio-serial: create a linked list of all active devicesAmit Shah1-0/+2
To ensure two virtserialports don't get added to the system with the same 'name' parameter, we need to access all the ports on all the devices added, and compare the names. We currently don't have a list of all VirtIOSerial devices added to the system. This commit adds a simple linked list in which devices are put when they're initialized, and removed when they go away. Signed-off-by: Amit Shah <amit.shah@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2014-08-18memory: Use canonical path component as the namePeter Crosthwaite1-1/+0
Rather than having the name as separate state. This prepares support for creating a MemoryRegion dynamically (i.e. without memory_region_init() and friends) and the MemoryRegion still getting a usable name. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-18memory: constify memory_region_namePeter Crosthwaite1-1/+1
It doesn't change the MR and some prospective call sites will have const MRs at hand. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-18memory: remove memory_region_destroyPaolo Bonzini1-9/+0
The function is empty after the previous patch, so remove it. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-17sysbus: remove unused function sysbus_del_ioPaolo Bonzini1-1/+0
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-15Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-08-15' ↵Peter Maydell1-1/+1
into staging trivial patches for 2014-08-15 # gpg: Signature made Fri 15 Aug 2014 16:13:03 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-08-15: ivshmem: check the value returned by fstat() l2cap: fix access to freed memory intc: i8259: Convert Array allocation to g_new0 ppc: convert g_new(qemu_irq usages to g_new0 ssi: xilinx_spi: Initialise CS GPIOs as NULL vl: free err qemu-options.hx: fix typo about l2tpv3 vmxnet3: don't use 'Yoda conditions' vl: don't use 'Yoda conditions' spice: don't use 'Yoda conditions' don't use 'Yoda conditions' isa-bus: don't use 'Yoda conditions' audio: don't use 'Yoda conditions' usb: don't use 'Yoda conditions' CODING_STYLE: Section about conditional statement pci-host: update uncorresponding description pci-host: update obsolete reference about piix_pci.c qemu-options.hx: fix a typo of chardev memory: Update obsolete comment about AddrRange field type apic: Fix reported DFR content Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-15Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into stagingPeter Maydell2-2/+9
post-2.1 bugfixes A bunch of fixes that missed 2.1 by a small margin. If we do 2.1.1, some of these would be good candidates, added Cc qemu-stable as appropriate. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Thu 14 Aug 2014 17:07:25 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: pc: Get rid of pci-info leftovers e1000: use symbolic constants to init phy ctrl & status registers e1000: correctly handle phy_ctrl reserved & self-clearing bits ivshmem: fix building when debug mode is enabled acpi: align RSDP numa: show hex number in error message for consistency and prefix them with 0x pc-dimm: fix up error message pc-dimm: validate node property hw:i386: typo fix: MEMORY_HOPTLUG_DEVICE -> MEMORY_HOTPLUG_DEVICE hw/audio/intel-hda: Fix MSI capability address pc: Create 2.2 machine type pci: Use bus master address space for delivering MSI/MSI-X messages Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-15Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' ↵Peter Maydell5-0/+12
into staging Tracing pull request * remotes/stefanha/tags/tracing-pull-request: virtio-rng: add some trace events trace: add some tcg tracing support trace: teach lttng backend to use format strings trace: [tcg] Include TCG-tracing header on all targets trace: [tcg] Include event definitions in "trace.h" trace: [tcg] Generate TCG tracing routines trace: [tcg] Include TCG-tracing helpers trace: [tcg] Define TCG tracing helper routine wrappers trace: [tcg] Define TCG tracing helper routines trace: [tcg] Declare TCG tracing helper routines trace: [tcg] Add 'tcg' event property trace: [tcg] Argument type transformation machinery trace: [tcg] Argument type transformation rules trace: [tcg] Add documentation trace: install simpletrace SystemTap tapset simpletrace: add simpletrace.py --no-header option trace: add tracetool simpletrace_stap format trace: extract stap_escape() function for reuse Conflicts: Makefile.objs
2014-08-15pci-host: update obsolete reference about piix_pci.cGonglei1-1/+1
piix_pci.c has been renamed into piix.c at commit c0907c9e6417cb959dfd9ef6873221536ec91351 update the obsolete reference. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-08-15Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell3-0/+14
Block patches # gpg: Signature made Fri 15 Aug 2014 14:07:42 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (59 commits) block: Catch !bs->drv in bdrv_check() iotests: Add test for image header overlap qcow2: Catch !*host_offset for data allocation qcow2: Return useful error code in refcount_init() mirror: Handle failure for potentially large allocations vpc: Handle failure for potentially large allocations vmdk: Handle failure for potentially large allocations vhdx: Handle failure for potentially large allocations vdi: Handle failure for potentially large allocations rbd: Handle failure for potentially large allocations raw-win32: Handle failure for potentially large allocations raw-posix: Handle failure for potentially large allocations qed: Handle failure for potentially large allocations qcow2: Handle failure for potentially large allocations qcow1: Handle failure for potentially large allocations parallels: Handle failure for potentially large allocations nfs: Handle failure for potentially large allocations iscsi: Handle failure for potentially large allocations dmg: Handle failure for potentially large allocations curl: Handle failure for potentially large allocations ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-15block: Introduce qemu_try_blockalign()Kevin Wolf2-0/+2
This function returns NULL instead of aborting when an allocation fails. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net>
2014-08-15coroutine: make pool size dynamicStefan Hajnoczi1-0/+11
Allow coroutine users to adjust the pool size. For example, if the guest has multiple emulated disk drives we should keep around more coroutines. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2014-08-15block: New bdrv_nb_sectors()Markus Armbruster1-0/+1
A call to retrieve the image size converts between bytes and sectors several times: * BlockDriver method bdrv_getlength() returns bytes. * refresh_total_sectors() converts to sectors, rounding up, and stores in total_sectors. * bdrv_getlength() converts total_sectors back to bytes (now rounded up to a multiple of the sector size). * Callers wanting sectors rather bytes convert it right back. Example: bdrv_get_geometry(). bdrv_nb_sectors() provides a way to omit the last two conversions. It's exactly bdrv_getlength() with the conversion to bytes omitted. It's functionally like bdrv_get_geometry() without its odd error handling. Reimplement bdrv_getlength() and bdrv_get_geometry() on top of bdrv_nb_sectors(). The next patches will convert some users of bdrv_getlength() to bdrv_nb_sectors(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-08-14pc: Get rid of pci-info leftoversMarkus Armbruster1-1/+0
pc_fw_cfg_guest_info() never does anything, because has_pci_info is always false. Introduced in commit f8c457b "pc: pass PCI hole ranges to Guests", disabled in commit 9604f70 "pc: disable pci-info for 1.6", and hasn't been enabled since. Obviously a dead end. Get of it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-08-14hw: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>
2014-08-14hw/audio/intel-hda: Fix MSI capability addressJan Kiszka1-1/+6
According to ICH9 spec, the MSI capability is located at 0x60. This is important for guest drivers that do not parse the capability chain and use absolute addresses instead. CC: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-08-14pc: Create 2.2 machine typeJan Kiszka1-0/+3
Yet identical to 2.1. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-08-12trace: [tcg] Include event definitions in "trace.h"Lluís Vilanova1-0/+1
Otherwise the user has to explicitly include an auto-generated header. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-08-12trace: [tcg] Generate TCG tracing routinesLluís Vilanova1-0/+7
Generate header "trace/generated-tcg-tracers.h" with the necessary routines for tracing events in guest code: * trace_${event}_tcg Convenience wrapper that calls the translation-time tracer 'trace_${event}_trans', and calls 'gen_helper_trace_${event}_exec to generate the TCG code to later trace the event at execution time. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-08-12trace: [tcg] Include TCG-tracing helpersLluís Vilanova3-0/+4
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-08-09hw/timer: Move extern declaration from .c to .h fileStefan Weil1-1/+6
This fixes a warning from smatch (static code analyser). Fix also the comment with the renamed source file name. Signed-off-by: Stefan Weil <sw@weilnetz.de> hw/timer/tusb6010.c | 3 --- include/hw/usb.h | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-08-09virtio: Move extern declaration to header fileStefan Weil1-0/+2
This fixes a warning from smatch (static code analyser). Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-08-07Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell3-1/+12
KVM changes include a MIPS patch and the testdev backend used by the ARM kvm-unit-tests. icount include the first part of reverse execution and Sebastian Tanase's patches to slow down -icount execution to the desired speed of the target. v1->v2: fix dump_drift_info to print nothing outside icount mode, and to compile on 32-bit architectures # gpg: Signature made Thu 07 Aug 2014 14:09:58 BST using RSA key ID 9B4D86F2 # gpg: Good signature from "Paolo Bonzini <pbonzini@redhat.com>" # gpg: aka "Paolo Bonzini <bonzini@gnu.org>" * remotes/bonzini/tags/for-upstream: target-mips: Ignore unassigned accesses with KVM monitor: Add drift info to 'info jit' cpu-exec: Print to console if the guest is late cpu-exec: Add sleeping algorithm icount: Add align option to icount icount: Add QemuOpts for icount icount: Fix virtual clock start value on ARM timer: add cpu_icount_to_ns function. migration: migrate icount fields. icount: put icount variables into TimerState. backends: Introduce chr-testdev Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-08-07monitor: Add drift info to 'info jit'Sebastian Tanase1-0/+4
Show in 'info jit' the current delay between the host clock and the guest clock. In addition, print the maximum advance and delay of the guest compared to the host. Signed-off-by: Sebastian Tanase <sebastian.tanase@openwide.fr> Tested-by: Camille Bégué <camille.begue@openwide.fr> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-06cpu-exec: Add sleeping algorithmSebastian Tanase1-0/+1
The goal is to sleep qemu whenever the guest clock is in advance compared to the host clock (we use the monotonic clocks). The amount of time to sleep is calculated in the execution loop in cpu_exec. At first, we tried to approximate at each for loop the real time elapsed while searching for a TB (generating or retrieving from cache) and executing it. We would then approximate the virtual time corresponding to the number of virtual instructions executed. The difference between these 2 values would allow us to know if the guest is in advance or delayed. However, the function used for measuring the real time (qemu_clock_get_ns(QEMU_CLOCK_REALTIME)) proved to be very expensive. We had an added overhead of 13% of the total run time. Therefore, we modified the algorithm and only take into account the difference between the 2 clocks at the begining of the cpu_exec function. During the for loop we try to reduce the advance of the guest only by computing the virtual time elapsed and sleeping if necessary. The overhead is thus reduced to 3%. Even though this method still has a noticeable overhead, it no longer is a bottleneck in trying to achieve a better guest frequency for which the guest clock is faster than the host one. As for the the alignement of the 2 clocks, with the first algorithm the guest clock was oscillating between -1 and 1ms compared to the host clock. Using the second algorithm we notice that the guest is 5ms behind the host, which is still acceptable for our use case. The tests where conducted using fio and stress. The host machine in an i5 CPU at 3.10GHz running Debian Jessie (kernel 3.12). The guest machine is an arm versatile-pb built with buildroot. Currently, on our test machine, the lowest icount we can achieve that is suitable for aligning the 2 clocks is 6. However, we observe that the IO tests (using fio) are slower than the cpu tests (using stress). Signed-off-by: Sebastian Tanase <sebastian.tanase@openwide.fr> Tested-by: Camille Bégué <camille.begue@openwide.fr> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-06icount: Add align option to icountSebastian Tanase1-0/+1
The align option is used for activating the align algorithm in order to synchronise the host clock and the guest clock. Signed-off-by: Sebastian Tanase <sebastian.tanase@openwide.fr> Tested-by: Camille Bégué <camille.begue@openwide.fr> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-06icount: Add QemuOpts for icountSebastian Tanase1-1/+2
Make icount parameter use QemuOpts style options in order to easily add other suboptions. Signed-off-by: Sebastian Tanase <sebastian.tanase@openwide.fr> Tested-by: Camille Bégué <camille.begue@openwide.fr> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-06timer: add cpu_icount_to_ns function.KONRAD Frederic1-0/+1
This adds cpu_icount_to_ns function which is needed for reverse execution. It returns the time for a specific instruction. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-06backends: Introduce chr-testdevPaolo Bonzini1-0/+3
From: Paolo Bonzini <pbonzini@redhat.com> chr-testdev enables a virtio serial channel to be used for guest initiated qemu exits. hw/misc/debugexit already enables guest initiated qemu exits, but only for PC targets. chr-testdev supports any virtio-capable target. kvm-unit-tests/arm is already making use of this backend. Currently there is a single command implemented, "q". It takes a (prefix) argument for the exit code, thus an exit is implemented by writing, e.g. "1q", to the virtio-serial port. It can be used as: $QEMU ... \ -device virtio-serial-device \ -device virtserialport,chardev=ctd -chardev testdev,id=ctd or, use: $QEMU ... \ -device virtio-serial-device \ -device virtconsole,chardev=ctd -chardev testdev,id=ctd to bind it to virtio-serial port0. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-08-01qemu: support xen hvm direct kernel bootChunyan Liu1-0/+5
qemu side patch to support xen HVM direct kernel boot: if -kernel exists, calls xen_load_linux(), which will read kernel/initrd and add a linuxboot.bin or multiboot.bin option rom. The linuxboot.bin/multiboot.bin will load kernel/initrd and jump to execute kernel directly. It's working when xen uses seabios. During this work, found the 'kvmvapic' is in option_rom list, it should not be there in xen case. Set s->vapic_control = 0 in xen_apic_realize() to handle that. Signed-off-by: Chunyan Liu <cyliu@suse.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
2014-07-29scsi-block, scsi-generic: implement parse_cdbPaolo Bonzini1-0/+1
The callback lets the bus provide the direction and transfer count for passthrough commands, enabling passthrough of vendor-specific commands. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-07-29scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfoPaolo Bonzini1-0/+6
These callbacks will let devices do their own request parsing, or defer it to the bus. If the bus does not provide an implementation, in turn, fall back to the default parsing routine. Swap the first two arguments to scsi_req_parse, and rename it to scsi_req_parse_cdb, for consistency. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.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>