sdk/emulator/qemu.git
12 years agobsd-user: Don't overuse CPUState
Andreas Färber [Sat, 25 Feb 2012 03:29:56 +0000 (04:29 +0100)]
bsd-user: Don't overuse CPUState

Use CPU*State where applicable.

Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agodarwin-user: Don't overuse CPUState
Andreas Färber [Sat, 25 Feb 2012 03:27:43 +0000 (04:27 +0100)]
darwin-user: Don't overuse CPUState

Use CPU*State where applicable.

Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agolinux-user: Don't overuse CPUState
Andreas Färber [Sat, 25 Feb 2012 02:37:53 +0000 (03:37 +0100)]
linux-user: Don't overuse CPUState

In target-specific code use CPU*State.

While at it, fix indentation on those lines.

Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agohw/mc146818: Drop unneeded #includes
Andreas Färber [Sat, 25 Feb 2012 01:14:24 +0000 (02:14 +0100)]
hw/mc146818: Drop unneeded #includes

pc.h and apic.h are not needed; apic.h would drag in x86 CPUState and
is now included directly for TARGET_I386.

isa.h is already #included from mc146818rtc.h.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotarget-unicore32: Rename to CPUUniCore32State
Andreas Färber [Wed, 15 Feb 2012 23:12:24 +0000 (00:12 +0100)]
target-unicore32: Rename to CPUUniCore32State

This aids in refactoring CPUState by adopting the common naming scheme.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotarget-sparc: Typedef struct CPUSPARCState early
Andreas Färber [Fri, 24 Feb 2012 16:15:27 +0000 (17:15 +0100)]
target-sparc: Typedef struct CPUSPARCState early

Will be needed for qemu_irq_ack callback.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotarget-lm32/microblaze: Typedef struct CPU{MB,LM32}State
Andreas Färber [Fri, 24 Feb 2012 15:59:17 +0000 (16:59 +0100)]
target-lm32/microblaze: Typedef struct CPU{MB,LM32}State

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomonitor: Avoid CPUState in read/write functions
Andreas Färber [Mon, 20 Feb 2012 05:44:56 +0000 (06:44 +0100)]
monitor: Avoid CPUState in read/write functions

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomonitor: Don't access registers through CPUState
Andreas Färber [Wed, 15 Feb 2012 23:40:47 +0000 (00:40 +0100)]
monitor: Don't access registers through CPUState

Use CPUX86State etc. instead (hand-converted).

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoRename cpu_reset() to cpu_state_reset()
Andreas Färber [Wed, 8 Feb 2012 02:03:33 +0000 (03:03 +0100)]
Rename cpu_reset() to cpu_state_reset()

Frees the identifier cpu_reset for QOM CPUs (manual rename).

Don't hide the parameter type behind explicit casts, use static
functions with strongly typed argument to indirect.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoPPC: 405: Use proper CPU reset
Alexander Graf [Tue, 21 Feb 2012 18:41:59 +0000 (19:41 +0100)]
PPC: 405: Use proper CPU reset

On ppc405ep there is a register that allows for software to reset the
core, but not the whole system. Implement this reset using a reset
interrupt.

This gets rid of a bunch of #if 0'ed code.

Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
12 years agoqom: Introduce object_class_get_list()
Andreas Färber [Sat, 25 Feb 2012 22:07:34 +0000 (23:07 +0100)]
qom: Introduce object_class_get_list()

This function allows to obtain a singly-linked list of classes, which
can be sorted by the caller.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqom/object.c: rename type_class_init() to type_initialize()
Igor Mitsyanko [Tue, 28 Feb 2012 11:57:11 +0000 (15:57 +0400)]
qom/object.c: rename type_class_init() to type_initialize()

Function name type_class_init() gave us a wrong impression of separation
of type's "class" and "object" entities initialization. Name type_initialize()
is more appropriate for type_class_init() function (considering what operations
it performs).

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqom: if @instance_size==0, assign size of object to parent object size
Igor Mitsyanko [Tue, 28 Feb 2012 11:57:10 +0000 (15:57 +0400)]
qom: if @instance_size==0, assign size of object to parent object size

QOM documentation states that for objects of type with @instance_size == 0 size
will be assigned to match parent object's size. But currently this feauture is
not implemented and qemu asserts during creation of object with zero instance_size.

Set appropriate value for type instance_size during type_class_init() call.
object_initialize_with_type() must call type_class_init() before asserting
type->instance_size, and object_new_with_type() must call type_class_init() before
object allocation.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agokvmvapic: align start address as well as size
Avi Kivity [Tue, 6 Mar 2012 15:50:10 +0000 (17:50 +0200)]
kvmvapic: align start address as well as size

The kvmvapic code remaps a section of ROM as RAM to allow the guest to
maintain state there.  It is careful to align the section size to a page
boundary, to avoid creating subpages, but neglects to do the same for
the start address.  These leads to an assert later on when the memory
core tries to create a page which is half RAM and half ROM.

Fix by aligning the start address to a page boundary.

This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'kiszka/queues/slirp' into staging
Anthony Liguori [Tue, 13 Mar 2012 18:56:13 +0000 (13:56 -0500)]
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

* kiszka/queues/slirp:
  slirp: Fix compiler warning for w64
  slirp: Cleanup resources on instance removal
  slirp: Remove unneeded if_queued
  slirp: Fix queue walking in if_start
  slirp: Prevent recursion of if_start
  slirp: Keep next_m always valid

12 years agoMerge remote-tracking branch 'kraxel/usb.44' into staging
Anthony Liguori [Tue, 13 Mar 2012 18:55:02 +0000 (13:55 -0500)]
Merge remote-tracking branch 'kraxel/usb.44' into staging

* kraxel/usb.44:
  Endian fix an assertion in usb-msd
  uhci: alloc can't fail, drop check.
  uhci: new uhci_handle_td return code for tds still in flight
  uhci: renumber uhci_handle_td return codes
  uhci: use enum for uhci_handle_td return codes
  uhci: tracing support
  uhci: cancel on schedule stop.
  uhci: fix uhci_async_cancel_all
  uhci: pass addr to uhci_async_alloc
  usb: improve packet state sanity checks
  usb-ohci: DMA writeback bug fixes
  usb-ehci: drop unused isoch_pause variable
  usb: zap hw/ush-{ohic,uhci}.h + init wrappers
  usb: the big rename

12 years agoqom: Add QOM support to user emulators
Andreas Färber [Sun, 4 Mar 2012 20:32:36 +0000 (21:32 +0100)]
qom: Add QOM support to user emulators

Link the Object base class and the module infrastructure for class
registration. Introduce $(universal-obj-y) for objects that are more
common than $(common-obj-y), so that those only get built once.

Call QOM module init for type registration.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqom: Register QOM infrastructure early
Andreas Färber [Sun, 4 Mar 2012 20:32:35 +0000 (21:32 +0100)]
qom: Register QOM infrastructure early

The constructors for QOM TYPE_INTERFACE were executed rather late in
vl.c's main(). Call them very early so that QOM can safely be used for
machines and CPUs.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agokvmclock: Always register type
Andreas Färber [Sun, 4 Mar 2012 20:32:34 +0000 (21:32 +0100)]
kvmclock: Always register type

Currently, the "kvmclock" type is only registered when kvm_enabled().

This breaks when moving type registration to before command line
parsing (so that QOM types can be used for CPU and machine).

Since the QOM classes are lazy-initialized anyway and kvmclock_create()
has another kvm_enabled() check, simply drop the KVM check in
kvmclock_register_types().

kvm-i8259, kvm-apic and kvm-ioapic do not suffer from such a check.

Reviewed-by: please.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoslirp: Fix compiler warning for w64
Stefan Weil [Sat, 10 Mar 2012 20:20:53 +0000 (21:20 +0100)]
slirp: Fix compiler warning for w64

Casting a pointer to an integer value must use uintptr_t or intptr_t
(not long) for portable code. MinGW-w64 requires this because
sizeof(long) != sizeof(void *) for w64 hosts, so casting to long
raises a compiler warning.

I use uintptr_t instead of intptr_t because changing the sign does not
matter here and casting pointers to unsigned values seems more
reasonable (the unsigned value is a non negative offset.

Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoslirp: Cleanup resources on instance removal
Jan Kiszka [Wed, 29 Feb 2012 18:14:23 +0000 (19:14 +0100)]
slirp: Cleanup resources on instance removal

Close & free sockets when shutting down a slirp instance, also release
all buffers.

CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoslirp: Remove unneeded if_queued
Jan Kiszka [Mon, 5 Mar 2012 23:02:23 +0000 (00:02 +0100)]
slirp: Remove unneeded if_queued

There is now a trivial check on entry of if_start for pending packets,
so we can drop the additional tracking via if_queued.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoslirp: Fix queue walking in if_start
Jan Kiszka [Mon, 5 Mar 2012 23:00:07 +0000 (00:00 +0100)]
slirp: Fix queue walking in if_start

Another attempt to get this right: We need to carefully walk both the
fastq and the batchq in if_start while trying to send packets to
possibly not yet resolved hosts on the virtual network.

So far we just requeued a delayed packet where it was and then started
walking the queues from the top again - that couldn't work. Now we pre-
calculate the next packet in the queue so that the current one can
safely be removed if it was sent successfully. We also need to take into
account that the next packet can be from the same session if the current
one was sent and there are no other sessions.

CC: Fabien Chouteau <chouteau@adacore.com>
CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
CC: Stefan Weil <sw@weilnetz.de>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoslirp: Prevent recursion of if_start
Jan Kiszka [Mon, 5 Mar 2012 18:50:39 +0000 (19:50 +0100)]
slirp: Prevent recursion of if_start

if_start can be called recursively via if_encap. Avoid this as our
scheme of dequeuing packets is not compatible with this.

CC: Fabien Chouteau <chouteau@adacore.com>
CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
CC: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoslirp: Keep next_m always valid
Jan Kiszka [Wed, 29 Feb 2012 08:27:33 +0000 (09:27 +0100)]
slirp: Keep next_m always valid

Make sure that next_m always points to a packet if batchq is non-empty.
This will simplify walking the queues in if_start.

CC: Fabien Chouteau <chouteau@adacore.com>
CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
CC: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agoEndian fix an assertion in usb-msd
Benjamin Herrenschmidt [Thu, 8 Mar 2012 00:41:10 +0000 (11:41 +1100)]
Endian fix an assertion in usb-msd

This fixes a broken endian assumption in an assertion in usb-msd.

Cc: Gerd Hoffman <kraxel@redhat.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: alloc can't fail, drop check.
Gerd Hoffmann [Fri, 9 Mar 2012 10:10:48 +0000 (11:10 +0100)]
uhci: alloc can't fail, drop check.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: new uhci_handle_td return code for tds still in flight
Gerd Hoffmann [Fri, 9 Mar 2012 10:15:41 +0000 (11:15 +0100)]
uhci: new uhci_handle_td return code for tds still in flight

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: renumber uhci_handle_td return codes
Gerd Hoffmann [Fri, 9 Mar 2012 10:11:46 +0000 (11:11 +0100)]
uhci: renumber uhci_handle_td return codes

Step #2 (separate for better bisectability): renumber so the silly '-1'
goes away.  Pick a range which doesn't overlap the old values.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: use enum for uhci_handle_td return codes
Gerd Hoffmann [Fri, 9 Mar 2012 10:09:49 +0000 (11:09 +0100)]
uhci: use enum for uhci_handle_td return codes

Step #1 (separate for better bisectability): replace numbers with names.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: tracing support
Gerd Hoffmann [Thu, 8 Mar 2012 12:12:38 +0000 (13:12 +0100)]
uhci: tracing support

Zap DPRINTF, add tracepoints instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: cancel on schedule stop.
Gerd Hoffmann [Thu, 8 Mar 2012 12:37:52 +0000 (13:37 +0100)]
uhci: cancel on schedule stop.

Cancel any in-flight transaction when the guest stops the uhci schedule.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: fix uhci_async_cancel_all
Gerd Hoffmann [Thu, 8 Mar 2012 12:29:07 +0000 (13:29 +0100)]
uhci: fix uhci_async_cancel_all

It should also free all queues.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agouhci: pass addr to uhci_async_alloc
Gerd Hoffmann [Thu, 8 Mar 2012 12:15:56 +0000 (13:15 +0100)]
uhci: pass addr to uhci_async_alloc

Also do async->td initialization in uhci_async_alloc now.
Prepares for adding tracepoints.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: improve packet state sanity checks
Gerd Hoffmann [Thu, 8 Mar 2012 11:27:47 +0000 (12:27 +0100)]
usb: improve packet state sanity checks

Add a new function to check whenever the packet state is as expected,
log more informations in case it isn't.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-ohci: DMA writeback bug fixes
Wei Yang [Thu, 8 Mar 2012 01:10:44 +0000 (12:10 +1100)]
usb-ohci: DMA writeback bug fixes

This patch fixes two bugs in the OHCI device where the device writes
back data to system memory that should be exclusively under the
control of the guest side driver.

In OHCI specification Section 5.2.7, it mentioned "In all cases, Host
Controller Driver is responsible for the insertion and removal of all
Endpoint Descriptors in the various Host Controller Endpoint
Descriptor lists".  In the ohci_frame_boundary(), ohci_put_hcca()
writes the entire hcca back including the interrupt ED lists which
should be under driver control. This violates the specification and
can race with a host driver updating that list at the same time.

In the OHCI Spec Section 4.6, Transfer Descriptor Queue Processing, it
mentioned "Since the TD pointed to by TailP is not accessed by the HC,
the Host Controller Driver can initialize that TD and link at least
one other to it without creating a coherency or synchronization
problem".  While the function ohci_put_ed() writes the entire endpoint
descriptor back including the TailP which should under driver
control. This violate the specification and can race with a host
driver updating the TD list at the same time.

In each case the solution is to make sure we don't write data which is
under driver control.

Cc: Gerd Hoffman <kraxel@redhat.com>
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-ehci: drop unused isoch_pause variable
Hans de Goede [Sun, 4 Mar 2012 11:10:11 +0000 (12:10 +0100)]
usb-ehci: drop unused isoch_pause variable

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: zap hw/ush-{ohic,uhci}.h + init wrappers
Gerd Hoffmann [Wed, 7 Mar 2012 14:06:32 +0000 (15:06 +0100)]
usb: zap hw/ush-{ohic,uhci}.h + init wrappers

Remove the uhci and ohci init wrappers, which all wrapped a
pci_create_simple() one-liner.  Switch callsites to call
pci_create_simple directly.  Remove the header files where
the wrappers where declared.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: the big rename
Gerd Hoffmann [Wed, 7 Mar 2012 13:55:18 +0000 (14:55 +0100)]
usb: the big rename

Reorganize usb source files.  Create a new hw/usb/ directory and move
all usb source code to that place.  Also make filenames a bit more
descriptive.  Host adapters are prefixed with "hch-" now, usb device
emulations are prefixed with "dev-".  Fixup paths Makefile and include
paths to make it compile.  No code changes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoMerge remote-tracking branch 'mdroth/qga-pull-3-12-2012' into staging
Anthony Liguori [Tue, 13 Mar 2012 01:52:34 +0000 (20:52 -0500)]
Merge remote-tracking branch 'mdroth/qga-pull-3-12-2012' into staging

* mdroth/qga-pull-3-12-2012:
  qemu-ga: add guest-sync-delimited
  qemu-ga: add guest-network-get-interfaces command
  qemu-ga: add win32 guest-suspend-ram command
  qemu-ga: add win32 guest-suspend-disk command.
  qemu-ga: add guest-suspend-hybrid
  qemu-ga: add guest-suspend-ram
  qemu-ga: add guest-suspend-disk

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 13 Mar 2012 01:51:42 +0000 (20:51 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  test-coroutine: add performance test for nesting
  coroutine: adding configure option for sigaltstack coroutine backend
  coroutine: adding configure choose mechanism for coroutine backend
  coroutine: adding sigaltstack method (.c source)
  qcow2: Reduce number of I/O requests
  qcow2: Add qcow2_alloc_clusters_at()
  qcow2: Factor out count_cow_clusters
  qmp: convert blockdev-snapshot-sync to a wrapper around transactions
  add mode field to blockdev-snapshot-sync transaction item
  rename blockdev-group-snapshot-sync
  qapi: complete implementation of unions
  use QSIMPLEQ_FOREACH_SAFE when freeing list elements
  Add 'make check-block'
  make check: Add qemu-iotests subset
  qemu-iotests: Mark some tests as quick
  qcow2: Add error messages in qcow2_truncate
  block: handle -EBUSY in bdrv_commit_all()
  qcow2: Add some tracing
  qed: do not evict in-use L2 table cache entries
  Group snapshot: Fix format name for backing file

12 years agoMerge remote-tracking branch 'qemu-kvm/memory/core' into staging
Anthony Liguori [Tue, 13 Mar 2012 01:50:09 +0000 (20:50 -0500)]
Merge remote-tracking branch 'qemu-kvm/memory/core' into staging

* qemu-kvm/memory/core:
  memory: get rid of cpu_register_io_memory()
  memory: dispatch directly via MemoryRegion
  exec: fix code tlb entry misused as iotlb in get_page_addr_code()
  memory: store section indices in iotlb instead of io indices
  memory: make phys_page_find() return an unadjusted section

12 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Tue, 13 Mar 2012 01:49:13 +0000 (20:49 -0500)]
Merge remote-tracking branch 'stefanha/tracing' into staging

* stefanha/tracing:
  vga: add trace event for ppm_save
  console: add some trace events
  maintainers: Add docs/tracing.txt to Tracing
  docs: correct ./configure line in tracing.txt
  trace: make trace_thread_create() use its function arg
  tracetool: Omit useless QEMU_*_ENABLED() check
  trace: Provide a per-event status define for conditional compilation

12 years agoMerge remote-tracking branch 'qmp/queue/qmp' into staging
Anthony Liguori [Tue, 13 Mar 2012 01:48:00 +0000 (20:48 -0500)]
Merge remote-tracking branch 'qmp/queue/qmp' into staging

* qmp/queue/qmp:
  qapi-schema.json: fix comment for type ObjectPropretyInfo
  qapi-schema: fix typos and explain 'spice' auth
  qjson.h: include compiler.h for GCC_FMT_ATTR

12 years agoqemu-ga: add guest-sync-delimited
Michael Roth [Tue, 7 Feb 2012 19:56:48 +0000 (13:56 -0600)]
qemu-ga: add guest-sync-delimited

guest-sync leaves it as an exercise to the user as to how to reliably
obtain the response to guest-sync if the client had previously read in a
partial response (due qemu-ga previously being restarted mid-"sentence"
due to reboot, forced restart, etc).

qemu-ga handles this situation on its end by having a client precede
their guest-sync request with a 0xFF byte (invalid UTF-8), which
qemu-ga/QEMU JSON parsers will treat as a flush event. Thus we can
reliably flush the qemu-ga parser state in preparation for receiving
the guest-sync request.

guest-sync-delimited provides the same functionality for a client: when
a guest-sync-delimited is issued, qemu-ga will precede it's response
with a 0xFF byte that the client can use as an indicator to flush its
buffer/parser state in preparation for reliably receiving the
guest-sync-delimited response.

It is also useful as an optimization for clients, since, after issuing a
guest-sync-delimited, clients can safely discard all stale data read
from the channel until the 0xFF is found.

More information available on the wiki:

http://wiki.qemu.org/Features/QAPI/GuestAgent#QEMU_Guest_Agent_Protocol

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 years agoqemu-ga: add guest-network-get-interfaces command
Michal Privoznik [Wed, 29 Feb 2012 16:02:23 +0000 (17:02 +0100)]
qemu-ga: add guest-network-get-interfaces command

This command returns an array of:

 [ifname, hwaddr, [ipaddr, ipaddr_family, prefix] ]

for each interface in the system.
Currently, only IPv4 and IPv6 are supported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
12 years agoqemu-ga: add win32 guest-suspend-ram command
Michael Roth [Mon, 12 Mar 2012 17:50:02 +0000 (12:50 -0500)]
qemu-ga: add win32 guest-suspend-ram command

S3 sleep implementation for windows.

12 years agoqemu-ga: add win32 guest-suspend-disk command.
Gal Hammer [Sun, 29 Jan 2012 09:53:31 +0000 (11:53 +0200)]
qemu-ga: add win32 guest-suspend-disk command.

Implement guest-suspend-disk RPC for Windows. Functionally this should be
equivalent to the posix implementation.

Signed-off-by: Gal Hammer <ghammer@redhat.com>
12 years agoqemu-ga: add guest-suspend-hybrid
Luiz Capitulino [Tue, 28 Feb 2012 14:03:05 +0000 (11:03 -0300)]
qemu-ga: add guest-suspend-hybrid

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqemu-ga: add guest-suspend-ram
Luiz Capitulino [Tue, 28 Feb 2012 14:03:04 +0000 (11:03 -0300)]
qemu-ga: add guest-suspend-ram

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqemu-ga: add guest-suspend-disk
Luiz Capitulino [Tue, 28 Feb 2012 14:03:03 +0000 (11:03 -0300)]
qemu-ga: add guest-suspend-disk

As the command name implies, this command suspends the guest to disk.

The suspend operation is implemented by two functions: bios_supports_mode()
and guest_suspend(). Both functions are generic enough to be used by
other suspend modes (introduced by next commits).

Both functions will try to use the scripts provided by the pm-utils
package if it's available. If it's not available, a manual method,
which consists of directly writing to '/sys/power/state', will be used.

To reap terminated children, a new signal handler is installed in the
parent to catch SIGCHLD signals and a non-blocking call to waitpid()
is done to collect their exit statuses. The statuses, however, are
discarded.

The approach used to query the guest for suspend support deserves some
explanation. It's implemented by bios_supports_mode() and shown below:

  qemu-ga
     |
 create pipe
     |
   fork()
     -----------------
     |               |
     |               |
     |             fork()
     |               --------------------------
     |               |                        |
     |               |                        |
     |               |               exec('pm-is-supported')
     |               |
     |              wait()
     |       write exit status to pipe
     |              exit
     |
  read pipe

This might look complex, but the resulting code is quite simple.
The purpose of that approach is to allow qemu-ga to reap its children
(semi-)automatically from its SIGCHLD handler.

Implementing this the obvious way, that's, doing the exec() call from
the first child process, would force us to introduce a more complex way
to reap qemu-ga's children. Like registering PIDs to be reaped and
having a way to wait for them when returning their exit status to
qemu-ga is necessary. The approach explained above avoids that complexity.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agocpu-all.h: Don't accidentally sign extend in g2h()
Peter Maydell [Fri, 9 Mar 2012 14:33:20 +0000 (14:33 +0000)]
cpu-all.h: Don't accidentally sign extend in g2h()

Cast the argument of the g2h() macro to a target_ulong so that
it isn't accidentally sign-extended if it is a signed 32 bit
type and long is a 64 bit type. In particular, this fixes a
bug where it would return the wrong value for 32 bit guests
on 64 bit hosts when passed in one of the arg* values from
do_syscall() [which are all abi_long and thus signed types].
This could result in spurious failure of mlock(), among others.

Reviewed-by: Andreas F=E4rber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoimplement vnc_dpy_setdata
Gerd Hoffmann [Thu, 8 Mar 2012 10:19:19 +0000 (11:19 +0100)]
implement vnc_dpy_setdata

The comment is wrong, we have to do something in the setdata callback.
Changing the framebuffer backing storage (happens when the guest pans
the display) renders the whole screen content invalid.

Trigger #1: cirrus vga + 32bit linux guest + vesafb with ypan enabled.
Trigger #2: std vga + http://patchwork.ozlabs.org/patch/145479/

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoinitialize CPU model list after handling -readconfig options
Eduardo Habkost [Fri, 9 Mar 2012 19:19:07 +0000 (16:19 -0300)]
initialize CPU model list after handling -readconfig options

To properly load cpudefs using -readconfig, we have to call
cpudef_init() after finishing the command-line option handling.

Consequently, the handling of "-cpu ?" has to be done after the
command-line option handling loop, too.

Without this patch, "-readconfig configfile -cpu ?" fails to list the
CPU definitions read from 'configfile'.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoadd Opteron_G4 CPU model (v2)
Eduardo Habkost [Tue, 6 Mar 2012 18:11:32 +0000 (15:11 -0300)]
add Opteron_G4 CPU model (v2)

This patch addes a Bulldozer-based Opteron_G4 CPU model.

This version has the ffxsr bit actually disabled, to match what was
documented below. Thanks to Andre Przywara for spotting the bug.

I am trying to be conservative with the new model, so I am enabling only
features known to be useful to guests, and not enabling anything that
was not tested or found to be useful to a guest.

List of missing flags in comparison to real hardware:

- vme: host-specific feature.
- osxsave: it is not set here because it is set by the guest OS, not by KVM
- monitor: this is filtered out by the KVM module, so no point in
  enabling it.
- mmxext: untested, so not enabled.
- Perf*, Topology*, lwp, ibs: not emulated by KVM.
- wdt, skinit, osvw, altmovcr8, extapicspace, cmplegacy: untested,
  so not enabled.

List of new flags, in comparison to the Opteron_G3 model:

- xsave: xsave feature, already implemented by Qemu
- avx, aes, sse4.x, ssse3, pclmulqdq: all new state the new instructions
  could use is handled by the xsave state loading/saving code on Qemu.
- pdpe1gb: 1GB pages, supported by the KVM kernel module.
- ffxsr: untested, so not enabled
- fma4, xop: all new state the new instructions could use is handled by
  the xsave loading/saving code on Qemu.
- 3dnowprefetch: safe to pass through, though the flag is not used by
  Linux guests, at least.

Below is the comparison between the current Opteron_G3 model
and the new model being added.

- The "full" line contains the flags found on actual hardware.
- The "missing" line shows the flags that are present on actual
  hardware, but not on the added Opteron_G4 model.
- The "new" line shows the flags that were not on the Opteron_G3 model
  but are on Opteron_G4.

feature_edx:
  Opteron_G3: sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de     fpu
  full:       sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de vme fpu
  Opteron_G4: sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de     fpu
  missing:                                                                                              vme

feature_ecx:
  Opteron_G3:                       popcnt               cx16       monitor           sse3
  full:       avx osxsave xsave aes popcnt sse4.2 sse4.1 cx16 ssse3 monitor pclmulqdq sse3
  Opteron_G4: avx         xsave aes popcnt sse4.2 sse4.1 cx16 ssse3         pclmulqdq sse3
  missing:        osxsave                                           monitor
  new:        avx         xsave aes        sse4.2 sse4.1      ssse3         pclmulqdq

extfeature_edx:
  Opteron_G3: lm rdtscp               fxsr mmx        nx pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de     fpu
  full:       lm rdtscp pdpe1gb ffxsr fxsr mmx mmxext nx pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de vme fpu
  Opteron_G4: lm rdtscp pdpe1gb       fxsr mmx        nx pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de     fpu
  missing:                                     mmxext                                                                        vme
  new:                  pdpe1gb

extfeature_ecx:
  Opteron_G3:                                                                misalignsse sse4a abm                        svm           lahf_lm
  full:       Perf* Topology* fma4 lwp wdt skinit xop ibs osvw 3dnowprefetch misalignsse sse4a abm altmovcr8 extapicspace svm cmplegacy lahf_lm
  Opteron_G4:                 fma4                xop          3dnowprefetch misalignsse sse4a abm                        svm           lahf_lm
  new:                        fma4                xop          3dnowprefetch
  missing:    Perf* Topology*      lwp wdt skinit     ibs osvw                                     altmovcr8 extapicspace     cmplegacy

Changes v1 -> v2:
 - Actually disable ffxsr bit

Cc: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoadd SandyBridge CPU model
Eduardo Habkost [Tue, 6 Mar 2012 18:11:31 +0000 (15:11 -0300)]
add SandyBridge CPU model

This patches add the definition of a SandyBridge CPU model.

Summary of differences:

Flags present on actual hardware, but not on the added model definition:

- pbe, tm, ht, ss, acpi, vme, xTPR, tm2, eist, smx: host-specific
  features, not exposed to guest.
- ds, ds-cpl, dtes64, pdcm: emulation not supported by KVM (although it
  may be added in the future if implementing PMU virtualization)
- pcid, vmx, monitor: not emulated by Qemu/KVM right now.
- osxsave: set by the guest OS, not by Qemu.

Flags added, that were not present on Westmere model:

- xsave: already supported by Qemu
- avx, pclmulqdq: all new state the new instructions could use is
  handled by xsave state loading/saving code.
- tsc-deadline, x2apic, rdtscp: already supported by Qemu/KVM.

Below there's a comparison of the features on the current Westmere CPU
model, and the SandyBridge CPU model.

- The "full" line contains the flags found on actual hardware.
- The "missing" line shows the flags that are present on actual
  hardware, but not on the added SandyBridge model.
- The "new" line shows the flags that were not on the Westmere model,
  but are on SandyBridge.

feature_edx:
  Westmere:                 sse2 sse fxsr mmx         clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de     fpu
  full:        pbe tm ht ss sse2 sse fxsr mmx ds acpi clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pge msr tsc pse de vme fpu
  SandyBridge:              sse2 sse fxsr mmx         clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de     fpu
  missing:     pbe tm ht ss                   ds acpi                                                                         vme

feature_ecx:
  Westmere:                      aes              popcnt        sse4.2 sse4.1                cx16 ssse3                                                  sse3
  full:        avx osxsave xsave aes tsc-deadline popcnt x2apic sse4.2 sse4.1 pcid pdcm xTPR cx16 ssse3 tm2 eist smx vmx ds-cpl monitor dtes64 pclmulqdq sse3
  SandyBridge: avx         xsave aes tsc-deadline popcnt x2apic sse4.2 sse4.1                cx16 ssse3                                        pclmulqdq sse3
  missing:         osxsave                                                    pcid pdcm xTPR            tm2 eist smx vmx ds-cpl monitor dtes64
  new:         avx         xsave     tsc-deadline        x2apic                                                                                pclmulqdq

extfeature_edx:
  Westmere:    i64        nx syscall
  full:        i64 rdtscp nx syscall
  SandyBridge: i64 rdtscp nx syscall
  new:             rdtscp

extfeature_ecx:
  Westmere:    lahf_lm
  full:        lahf_lm
  SandyBridge: lahf_lm

Cc: "Dugger, Donald D" <donald.d.dugger@intel.com>
Cc: "Zhang, Xiantao" <xiantao.zhang@intel.com>
Acked-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoadd "tsc-deadline" flag name to feature_ecx table
Eduardo Habkost [Tue, 6 Mar 2012 18:11:30 +0000 (15:11 -0300)]
add "tsc-deadline" flag name to feature_ecx table

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqom: fix device hot-unplug
Paolo Bonzini [Tue, 28 Feb 2012 08:54:15 +0000 (09:54 +0100)]
qom: fix device hot-unplug

Property removal modifies the list, so it is not safe to continue
iteration.  We know anyway that each object can have only one
parent (see object_property_add_child), so exit after finding
the requested object.

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqdev: accept empty string properties
Paolo Bonzini [Tue, 28 Feb 2012 08:54:14 +0000 (09:54 +0100)]
qdev: accept empty string properties

These were stored as NULL due to wrong cut-and-paste from set_pointer.

Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
Tested-by: Gerhard Wiesinger <lists@wiesinger.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotest-coroutine: add performance test for nesting
Alex Barcelo [Thu, 16 Feb 2012 12:14:06 +0000 (13:14 +0100)]
test-coroutine: add performance test for nesting

The performance test will also check for nesting. It will do
a certain quantity of cycles, and each of one will do a depth
nesting process.

This is useful for benchmarking the creation of coroutines,
given that nesting is creation-intensive (and the other perf
test does not benchmark that).

Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agocoroutine: adding configure option for sigaltstack coroutine backend
Alex Barcelo [Tue, 28 Feb 2012 11:25:51 +0000 (12:25 +0100)]
coroutine: adding configure option for sigaltstack coroutine backend

It's possible to use sigaltstack backend with --with-coroutine=sigaltstack

v2: changed from enable/disable configure flags

Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agocoroutine: adding configure choose mechanism for coroutine backend
Alex Barcelo [Tue, 28 Feb 2012 11:25:50 +0000 (12:25 +0100)]
coroutine: adding configure choose mechanism for coroutine backend

Configure tries, as a default, ucontext functions for the
coroutines. But now the user can force another backend by
--with-coroutine=BACKEND option

v2: Using --with-coroutine=BACKEND instead of enable
disable individual configure options

Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agocoroutine: adding sigaltstack method (.c source)
Alex Barcelo [Tue, 28 Feb 2012 11:25:49 +0000 (12:25 +0100)]
coroutine: adding sigaltstack method (.c source)

This file is based in both coroutine-ucontext.c and
pth_mctx.c (from the GNU Portable Threads library).

The mechanism used to change stacks is the sigaltstack
function (variant 2 of the pth library).

v2: Some corrections. Moving global variables into
thread storage (CoroutineThreadState).

Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: Reduce number of I/O requests
Kevin Wolf [Fri, 2 Mar 2012 13:10:54 +0000 (14:10 +0100)]
qcow2: Reduce number of I/O requests

If the first part of a write request is allocated, but the second isn't
and it can be allocated so that the resulting area is contiguous, handle
it at once. This is a common case for sequential writes.

After this patch, alloc_cluster_offset() only checks if the clusters are
already allocated or how many new clusters can be allocated contigouosly.
The actual cluster allocation is split off into a new function
do_alloc_cluster_offset().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqcow2: Add qcow2_alloc_clusters_at()
Kevin Wolf [Fri, 2 Mar 2012 18:35:58 +0000 (19:35 +0100)]
qcow2: Add qcow2_alloc_clusters_at()

This function allows to allocate clusters at a given offset in the image
file. This is useful if you want to allocate the second part of an area
that must be contiguous.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqcow2: Factor out count_cow_clusters
Kevin Wolf [Fri, 2 Mar 2012 18:27:53 +0000 (19:27 +0100)]
qcow2: Factor out count_cow_clusters

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqmp: convert blockdev-snapshot-sync to a wrapper around transactions
Paolo Bonzini [Tue, 6 Mar 2012 17:55:59 +0000 (18:55 +0100)]
qmp: convert blockdev-snapshot-sync to a wrapper around transactions

Simplify the blockdev-snapshot-sync code and gain failsafe operation
by turning it into a wrapper around the new transaction command.  A new
option is also added matching "mode".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoadd mode field to blockdev-snapshot-sync transaction item
Paolo Bonzini [Tue, 6 Mar 2012 17:55:58 +0000 (18:55 +0100)]
add mode field to blockdev-snapshot-sync transaction item

The mode field lets a management application create the snapshot
destination outside QEMU.

Right now, the only modes are "existing" and "absolute-paths".  Mirroring
introduces "no-backing-file".  In the future "relative-paths" could be
implemented too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agorename blockdev-group-snapshot-sync
Paolo Bonzini [Tue, 6 Mar 2012 17:55:57 +0000 (18:55 +0100)]
rename blockdev-group-snapshot-sync

We will add other kinds of operation.  Prepare for this by adjusting
the schema.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqapi: complete implementation of unions
Paolo Bonzini [Tue, 6 Mar 2012 17:55:56 +0000 (18:55 +0100)]
qapi: complete implementation of unions

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agouse QSIMPLEQ_FOREACH_SAFE when freeing list elements
Paolo Bonzini [Tue, 6 Mar 2012 17:55:54 +0000 (18:55 +0100)]
use QSIMPLEQ_FOREACH_SAFE when freeing list elements

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoAdd 'make check-block'
Kevin Wolf [Fri, 9 Mar 2012 12:37:40 +0000 (13:37 +0100)]
Add 'make check-block'

Runs the full qemu-iotests suite for various image formats.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agomake check: Add qemu-iotests subset
Kevin Wolf [Thu, 8 Mar 2012 11:29:00 +0000 (12:29 +0100)]
make check: Add qemu-iotests subset

Run the 'quick' group from qemu-iotests during 'make check'.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: Mark some tests as quick
Kevin Wolf [Thu, 8 Mar 2012 11:26:52 +0000 (12:26 +0100)]
qemu-iotests: Mark some tests as quick

This creates a new test group 'quick' for some test case that take at
most a couple of seconds each, so that the group can be run during a
quick 'make check'

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: Add error messages in qcow2_truncate
Kevin Wolf [Tue, 6 Mar 2012 11:44:45 +0000 (12:44 +0100)]
qcow2: Add error messages in qcow2_truncate

qemu-img resize has some limitations with qcow2, but the user is only
told that "this image format does not support resize". Quite confusing,
so add some more detailed error_report() calls and change "this image
format" into "this image".

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoblock: handle -EBUSY in bdrv_commit_all()
Stefan Hajnoczi [Mon, 5 Mar 2012 18:10:11 +0000 (18:10 +0000)]
block: handle -EBUSY in bdrv_commit_all()

Monitor operations that manipulate image files must not execute while a
background job (like image streaming) is in progress.  This prevents
corruptions from happening when two pieces of code are manipulating the
image file without knowledge of each other.

The monitor "commit" command raises QERR_DEVICE_IN_USE when
bdrv_commit() returns -EBUSY but "commit all" has no error handling.
This is easy to fix, although note that we do not deliver a detailed
error about which device was busy in the "commit all" case.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: Add some tracing
Kevin Wolf [Thu, 1 Mar 2012 17:36:21 +0000 (18:36 +0100)]
qcow2: Add some tracing

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqed: do not evict in-use L2 table cache entries
Stefan Hajnoczi [Mon, 27 Feb 2012 13:16:01 +0000 (13:16 +0000)]
qed: do not evict in-use L2 table cache entries

The L2 table cache reduces QED metadata reads that would be required
when translating LBAs to offsets into the image file.  Since requests
execute in parallel it is possible to share an L2 table between multiple
requests.

There is a potential data corruption issue when an in-use L2 table is
evicted from the cache because the following situation occurs:

  1. An allocating write performs an update to L2 table "A".

  2. Another request needs L2 table "B" and causes table "A" to be
     evicted.

  3. A new read request needs L2 table "A" but it is not cached.

As a result the L2 update from #1 can overlap with the L2 fetch from #3.
We must avoid doing overlapping I/O requests here since the worst case
outcome is that the L2 fetch completes before the L2 update and yields
stale data.  In that case we would effectively discard the L2 update and
lose data clusters!

Thanks to Benoît Canet <benoit.canet@gmail.com> for extensive testing
and debugging which lead to discovery of this bug.

Reported-by: Benoît Canet <benoit.canet@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Tested-by: Benoît Canet <benoit.canet@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoGroup snapshot: Fix format name for backing file
Paolo Bonzini [Thu, 1 Mar 2012 11:21:43 +0000 (12:21 +0100)]
Group snapshot: Fix format name for backing file

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovga: add trace event for ppm_save
Alon Levy [Sun, 11 Mar 2012 16:11:27 +0000 (18:11 +0200)]
vga: add trace event for ppm_save

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoconsole: add some trace events
Alon Levy [Sun, 11 Mar 2012 16:11:26 +0000 (18:11 +0200)]
console: add some trace events

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agomaintainers: Add docs/tracing.txt to Tracing
Andreas Färber [Sat, 10 Mar 2012 12:37:34 +0000 (13:37 +0100)]
maintainers: Add docs/tracing.txt to Tracing

The topic of whether and by whom docs/tracing.txt is maintained was
brought up. It currently does not have an official maintainer.

Add it to the tracing section so that Stefan gets cc'ed on patches.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agodocs: correct ./configure line in tracing.txt
Jun Koi [Thu, 8 Mar 2012 08:24:52 +0000 (16:24 +0800)]
docs: correct ./configure line in tracing.txt

This patch corrects the configure's trace option in docs/tracing.txt.

Signed-off-by: Jun Koi <junkoi2004@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agotrace: make trace_thread_create() use its function arg
Jun Koi [Thu, 8 Mar 2012 06:20:37 +0000 (14:20 +0800)]
trace: make trace_thread_create() use its function arg

This patch makes trace_thread_create() to use its function arg to
initialize thread.  The other choice is to make this a function to use
void arg, but i prefer this way.

Signed-off-by: Jun Koi <junkoi2004@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agotracetool: Omit useless QEMU_*_ENABLED() check
Stefan Hajnoczi [Tue, 27 Sep 2011 08:00:22 +0000 (09:00 +0100)]
tracetool: Omit useless QEMU_*_ENABLED() check

SystemTap provides a "semaphore" that can optionally be tested before
executing a trace event.  The purpose of this mechanism is to skip
expensive tracing code when the trace event is disabled.

For example, some applications may have trace events that format or
convert strings for trace events.  This expensive processing should only
be done in the case where the trace event is enabled.

Since QEMU's generated trace events never have such special-purpose
code, there is no reason to add the semaphore check.

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agotrace: Provide a per-event status define for conditional compilation
Lluís Vilanova [Tue, 6 Dec 2011 16:38:15 +0000 (17:38 +0100)]
trace: Provide a per-event status define for conditional compilation

Adds a 'TRACE_${NAME}_ENABLED' preprocessor define for each tracing event in
"trace.h".

This lets the user conditionally compile code with a relatively high execution
cost that is only necessary when producing the tracing information for an event
that is enabled.

Note that events using this define will probably have the "disable" property by
default, in order to avoid such costs on regular builds.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoAdd missing const attributes for MemoryRegionOps
Stefan Weil [Sun, 5 Feb 2012 10:19:07 +0000 (10:19 +0000)]
Add missing const attributes for MemoryRegionOps

Most MemoryRegionOps already had the const attribute.
This patch adds it to the remaining ones.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotcg: Improve tcg_out_label and fix its usage for w64
Stefan Weil [Sat, 10 Mar 2012 18:59:04 +0000 (19:59 +0100)]
tcg: Improve tcg_out_label and fix its usage for w64

tcg_out_label is always called with a third argument of pointer type
which was casted to tcg_target_long.

These casts can be avoided by changing the prototype of tcg_out_label.

There was also a cast to long. For most hosts with
sizeof(long) == sizeof(tcg_target_long) == sizeof(void *) this did not
matter, but for w64 it was wrong. This is fixed now.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoconfigure: Test for libiberty.a (mingw32)
Stefan Weil [Sat, 10 Mar 2012 10:14:32 +0000 (11:14 +0100)]
configure: Test for libiberty.a (mingw32)

MinGW-w64 and some versions of MinGW32 don't provide libiberty.a,
so add this library only if it was found.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agow64: Don't redefine lseek, ftruncate
Stefan Weil [Sat, 10 Mar 2012 10:14:31 +0000 (11:14 +0100)]
w64: Don't redefine lseek, ftruncate

MinGW-w64 already defines lseek and ftruncate (and uses the 64 bit
variants). The conditional compilation avoids redefinitions
(which would be wrong) and compiler warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agocache-utils: Add missing include file for uintptr_t
Stefan Weil [Mon, 5 Mar 2012 20:15:19 +0000 (21:15 +0100)]
cache-utils: Add missing include file for uintptr_t

Commit 021ecd8b9db37927059f5d3234b51ed766706437 breaks the build for
PPC hosts because it uses uintptr_t without the necessary include file.

uintptr_t is defined in stdint.h, so add this include.

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agobuild: Include config-host.mak as soon as possible
Lluís Vilanova [Tue, 6 Mar 2012 18:50:38 +0000 (19:50 +0100)]
build: Include config-host.mak as soon as possible

Current code depends on variables defined in config-host.mak before it is
actually included.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Paul Brook <paul@codesourcery.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agogdbstub: Do not kill target in system emulation mode
Jan Kiszka [Tue, 6 Mar 2012 17:32:35 +0000 (18:32 +0100)]
gdbstub: Do not kill target in system emulation mode

Too many VM kittens were killed since 7d03f82f81. Another one just died
under my fat fingers.

When you quit a kgdb session, does the Linux kernel power off? Or when
you terminate gdb attached to a hardware debugger, does your board
vanish in space? No.

So let's stop terminating QEMU when the gdbstub receives a kill commando
in system emulation mode. Real termination can still be achieved via
"monitor quit". We keep the behavior for user mode emulation which is
arguably more like a gdbserver scenario.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-i386: Mask NX bit from cpu_get_phys_page_debug result
Jan Kiszka [Tue, 6 Mar 2012 14:22:02 +0000 (15:22 +0100)]
target-i386: Mask NX bit from cpu_get_phys_page_debug result

This was a long pending bug, now revealed by the assert in
phys_page_find that stumbled over the large page index returned by
cpu_get_phys_page_debug for NX-marked pages: We need to mask out NX and
all user-definable bits 52..62 from PDEs and the final PTE to avoid
corrupting physical addresses.

Reviewed-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoqapi-schema.json: fix comment for type ObjectPropretyInfo
Alon Levy [Mon, 5 Mar 2012 13:13:28 +0000 (15:13 +0200)]
qapi-schema.json: fix comment for type ObjectPropretyInfo

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi-schema: fix typos and explain 'spice' auth
Alon Levy [Mon, 5 Mar 2012 13:13:27 +0000 (15:13 +0200)]
qapi-schema: fix typos and explain 'spice' auth

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqjson.h: include compiler.h for GCC_FMT_ATTR
Alon Levy [Fri, 24 Feb 2012 21:22:03 +0000 (23:22 +0200)]
qjson.h: include compiler.h for GCC_FMT_ATTR

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Fri, 9 Mar 2012 18:30:20 +0000 (12:30 -0600)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  configure: Quote the configure args printed in config.log
  osdep: Remove local definition of macro offsetof
  libcacard: Spelling and grammar fixes in documentation
  Spelling fixes in comments (it's -> its)
  vnc: Add break statement
  libcacard: Use format specifier %u instead of %d for unsigned values
  Fix sign of sscanf format specifiers
  block/vmdk: Fix warning from splint (comparision of unsigned value)
  qmp: Fix spelling fourty -> forty
  qom: Fix spelling in documentation
  sh7750: Remove redundant 'struct' from MemoryRegionOps

12 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Fri, 9 Mar 2012 18:29:55 +0000 (12:29 -0600)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

* qemu-kvm/uq/master:
  kvm: fill in padding to help valgrind
  kvm: x86: Add user space part for in-kernel i8254
  kvm: Add kvm_has_pit_state2 helper
  i8254: Open-code timer restore
  i8254: Factor out base class for KVM reuse