]> git.proxmox.com Git - qemu.git/log
qemu.git
10 years agoxics: Implement H_IPOLL
Benjamin Herrenschmidt [Thu, 26 Sep 2013 06:18:45 +0000 (16:18 +1000)]
xics: Implement H_IPOLL

This adds support for the H_IPOLL hypercall which the guest
uses to poll for a pending interrupt. This hypercall is
mandatory for PAPR+ and there is no way for the guest to
detect whether it is supported or not so just add it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics-kvm: Support for in-kernel XICS interrupt controller
David Gibson [Thu, 26 Sep 2013 06:18:44 +0000 (16:18 +1000)]
xics-kvm: Support for in-kernel XICS interrupt controller

Recent (host) kernels support emulating the PAPR defined "XICS" interrupt
controller system within KVM.  This patch allows qemu to initialize and
configure the in-kernel XICS, and keep its state in sync with qemu's XICS
state as necessary.

This should give considerable performance improvements.  e.g. on a simple
IPI ping-pong test between hardware threads, using qemu XICS gives us
around 5,000 irqs/second, whereas the in-kernel XICS gives us around
70,000 irqs/s on the same hardware configuration.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[Mike Qiu <qiudayu@linux.vnet.ibm.com>: fixed mistype which caused ics_set_kvm_state() to fail]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: add cpu_setup callback
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:43 +0000 (16:18 +1000)]
xics: add cpu_setup callback

This adds a cpu_setup callback to the XICS device class (as XICS-KVM
will do it different), xics_cpu_setup() will call it if it is set.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: split to xics and xics-common
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:42 +0000 (16:18 +1000)]
xics: split to xics and xics-common

The upcoming XICS-KVM support will use bits of emulated XICS code.
So this introduces new level of hierarchy - "xics-common" class. Both
emulated XICS and XICS-KVM will inherit from it and override class
callbacks when required.

The new "xics-common" class implements:
1. replaces static "nr_irqs" and "nr_servers" properties with
the dynamic ones and adds callbacks to be executed when properties
are set.
2. xics_cpu_setup() callback renamed to xics_common_cpu_setup() as
it is a common part for both XICS'es
3. xics_reset() renamed to xics_common_reset() for the same reason.

The emulated XICS changes:
1. the part of xics_realize() which creates ICPs is moved to
the "nr_servers" property callback as realize() is too late to
create/initialize devices and instance_init() is too early to create
devices as the number of child devices comes via the "nr_servers"
property.
2. added ics_initfn() which does a little part of what xics_realize() did.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: add missing const specifiers to TypeInfo
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:41 +0000 (16:18 +1000)]
xics: add missing const specifiers to TypeInfo

This adds missing const specifiers to ICS and ICP TypeInfo's.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: convert init() to realize()
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:40 +0000 (16:18 +1000)]
xics: convert init() to realize()

This fixes XICS according new QOM rules.

This converts ICS's init() callbacks to realize().

This converts legacy qdev_init_nofail() to property_set(realized).

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: add pre_save/post_load dispatchers
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:39 +0000 (16:18 +1000)]
xics: add pre_save/post_load dispatchers

The upcoming support of in-kernel XICS will redefine migration callbacks
for both ICS and ICP so classes and callback pointers are added.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: replace fprintf with error_report
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:38 +0000 (16:18 +1000)]
xics: replace fprintf with error_report

This replaces old-style fprintf with new style error_report.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: move cpu_setup after kvmppc_set_papr
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:37 +0000 (16:18 +1000)]
spapr: move cpu_setup after kvmppc_set_papr

This moves the xics_cpu_setup() call after kvmppc_set_papr()
in order to get VCPUs initialized as this is required by upcoming
XICS-KVM.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: move reset and cpu_setup
Alexey Kardashevskiy [Thu, 26 Sep 2013 06:18:36 +0000 (16:18 +1000)]
xics: move reset and cpu_setup

This simple change makes following patches nicer.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN
David Gibson [Thu, 26 Sep 2013 06:18:35 +0000 (16:18 +1000)]
target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN

Recent PowerKVM allows the kernel to intercept some RTAS calls from the
guest directly.  This is used to implement the more efficient in-kernel
XICS for example.  qemu is still responsible for assigning the RTAS token
numbers however, and needs to tell the kernel which RTAS function name is
assigned to a given token value.  This patch adds a convenience wrapper for
the KVM_PPC_RTAS_DEFINE_TOKEN ioctl() which is used for this purpose.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr-rtas: fix h_rtas parameters reading
Alexey Kardashevskiy [Fri, 27 Sep 2013 08:10:18 +0000 (18:10 +1000)]
spapr-rtas: fix h_rtas parameters reading

On the real hardware, RTAS is called in real mode and therefore
top 4 bits of the address passed in the call are ignored.
So does the patch.

This converts h_rtas() to use existing rtas_ld() handlers.

This fixed rtas_ld()/rtas_st() to ignore top 4 bits.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Add ibm, purr property on power7 and newer
Alexey Kardashevskiy [Fri, 27 Sep 2013 08:11:51 +0000 (18:11 +1000)]
spapr: Add ibm, purr property on power7 and newer

PAPR+ says that no "ibm,purr" tells the guest that H_PURR is not
supported. However some guests still try calling H_PURR on POWER7 unless
the property is present and equal to 0. This adds the property for CPUs
supporting the PURR special register.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: increase temporary fdt buffer size
Alexey Kardashevskiy [Tue, 24 Sep 2013 05:59:55 +0000 (15:59 +1000)]
spapr: increase temporary fdt buffer size

At the moment the size of the buffer is set to 64K which is
enough for approximately 150 VCPUs which is not the limit.

This increases the buffer up to 256K which allows having
a tree for approximately 600 VCPUs which is way beyond the real
number we need.

As only the real size of the tree is copied to the guest, there
will be no impact on existing configurations.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoPPC: Fix L2CR write accesses
Alexander Graf [Wed, 25 Sep 2013 13:41:12 +0000 (15:41 +0200)]
PPC: Fix L2CR write accesses

Commit 2345f1c01 was supposed to render L2CR writes into noops. Instead,
it made them illegal instruction traps which apparently didn't confuse
XNU, but can easily confuse other OSs.

Fix it up by actually doing nothing when we write to L2CR.

Reported-by: Julio Guerra <guerr@julio.in>
Signed-off-by: Alexander Graf <agraf@suse.de>
Tested-by: Julio Guerra <guerr@julio.in>
10 years agotarget-ppc: Little Endian Correction to Load/Store Vector Element
Tom Musta [Wed, 25 Sep 2013 07:42:46 +0000 (17:42 +1000)]
target-ppc: Little Endian Correction to Load/Store Vector Element

The Load Vector Element (lve*x) and Store Vector Element (stve*x)
instructions not only byte-swap in Little Endian mode, they also
invert the element that is accessed. For example, the RTL for
lvehx contains this:

     eb <-- EA[60:63]
     if Big-Endian byte ordering then
         VRT[8*eb:8*eb+15] <-- MEM(EA,2)
     else
         VRT[112-(8*eb):127-(8*eb)] <-- MEM(EA,2)

This patch adds the element inversion, as described in the last line
of the RTL.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoppc: Add CFAR, DAR and DSISR to the dictionary of printable registers
Tom Musta [Wed, 25 Sep 2013 07:41:13 +0000 (17:41 +1000)]
ppc: Add CFAR, DAR and DSISR to the dictionary of printable registers

The CFAR, DAR and DSISR registers are currently missing from the
dictionary of registers that may be printed in the QEMU console.
These are interesting registers when debugging.  With this patch,
the following commands work properly:

     (qemu) print $cfar
     (qemu) print $dar
     (qemu) print $dsisr

Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agopseries: Fix loading of little endian kernels
Benjamin Herrenschmidt [Wed, 25 Sep 2013 07:40:15 +0000 (17:40 +1000)]
pseries: Fix loading of little endian kernels

Try loading the kernel as little endian if it fails big endian.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agopseries: Update SLOF firmware image
Alexey Kardashevskiy [Tue, 27 Aug 2013 03:42:47 +0000 (13:42 +1000)]
pseries: Update SLOF firmware image

This has reworked USB OHCI and adds support of USB EHCI,
VIRTIO-SCSI and various fixes (IBM VSCSI, VGA and more).

The full list of fixes is:
*  usb-ohci: Convert td-phys every time to td-virt
*  usb-storage: Fix cbwflags field
*  Add -fno-strict-aliasing in global CFLAGS
*  usb: fix various issues found with js2x
*  Move hex64-{decode,encode}-unit to node.fs
*  usb: Use separate in-memory endian swap
*  usb-ohci: collect TDs from done list
*  js2x: more fixes
*  js2x: Fix build of takeover image
*  js2x: use new usb stack
*  usb-ohci: Use proper memory barriers always
*  usb: Fix a couple of warnings
*  Fix $cat-instance-unit
*  Cache phandle of /chosen
*  Use root.fs on qemu as well
*  usb-ehci: Add ehci handshake
*  usb: add mb for write accessors
*  usb-ohci: add missing memory barriers
*  usb-ohci: suspend the controller in exit code path
*  usb-ohci: Add a reset when closing the OHCI
*  usb: Use proper accessors for MMIO and separate in-memory endian swap
*  Use a global definition of sync() and mb()
*  net-snk: Remove exception handling
*  usb: unmap buffers
*  slof: call quiesce on closing of stdin
*  usb-kbd: accept "s" to drop to OF prompt
*  USB storage driver
*  usb-ohci: add Bulk transfer support
*  usb-ehci: Add bulk support
*  usb-core: add usb bulk support
*  USB generic hub device driver
*  usb-ehci: setup new device
*  usb-ehci: Check ehci ports
*  usb-ehci: initialize controller
*  USB keyboard driver
*  usb-core: setup new device
*  usb-core: create dev pool allocation
*  usb-ohci: implement ohci send control
*  usb-core: usb send control
*  usb-core: implement usb_{get,put}_pipe routines
*  usb-ohci: allocate pipe pool
*  usb-ohci: reset, init and check-ports
*  Add standard header stdbool.h
*  usb-slof: forth support routines for C
*  usb-ehci: Add USB EHCI skeleton
*  usb-core: Add register accessor functions
*  Use __builtin_bswap routines for endianness swapping
*  usb-core: hcd registration and query routines
*  usb-core: adding generic dev-hci.fs
*  usb-core: registration and makefiles
*  Add new USB code
*  Remove old usb code
*  vga: fix hcall-invert-screen and hcall-blink-screen
*  Enumerate disk/cdrom aliases for multiple disks or cdroms
*  scsi: unify scsi probing code
*  vscsi: generalizing probe code
*  virtio-scsi: iterate through targets
*  scsi: unify and use make-disk-alias
*  nvram: remove unnecessary prints
*  Add hack to client interface finddevice of "/memory"
*  scsi: Fix cdrom boot crash when no medium present
*  Look for /memory@0, not just /memory
*  Fix instance>qname crashing when displaying instance arguments
*  Fix js2x build
*  scsi-disk: Bound check read-blocks
*  Fix off by one error in scsi-disk get-capacity
*  scsi: fix report-luns handling
*  SLOF: virtio-scsi block driver code
*  scsi: Move bits of vio-vscsi.fs to a common helpers file
*  scsi: Move scsi-disk.fs to a generic place
*  SLOF: virtio-scsi helper routines
*  SLOF: virtio-scsi - add pci device file
*  iso9660: Don't constantly reallocate the read buffer
*  vscsi: Sanitize interface between scsi-disk.fs and vio-vscsi.fs
*  vio-vscsi: Rework vio-vscsi support
*  virtio: Add a virtio-set-qaddr helper
*  disk-label: Allocate 4096 bytes for 4k block devices
*  disk-label: Increase the max size of the PReP boot partition
*  Make load-base a real environment variable
*  vio-vscsi: Switch to using a wildcard "disk" node and make scsi-disk generic
*  Fix disk-label package to use proper instance path
*  Increase size of catpad
*  Fix instance>path to contain unit address for wildcard nodes
*  Fix handling of wildcard nodes in open-dev
*  vio-vscsi: Get CRQ on open and release on close

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoqemu-iotests: Test for loading VM state from qcow2
Max Reitz [Thu, 24 Oct 2013 18:24:43 +0000 (20:24 +0200)]
qemu-iotests: Test for loading VM state from qcow2

Add a test for saving a VM state from a qcow2 image and loading it back
(with having restarted qemu in between); this should work without any
problems.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agohw/microblaze: Add support for loading initrd images
Edgar E. Iglesias [Sun, 5 May 2013 09:06:37 +0000 (11:06 +0200)]
hw/microblaze: Add support for loading initrd images

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agohw/microblaze: Indentation cleanups
Edgar E. Iglesias [Sun, 5 May 2013 08:52:41 +0000 (10:52 +0200)]
hw/microblaze: Indentation cleanups

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: At swx, check that the reserved word is unmodified
Edgar E. Iglesias [Wed, 23 Oct 2013 14:54:31 +0000 (16:54 +0200)]
microblaze: At swx, check that the reserved word is unmodified

This improves the reservation check for system emulation, making
it possible to catch stores that modify reserved word.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Turn res_addr into a tcg global
Edgar E. Iglesias [Wed, 23 Oct 2013 14:44:08 +0000 (16:44 +0200)]
microblaze: Turn res_addr into a tcg global

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Move the saving of the reservation addr into gen_load
Edgar E. Iglesias [Wed, 23 Oct 2013 11:58:08 +0000 (13:58 +0200)]
microblaze: Move the saving of the reservation addr into gen_load

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Improve src
Edgar E. Iglesias [Thu, 24 Oct 2013 17:18:28 +0000 (19:18 +0200)]
microblaze: Improve src

Microblaze carry is mirrored in MSR[31], pick it directly from
there. Also, no need to mask cpu_R[dc->ra] when calling
write_carry.

15% improvement in linux-user src loops.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Improve srl
Edgar E. Iglesias [Thu, 24 Oct 2013 17:03:44 +0000 (19:03 +0200)]
microblaze: Improve srl

write_carry only looks at bit zero, no need to mask out the others.

Meassured a 12% speed improvement in linux-user srl loops.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Simplify andn by using tcg_gen_andc
Edgar E. Iglesias [Thu, 24 Oct 2013 16:49:46 +0000 (18:49 +0200)]
microblaze: Simplify andn by using tcg_gen_andc

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Make write_carryi input a boolean
Edgar E. Iglesias [Thu, 24 Oct 2013 10:49:05 +0000 (12:49 +0200)]
microblaze: Make write_carryi input a boolean

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Clarify expected input of write_carry
Edgar E. Iglesias [Thu, 24 Oct 2013 20:31:22 +0000 (22:31 +0200)]
microblaze: Clarify expected input of write_carry

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agoblock/vpc: check that the image has not been truncated
Peter Lieven [Thu, 24 Oct 2013 07:16:03 +0000 (09:16 +0200)]
block/vpc: check that the image has not been truncated

this adds a check that a dynamic VHD file has not been
accidently truncated (e.g. during transfer or upload).

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqemu-img: add special exit code if bdrv_check is not supported
Peter Lieven [Thu, 24 Oct 2013 06:53:34 +0000 (08:53 +0200)]
qemu-img: add special exit code if bdrv_check is not supported

currently it is not possible to distinguish by exitcode if there
has been an error or if bdrv_check is not supported by the image
format. Change the exitcode from 1 to 63 for the latter case.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqcow2: Unset zero_beyond_eof in save_vmstate
Max Reitz [Sun, 20 Oct 2013 19:52:35 +0000 (21:52 +0200)]
qcow2: Unset zero_beyond_eof in save_vmstate

Saving the VM state is done using bdrv_pwrite. This function may perform
a read-modify-write, which in this case results in data being read from
beyond the end of the virtual disk. Since we are actually trying to
access an area which is not a part of the virtual disk, zero_beyond_eof
has to be set to false before performing the partial write, otherwise
the VM state may become corrupted.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqcow2: Restore total_sectors value in save_vmstate
Max Reitz [Sun, 20 Oct 2013 18:28:20 +0000 (20:28 +0200)]
qcow2: Restore total_sectors value in save_vmstate

Since df2a6f29a5, bdrv_co_do_writev increases the total_sectors value of
a growable block devices on writes after the current end. This leads to
the virtual disk apparently growing in qcow2_save_vmstate, which in turn
affects the disk size captured by the internal snapshot taken directly
afterwards through e.g. the HMP savevm command. Such a "grown" snapshot
cannot be loaded after reopening the qcow2 image, since its disk size
differs from the actual virtual disk size (writing a VM state does not
actually increase the virtual disk size).

Fix this by restoring total_sectors at the end of qcow2_save_vmstate.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoaudio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second
Hans de Goede [Wed, 9 Oct 2013 19:33:44 +0000 (21:33 +0200)]
audio: honor QEMU_AUDIO_TIMER_PERIOD instead of waking up every *nano* second

Now that we no longer have MIN_REARM_TIMER_NS a bug in the audio subsys has
clearly shown it self by trying to make a timer fire every nano second.

Note we have a similar problem in 1.6, 1.5 and older but there
MIN_REARM_TIMER_NS limits the wakeups caused by audio being active to
4000 times / second. This still causes a host cpu load of 50 % for simply
playing audio, where as with this patch git master is at 13%, so we should
backport this to 1.5 and 1.6 too.

Note this will not apply to 1.5 and 1.6 as is.

Cc: qemu-stable@nongnu.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-hcd-xhci: Update endpoint context dequeue pointer for streams too
Hans de Goede [Tue, 8 Oct 2013 19:58:12 +0000 (21:58 +0200)]
usb-hcd-xhci: Update endpoint context dequeue pointer for streams too

With streams the endpoint context dequeue pointer should point to the
dequeue value for the currently active stream.

At least Linux guests expect it to point to value set by an set_ep_dequeue
upon completion of the set_ep_dequeue (before kicking the ep).

Otherwise the Linux kernel will complain (and things won't work):

xhci_hcd 0000:00:05.0: Mismatch between completed Set TR Deq Ptr command & xHCI internal state.
xhci_hcd 0000:00:05.0: ep deq seg = ffff8800366f0880, deq ptr = ffff8800366ec010

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-hcd-xhci: Report completion of active transfer with CC_STOPPED on ep stop
Hans de Goede [Tue, 8 Oct 2013 19:58:11 +0000 (21:58 +0200)]
usb-hcd-xhci: Report completion of active transfer with CC_STOPPED on ep stop

As we should per the XHCI spec "4.6.9 Stop Endpoint".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-hcd-xhci: Remove unused cancelled member from XHCITransfer
Hans de Goede [Tue, 8 Oct 2013 19:58:10 +0000 (21:58 +0200)]
usb-hcd-xhci: Remove unused cancelled member from XHCITransfer

Since qemu's USB model is geared towards emulated devices cancellation
is instanteneous, so no need to wait for cancellation to complete, as
such there is no wait for cancellation code, and the cancelled bool
as well as the bogus comment about it can be removed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-hcd-xhci: Remove unused sstreamsm member from XHCIStreamContext
Hans de Goede [Tue, 8 Oct 2013 19:58:09 +0000 (21:58 +0200)]
usb-hcd-xhci: Remove unused sstreamsm member from XHCIStreamContext

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-host-libusb: Detach kernel drivers earlier
Hans de Goede [Tue, 8 Oct 2013 19:58:08 +0000 (21:58 +0200)]
usb-host-libusb: Detach kernel drivers earlier

If we detach the kernel drivers on the first set_config, then they will
be still attached when the device gets its initial reset. Causing the drivers
to re-initialize the device after the reset, dirtying the device state.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-host-libusb: Configuration 0 may be a valid configuration
Hans de Goede [Tue, 8 Oct 2013 19:58:07 +0000 (21:58 +0200)]
usb-host-libusb: Configuration 0 may be a valid configuration

Quoting from: linux/Documentation/ABI/stable/sysfs-bus-usb:

Note that some devices, in violation of the USB spec, have a
configuration with a value equal to 0. Writing 0 to
bConfigurationValue for these devices will install that
configuration, rather then unconfigure the device.

So don't compare the configuration value against 0 to check for unconfigured
devices, instead check for a LIBUSB_ERROR_NOT_FOUND return from
libusb_get_active_config_descriptor().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-host-libusb: Fix reset handling
Hans de Goede [Tue, 8 Oct 2013 19:58:06 +0000 (21:58 +0200)]
usb-host-libusb: Fix reset handling

The guest will issue an initial device reset when the device is attached, but
since the current usb-host-libusb code only actually does the reset when
udev->configuration != 0, and on attach the device is not yet configured,
the reset gets ignored. This means that the device gets passed to the guest
in an unknown state, which is not good.

The udev->configuration check is there because of the release / claim
interfaces done around the libusb_device_reset call, but these are not
necessary. If interfaces are claimed when libusb_device_reset gets called
libusb will release + reclaim them itself.

The usb_host_ep_update call also is not necessary. If the reset succeeds the
original config and interface alt settings will be restored.

Last if the reset fails, that means the device has either disconnected or
morphed into an another device and has been completely re-enumerated,
so it is treated by the host as a new device and our handle is invalid,
so on reset failure we need to call usb_host_nodev().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoqapi: fix documentation example
Eric Blake [Sat, 19 Oct 2013 16:52:33 +0000 (17:52 +0100)]
qapi: fix documentation example

The QMP wire format uses "", not '', around strings.

* docs/qapi-code-gen.txt: Fix typo.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agomonitor: eliminate monitor_event_state_lock
Paolo Bonzini [Wed, 16 Oct 2013 17:17:08 +0000 (19:17 +0200)]
monitor: eliminate monitor_event_state_lock

This lock does not protect anything that the BQL does not already
protect.  Furthermore, with -nodefaults and no monitor, the mutex
is not initialized but monitor_protocol_event_queue is called
anyway, which causes a crash under mingw (and only works by luck.
under Linux or other POSIX OSes).

Reported-by: Orx Goshen <orx.goshen@intel.com>
Cc: Daniel Berrange <berrange@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:03:24 +0000 (10:03 -0700)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

# By Paolo Bonzini (2) and Jan Kiszka (1)
# Via Gleb Natapov
* qemu-kvm/uq/master:
  kvmvapic: Prevent reading beyond the end of guest RAM
  x86: cpuid: reconstruct leaf 0Dh data
  x86: fix migration from pre-version 12

Message-id: 1382108641-4862-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'stefanha/net' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:02:48 +0000 (10:02 -0700)]
Merge remote-tracking branch 'stefanha/net' into staging

# By Amos Kong
# Via Stefan Hajnoczi
* stefanha/net:
  net/rtl8139: update network information when macaddr is changed in guest
  net/e1000: update network information when macaddr is changed in guest
  net: update nic info during device reset

Message-id: 1382103314-21608-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'stefanha/block' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:02:14 +0000 (10:02 -0700)]
Merge remote-tracking branch 'stefanha/block' into staging

# By Fam Zheng (3) and others
# Via Stefan Hajnoczi
* stefanha/block:
  vmdk: fix VMFS extent parsing
  vmdk: Only read cid from image file when opening
  virtio: Remove unneeded memcpy
  block/raw-win32: Always use -errno in hdev_open
  blockdev: fix cdrom read_only flag
  sd: Avoid access to NULL BlockDriverState
  hmp: drop bogus "[not inserted]"

Message-id: 1382105915-27735-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'bonzini/iommu-for-anthony' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:01:49 +0000 (10:01 -0700)]
Merge remote-tracking branch 'bonzini/iommu-for-anthony' into staging

# By Paolo Bonzini (10) and others
# Via Paolo Bonzini
* bonzini/iommu-for-anthony:
  exec: remove qemu_safe_ram_ptr
  icount: make it thread-safe
  icount: document (future) locking rules for icount
  icount: prepare the code for future races in calling qemu_clock_warp
  icount: reorganize icount_warp_rt
  icount: use cpu_get_icount() directly
  timer: add timer_mod_anticipate and timer_mod_anticipate_ns
  timer: extract timer_mod_ns_locked and timerlist_rearm
  timer: make qemu_clock_enable sync between disable and timer's cb
  qemu-thread: add QemuEvent
  timer: protect timers_state's clock with seqlock
  seqlock: introduce read-write seqlock
  vga: Mark relevant portio lists regions as coalesced MMIO flushing
  cirrus: Mark vga io region as coalesced MMIO flushing
  portio: Allow to mark portio lists as coalesced MMIO flushing
  compatfd: switch to QemuThread
  memory: fix 128 arithmetic in info mtree

Message-id: 1382024935-28297-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'bonzini/configure' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:01:37 +0000 (10:01 -0700)]
Merge remote-tracking branch 'bonzini/configure' into staging

# By Peter Maydell (3) and Ákos Kovács (2)
# Via Paolo Bonzini
* bonzini/configure:
  ui/Makefile.objs: delete unnecessary cocoa.o dependency
  default-configs/: CONFIG_GDBSTUB_XML removed
  Makefile.target: CONFIG_NO_* variables removed
  rules.mak: New string testing functions
  rules.mak: New logical functions for handling y/n values

10 years agoMerge remote-tracking branch 'spice/spice.v75' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:01:21 +0000 (10:01 -0700)]
Merge remote-tracking branch 'spice/spice.v75' into staging

# By Gerd Hoffmann (2) and others
# Via Gerd Hoffmann
* spice/spice.v75:
  spice: fix multihead support
  spice-display: add display channel id to the debug messages.
  Fix VNC SASL authentication when using a QXL device
  spice: replace use of deprecated API

Message-id: 1382006760-19388-1-git-send-email-kraxel@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'filippov/tags/20131015-xtensa' into staging
Anthony Liguori [Fri, 18 Oct 2013 17:01:08 +0000 (10:01 -0700)]
Merge remote-tracking branch 'filippov/tags/20131015-xtensa' into staging

xtensa queue 2013-10-15

# gpg: Signature made Tue 15 Oct 2013 06:27:41 AM PDT using RSA key ID F83FA044
# gpg: Can't check signature: public key not found

# By Max Filippov
# Via Max Filippov
* filippov/tags/20131015-xtensa:
  target-xtensa: add in_asm logging

Message-id: 1381844297-1728-1-git-send-email-jcmvbkbc@gmail.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agovmdk: fix VMFS extent parsing
Fam Zheng [Fri, 18 Oct 2013 07:07:33 +0000 (15:07 +0800)]
vmdk: fix VMFS extent parsing

The VMFS extent line in description file doesn't have start offset as
FLAT lines does, and it should be defaulted to 0. The flat_offset
variable is initialized to -1, so we need to set it in this case.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agovmdk: Only read cid from image file when opening
Fam Zheng [Fri, 18 Oct 2013 05:17:19 +0000 (13:17 +0800)]
vmdk: Only read cid from image file when opening

Previously cid of parent is parsed from image file for every IO request.
We already have L1/L2 cache and don't have assumption that parent image
can be updated behind us, so remove this to get more efficiency.

The parent CID is checked only for once after opening.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agonet/rtl8139: update network information when macaddr is changed in guest
Amos Kong [Thu, 17 Oct 2013 07:02:50 +0000 (15:02 +0800)]
net/rtl8139: update network information when macaddr is changed in guest

rtl8139 has same problem as e1000, nic info isn't updated when macaddr
is changed in guest.

This patch updates the nic info when the last bit of macaddr is written.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agonet/e1000: update network information when macaddr is changed in guest
Amos Kong [Thu, 17 Oct 2013 07:02:49 +0000 (15:02 +0800)]
net/e1000: update network information when macaddr is changed in guest

If we change macaddr in guest by 'ifconfig eth0 hw ether 12:12:12:34:35:36',
the mac register of e1000 is already updated, but we don't update
network information in qemu. Therefor, the information in monitor
is wrong.

This patch updates nic info when the second part of macaddr is written.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agonet: update nic info during device reset
Amos Kong [Thu, 17 Oct 2013 08:38:34 +0000 (16:38 +0800)]
net: update nic info during device reset

macaddr is reset during device reset, but nic info
isn't updated, this problem exists in e1000 & rtl8139

Signed-off-by: Amos Kong <akong@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agovirtio: Remove unneeded memcpy
Stefan Weil [Thu, 17 Oct 2013 19:23:26 +0000 (21:23 +0200)]
virtio: Remove unneeded memcpy

Report from valgrind:

==19521== Source and destination overlap in memcpy(0x31d38938, 0x31d38938, 64)
==19521==    at 0x4A0A343: memcpy@@GLIBC_2.14 (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19521==    by 0x42774E: virtio_blk_device_init (virtio-blk.c:686)
==19521==    by 0x46EE9E: virtio_device_init (virtio.c:1158)
==19521==    by 0x25405E: device_realize (qdev.c:178)
==19521==    by 0x2559B5: device_set_realized (qdev.c:699)
==19521==    by 0x3A819B: property_set_bool (object.c:1315)
==19521==    by 0x3A6CE0: object_property_set (object.c:803)

Valgrind is right: blk == &s->blks, so it is a memcpy of 64 byte with
source == destination which can be removed.

Reported-by: Dave Airlie <airlied@gmail.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoexec: remove qemu_safe_ram_ptr
Paolo Bonzini [Mon, 9 Sep 2013 15:49:45 +0000 (17:49 +0200)]
exec: remove qemu_safe_ram_ptr

This is not needed since the RAM list is not modified anymore by
qemu_get_ram_ptr.  Replace it with qemu_get_ram_block.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoicount: make it thread-safe
Paolo Bonzini [Thu, 3 Oct 2013 13:17:25 +0000 (15:17 +0200)]
icount: make it thread-safe

This lets threads other than the I/O thread use vm_clock even in -icount mode.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoicount: document (future) locking rules for icount
Paolo Bonzini [Mon, 7 Oct 2013 15:18:15 +0000 (17:18 +0200)]
icount: document (future) locking rules for icount

Reviewed-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoicount: prepare the code for future races in calling qemu_clock_warp
Paolo Bonzini [Mon, 7 Oct 2013 15:30:02 +0000 (17:30 +0200)]
icount: prepare the code for future races in calling qemu_clock_warp

Computing the deadline of all vm_clocks is somewhat expensive and calls
out to qemu-timer.c; two reasons not to do it in the seqlock's write-side
critical section.  This however opens the door for races in setting and
reading vm_clock_warp_start.

To plug them, we need to cover the case where a new deadline slips in
between the call to qemu_clock_deadline_ns_all and the actual modification
of the icount_warp_timer.  Restrict changes to vm_clock_warp_start and
the icount_warp_timer's expiration time, to only move them back (which
would simply cause an early wakeup).

If a vm_clock timer is cancelled while CPUs are idle, this might cause the
icount_warp_timer to fire unnecessarily.  This is not a problem, after it
fires the timer becomes inactive and the next call to timer_mod_anticipate
will be precise.

In addition to this, we must deactivate the icount_warp_timer _before_
checking whether CPUs are idle.  This way, if the "last" CPU becomes idle
during the call to timer_del we will still set up the icount_warp_timer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoicount: reorganize icount_warp_rt
Paolo Bonzini [Mon, 7 Oct 2013 15:26:07 +0000 (17:26 +0200)]
icount: reorganize icount_warp_rt

To prepare for future code changes, move the increment of qemu_icount_bias
outside the "if" statement.

Also, hoist outside the if the check for timers that expired due to the
"warping".  The check is redundant when !runstate_is_running(), but
doing it this way helps because the code that increments qemu_icount_bias
will be a critical section.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoicount: use cpu_get_icount() directly
Paolo Bonzini [Mon, 7 Oct 2013 15:21:51 +0000 (17:21 +0200)]
icount: use cpu_get_icount() directly

This will help later when we will have to place these calls in
a critical section, and thus call a version of cpu_get_icount()
that does not take the lock.

Reviewed-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotimer: add timer_mod_anticipate and timer_mod_anticipate_ns
Paolo Bonzini [Thu, 3 Oct 2013 13:11:43 +0000 (15:11 +0200)]
timer: add timer_mod_anticipate and timer_mod_anticipate_ns

These let a user anticipate the deadline of a timer, atomically with
other sites that call the function.  This helps avoiding complicated
lock hierarchies.

Reviewed-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotimer: extract timer_mod_ns_locked and timerlist_rearm
Paolo Bonzini [Thu, 3 Oct 2013 13:06:39 +0000 (15:06 +0200)]
timer: extract timer_mod_ns_locked and timerlist_rearm

These will be reused in timer_mod_anticipate functions.

Reviewed-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotimer: make qemu_clock_enable sync between disable and timer's cb
Liu Ping Fan [Wed, 25 Sep 2013 06:21:00 +0000 (14:21 +0800)]
timer: make qemu_clock_enable sync between disable and timer's cb

After disabling the QemuClock, we should make sure that no QemuTimers
are still in flight. To implement that with light overhead, we resort
to QemuEvent. The caller of disabling will wait on QemuEvent of each
timerlist.

Note, qemu_clock_enable(foo,false) can _not_ be called from timer's cb.
Also, the callers of qemu_clock_enable() should be protected by the BQL.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoqemu-thread: add QemuEvent
Paolo Bonzini [Wed, 25 Sep 2013 06:20:59 +0000 (14:20 +0800)]
qemu-thread: add QemuEvent

This emulates Win32 manual-reset events using futexes or conditional
variables.  Typical ways to use them are with multi-producer,
single-consumer data structures, to test for a complex condition whose
elements come from different threads:

    for (;;) {
        qemu_event_reset(ev);
        ... test complex condition ...
        if (condition is true) {
            break;
        }
        qemu_event_wait(ev);
    }

Or more efficiently (but with some duplication):

    ... evaluate condition ...
    while (!condition) {
        qemu_event_reset(ev);
        ... evaluate condition ...
        if (!condition) {
            qemu_event_wait(ev);
            ... evaluate condition ...
        }
    }

QemuEvent provides a very fast userspace path in the common case when
no other thread is waiting, or the event is not changing state.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotimer: protect timers_state's clock with seqlock
Liu Ping Fan [Wed, 25 Sep 2013 06:20:58 +0000 (14:20 +0800)]
timer: protect timers_state's clock with seqlock

QEMU_CLOCK_VIRTUAL may be read outside BQL. This will make its
foundation, i.e. cpu_clock_offset exposed to race condition.
Using private lock to protect it.

After this patch, reading QEMU_CLOCK_VIRTUAL is thread safe
unless use_icount is true, in which case the existing callers
still rely on the BQL.

Lock rule: private lock innermost, ie BQL->"this lock"

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoseqlock: introduce read-write seqlock
Paolo Bonzini [Wed, 25 Sep 2013 06:20:57 +0000 (14:20 +0800)]
seqlock: introduce read-write seqlock

Seqlock implementation for QEMU. Usage idiom

reader:
    do {
        start = seqlock_read_begin(&sl);
        ...
    } while (seqlock_read_retry(&sl, start));

writer:
    seqlock_write_lock(&sl);
    ...
    seqlock_write_unlock(&sl);

initialization:
    seqlock_init(QemuSeqLock *sl, QemuMutex *mutex)

    mutex could be NULL if the caller will provide its own protection
    for concurrent write sides (typically using the BQL).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovga: Mark relevant portio lists regions as coalesced MMIO flushing
Jan Kiszka [Tue, 2 Jul 2013 19:37:40 +0000 (21:37 +0200)]
vga: Mark relevant portio lists regions as coalesced MMIO flushing

This allows to remove the explicit qemu_flush_coalesced_mmio_buffer
calls.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agocirrus: Mark vga io region as coalesced MMIO flushing
Jan Kiszka [Tue, 2 Jul 2013 19:19:02 +0000 (21:19 +0200)]
cirrus: Mark vga io region as coalesced MMIO flushing

This allows to remove the explicit qemu_flush_coalesced_mmio_buffer
calls - the memory core will invoke them now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoportio: Allow to mark portio lists as coalesced MMIO flushing
Jan Kiszka [Tue, 2 Jul 2013 18:22:37 +0000 (20:22 +0200)]
portio: Allow to mark portio lists as coalesced MMIO flushing

This will enable us to remove all remaining explicit calls of
qemu_flush_coalesced_mmio_buffer in IO handlers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agocompatfd: switch to QemuThread
Jan Kiszka [Thu, 2 May 2013 08:21:18 +0000 (10:21 +0200)]
compatfd: switch to QemuThread

qemu_thread_create already does signal blocking and detaching for us.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: fix 128 arithmetic in info mtree
Alexey Kardashevskiy [Fri, 30 Aug 2013 08:10:38 +0000 (18:10 +1000)]
memory: fix 128 arithmetic in info mtree

mtree_print_mr() calls int128_get64() in 3 places but only 2 places
handle 2^64 correctly.

This fixes the third call of int128_get64().

Cc: qemu-stable@nongnu.org
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/raw-win32: Always use -errno in hdev_open
Max Reitz [Fri, 11 Oct 2013 12:30:16 +0000 (14:30 +0200)]
block/raw-win32: Always use -errno in hdev_open

On one occasion, hdev_open() returned -1 in case of an unknown error
instead of a proper -errno value. Adjust this to match the behavior of
raw_open() (in raw-win32), which is to return -EINVAL in this case.
Also, change the call to error_setg*() to match the one in raw_open() as
well.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoe820: pass high memory too.
Gerd Hoffmann [Thu, 10 Oct 2013 08:30:27 +0000 (10:30 +0200)]
e820: pass high memory too.

We have a fw_cfg entry to pass e820 entries from qemu to the firmware.
Today it's used to pass reservations only.  This patch makes qemu pass
entries for RAM too.

This allows to pass RAM sizes larger than 1TB to the firmware and it
will also allow to pass non-contignous memory ramges should we decide
to implement that some day, say for our virtual numa nodes.

Obviously this needs some extra care to not break existing firware.

SeaBIOS loads the entries and happily adds them without looking at the
type.  Which is problematic for memory below 4g as this will overwrite
reservations added for bios memory etc.  For memory above 4g it works
just fine, seabios will merge the entry derived from cmos with the one
loaded from fw_cfg.

OVMF doesn't look at the fw_cfg e820 table.
coreboot doesn't look at the fw_cfg e820 table.

Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
10 years agospice: fix multihead support
Gerd Hoffmann [Fri, 11 Oct 2013 20:39:59 +0000 (22:39 +0200)]
spice: fix multihead support

This patch fixes spice display initialization to handle
multihead properly.

spice-core now keeps track of which QemuConsole has a spice
display channel attached to it and which has not.  It also
manages display channel ids.

spice-display looks at all QemuConsoles and will pick up any
graphic console not yet bound to a spice channel (which in practice
are all non-qxl graphic devices).

Result is that
 (a) you'll get a spice client window for each graphical device
     now (first only without this patch), and
 (b) mixing qxl and non-qxl vga cards works properly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agospice-display: add display channel id to the debug messages.
Gerd Hoffmann [Thu, 17 Oct 2013 10:11:43 +0000 (12:11 +0200)]
spice-display: add display channel id to the debug messages.

And s/__FUNCTION__/__func__/ while being at it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoFix VNC SASL authentication when using a QXL device
Christophe Fergeau [Wed, 16 Oct 2013 15:52:33 +0000 (17:52 +0200)]
Fix VNC SASL authentication when using a QXL device

ui/vnc.c:vnc_display_open() and spice-server/server/reds.c:do_spice_init()
are both calling sasl_server_init(). If spice_server_set_sasl_appname()
hasn't been called, spice-server will call it with "spice" as an appname,
causing cyrus-sasl to try to use a /etc/sasl2/spice.conf config file rather
than the /etc/sasl2/qemu.conf file that QEMU uses.

When using -spice sasl on the command line, QEMU properly calls
spice_server_set_sasl_appname() to set the SASL appname as "qemu",
but when using a QXL device without using SPICE, spice_server_init()
is called from qemu_spice_add_interface() without setting the appname
to "qemu", which then causes the VNC code to try to use spice.conf
instead of qemu.conf.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agospice: replace use of deprecated API
Marc-André Lureau [Fri, 4 Oct 2013 11:10:46 +0000 (13:10 +0200)]
spice: replace use of deprecated API

hose API are deprecated since 0.11, and qemu depends on 0.12 already.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoblockdev: fix cdrom read_only flag
Fam Zheng [Tue, 15 Oct 2013 09:45:50 +0000 (17:45 +0800)]
blockdev: fix cdrom read_only flag

Since 0ebd24e0, cdrom doesn't have read-only on by default, which will
error out when using an read only image. Fix it by setting the default
value when parsing opts.

Reported-by: Edivaldo de Araujo Pereira <edivaldoapereira@yahoo.com.br>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agosd: Avoid access to NULL BlockDriverState
Andreas Färber [Wed, 16 Oct 2013 13:24:01 +0000 (15:24 +0200)]
sd: Avoid access to NULL BlockDriverState

Commit 4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf (blockdev: Remove IF_*
check for read-only blockdev_init) added a usage of bdrv_is_read_only()
to sd_init(), which is called for versatilepb, versatileab and
xilinx-zynq-a9 machines among others with NULL argument by default,
causing the new qom-test to fail.

Add a check to prevent this.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agohmp: drop bogus "[not inserted]"
Mike Qiu [Thu, 17 Oct 2013 03:16:01 +0000 (23:16 -0400)]
hmp: drop bogus "[not inserted]"

Commit 3e9fab690d59ac15956c3733fe0794ce1ae4c4af ("block: Add support for
throttling burst max in QMP and the command line.") introduced bogus
"[not inserted]" output, possibly due to a merge failure.  Remove this
artifact.

Output of 'info block'

scsi0-hd0: /images/f18-ppc64.qcow2 (qcow2)
 [not inserted]
scsi0-cd2: [not inserted]
    Removable device: not locked, tray closed

floppy0: [not inserted]
    Removable device: not locked, tray closed

sd0: [not inserted]
    Removable device: not locked, tray closed

There will be no additional lines between scsi0-hd0 and
scsi0-cd2.

At the same time, scsi0-hd0 already inserted, but still has
'[not inserted]' flag. This line should be removed.

This patch is to solve this.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoui/Makefile.objs: delete unnecessary cocoa.o dependency
Peter Maydell [Thu, 10 Oct 2013 11:26:09 +0000 (19:26 +0800)]
ui/Makefile.objs: delete unnecessary cocoa.o dependency

Delete an unnecessary dependency for cocoa.o; we already have
a general rule that tells Make that we can build a .o file
from a .m source using an ObjC compiler, so this specific
rule is unnecessary. Further, it is using the dubious construct
"$(SRC_PATH)/$(obj)" to get at the source directory, which will
break when $(obj) is redefined as part of the preparation for
per-object library support.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agodefault-configs/: CONFIG_GDBSTUB_XML removed
Ákos Kovács [Fri, 13 Sep 2013 17:25:54 +0000 (18:25 +0100)]
default-configs/: CONFIG_GDBSTUB_XML removed

Makefile.target: Build gdbstub-xml.o only when
TARGET_XML_FILES is not empty.

Signed-off-by: Ákos Kovács <akoskovacs@gmx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMakefile.target: CONFIG_NO_* variables removed
Ákos Kovács [Fri, 13 Sep 2013 17:25:53 +0000 (18:25 +0100)]
Makefile.target: CONFIG_NO_* variables removed

CONFIG_NO_* variables replaced with the lnot logical function

Signed-off-by: Ákos Kovács <akoskovacs@gmx.com>
[PMM: fixed a few CONFIG_NO_* uses that were missed]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agorules.mak: New string testing functions
Peter Maydell [Fri, 13 Sep 2013 17:25:52 +0000 (18:25 +0100)]
rules.mak: New string testing functions

Add new string testing functions which return a y/n result:
 eq : are two strings equal (ignoring leading/trailing space)?
 ne : are two strings unequal?
 isempty : is a string empty?
 notempty : is a string non-empty?

Based on an idea by Ákos Kovács <akoskovacs@gmx.com>.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agorules.mak: New logical functions for handling y/n values
Peter Maydell [Fri, 13 Sep 2013 17:25:51 +0000 (18:25 +0100)]
rules.mak: New logical functions for handling y/n values

Add new logical functions for handling y/n values like those we
use in CONFIG_FOO variables:
 lnot : logical NOT
 land : logical AND
 lor : logical OR
 lxor : logical XOR
 leqv : logical equality, inverse of lxor
 lif : like Make's $(if) but with an eq-like test

Based on an idea by Ákos Kovács <akoskovacs@gmx.com>.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-xtensa: add in_asm logging
Max Filippov [Sat, 17 Aug 2013 08:30:57 +0000 (12:30 +0400)]
target-xtensa: add in_asm logging

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agoMerge remote-tracking branch 'rth/tcg-ldst-6' into staging
Anthony Liguori [Mon, 14 Oct 2013 16:59:59 +0000 (09:59 -0700)]
Merge remote-tracking branch 'rth/tcg-ldst-6' into staging

# By Richard Henderson
# Via Richard Henderson
* rth/tcg-ldst-6:
  target-alpha: Convert to new ldst opcodes
  tcg-ppc64: Support new ldst opcodes
  tcg-ppc: Support new ldst opcodes
  tcg-ppc64: Convert to le/be ldst helpers
  tcg-ppc: Convert to le/be ldst helpers
  tcg-ppc64: Use TCGMemOp within qemu_ldst routines
  tcg-ppc: Use TCGMemOp within qemu_ldst routines
  tcg-arm: Improve GUEST_BASE qemu_ld/st
  tcg-arm: Convert to new ldst opcodes
  tcg-arm: Tidy variable naming convention in qemu_ld/st
  tcg-arm: Convert to le/be ldst helpers
  tcg-arm: Use TCGMemOp within qemu_ldst routines
  tcg-i386: Support new ldst opcodes
  tcg-i386: Remove "cb" output restriction from qemu_st8 for i386
  tcg-i386: Tidy softmmu routines
  tcg-i386: Use TCGMemOp within qemu_ldst routines
  tcg: Use TCGMemOp for TCGLabelQemuLdst.opc

Message-id: 1381620683-4568-1-git-send-email-rth@twiddle.net
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'jliu/or32' into staging
Anthony Liguori [Mon, 14 Oct 2013 16:15:47 +0000 (09:15 -0700)]
Merge remote-tracking branch 'jliu/or32' into staging

# By Sebastian Macke
# Via Jia Liu
* jliu/or32:
  target-openrisc: Removes a non-conforming behavior for the first page of the memory
  target-openrisc: Correct handling of page faults.

Message-id: 1380789702-18935-1-git-send-email-proljc@gmail.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoMerge remote-tracking branch 'awilliam/tags/vfio-pci-for-qemu-20131010.0' into staging
Anthony Liguori [Mon, 14 Oct 2013 16:14:30 +0000 (09:14 -0700)]
Merge remote-tracking branch 'awilliam/tags/vfio-pci-for-qemu-20131010.0' into staging

vfio-pci updates include:
 - Forgotten MSI affinity patch posted several months ago
 - Lazy option ROM loading to delay load until after device/bus resets
 - Error reporting cleanups
 - PCI hot reset support introduced with Linux v3.12 development kernels
 - Debug build fix for int128

The lazy ROM loading and hot reset should help VGA assignment as we can
now do a bus reset when there are multiple devices on the bus, ex.
multi-function graphics and audio cards.

# gpg: Signature made Thu 10 Oct 2013 11:26:39 AM PDT using RSA key ID 3BB08B22
# gpg: Can't check signature: public key not found

# By Alex Williamson (7) and Alexey Kardashevskiy (1)
# Via Alex Williamson
* awilliam/tags/vfio-pci-for-qemu-20131010.0:
  vfio-pci: Fix endian issues in vfio_pci_size_rom()
  vfio-pci: Add dummy PCI ROM write accessor
  vfio: Fix debug output for int128 values
  vfio-pci: Implement PCI hot reset
  vfio-pci: Cleanup error_reports
  vfio-pci: Lazy PCI option ROM loading
  vfio-pci: Test device reset capabilities
  vfio-pci: Add support for MSI affinity

Message-id: 20131010184122.31667.28382.stgit@bling.home
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agoexec: Fix prototype of phys_mem_set_alloc and related functions
Stefan Weil [Sun, 29 Sep 2013 18:56:45 +0000 (20:56 +0200)]
exec: Fix prototype of phys_mem_set_alloc and related functions

phys_mem_alloc and its assigned values qemu_anon_ram_alloc and
legacy_s390_alloc must have identical argument lists.

legacy_s390_alloc uses the size parameter to call mmap, so size_t is
good enough for all of them.

This patch fixes compiler errors on i686 Linux hosts:

  CC    alpha-softmmu/exec.o
exec.c:752:51: error:
 initialization from incompatible pointer type [-Werror]
exec.c: In function 'qemu_ram_alloc_from_ptr':
exec.c:1139:32: error:
 comparison of distinct pointer types lacks a cast [-Werror]
exec.c: In function 'qemu_ram_remap':
exec.c:1283:21: error:
 comparison of distinct pointer types lacks a cast [-Werror]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1380481005-32399-1-git-send-email-sw@weilnetz.de
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
10 years agossdt-proc: update generated file
Michael S. Tsirkin [Fri, 27 Sep 2013 14:15:41 +0000 (17:15 +0300)]
ssdt-proc: update generated file

Update generated ssdt proc hex file (used for systems
lacking IASL) after P_BLK length change.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agossdt: fix PBLK length
Michael S. Tsirkin [Thu, 26 Sep 2013 22:15:14 +0000 (01:15 +0300)]
ssdt: fix PBLK length

We don't really support CPU throttling, so supply 0 PBLK length.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoi386: ACPI table generation code from seabios
Michael S. Tsirkin [Wed, 24 Jul 2013 15:56:14 +0000 (18:56 +0300)]
i386: ACPI table generation code from seabios

This adds C code for generating ACPI tables at runtime,
imported from seabios git tree
    commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd

Although ACPI tables come from a system BIOS on real hw,
it makes sense that the ACPI tables are coupled with the
virtual machine, since they have to abstract the x86 machine to
the OS's.

This is widely desired as a way to avoid the churn
and proliferation of QEMU-specific interfaces
associated with ACPI tables in bios code.

Notes:
As BIOS can reprogram devices prior to loading
ACPI tables, we pre-format ACPI tables but defer loading
hardware configuration there until tables are loaded.

The code structure was intentionally kept as close
to the seabios original as possible, to simplify
comparison and making sure we didn't lose anything
in translation.

Minor code duplication results, to help ensure there are no functional
regressions, I think it's better to merge it like this and do more code
changes in follow-up patches.

Cross-version compatibility concerns have been addressed:
    ACPI tables are exposed to guest as FW_CFG entries.
    When running with -M 1.5 and older, this patch disables ACPI
    table generation, and doesn't expose ACPI
    tables to guest.

    As table content is likely to change over time,
    the following measures are taken to simplify
    cross-version migration:
    - All tables besides the RSDP are packed in a single FW CFG entry.
      This entry size is currently 23K. We round it up to 64K
      to avoid too much churn there.
    - Tables are placed in special ROM blob (not mapped into guest memory)
      which is automatically migrated together with the guest, same
      as BIOS code.
    - Offsets where hardware configuration is loaded in ACPI tables
      are also migrated, this is in case future ACPI changes make us
      rearrange the tables in memory.

This patch reuses some code from SeaBIOS, which was originally under
LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This
relicensing has been acked by all contributors that had contributed to the
code since the v2->v3 relicense. ACKs approving the v2+ relicensing are
listed below. The list might include ACKs from people not holding
copyright on any parts of the reused code, but it's better to err on the
side of caution and include them.

Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:

 src/acpi-dsdt-cpu-hotplug.dsl
 src/acpi-dsdt-dbug.dsl
 src/acpi-dsdt-hpet.dsl
 src/acpi-dsdt-isa.dsl
 src/acpi-dsdt-pci-crs.dsl
 src/acpi.c
 src/acpi.h
 src/ssdt-misc.dsl
 src/ssdt-pcihp.dsl
 src/ssdt-proc.dsl
 tools/acpi_extract.py
 tools/acpi_extract_preprocess.py

Each one of the listed people agreed to the following:

> If you allow the use of your contribution in QEMU under the
> terms of GPLv2 or later as proposed by this patch,
> please respond to this mail including the line:
>
> Acked-by: Name <email address>

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Jason Baron <jbaron@akamai.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Dave Frodin <dave.frodin@se-eng.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Kevin O'Connor <kevin@koconnor.net>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Magnus Christensson <magnus.christensson@intel.com>
Acked-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: use new api to add builtin tables
Michael S. Tsirkin [Mon, 7 Oct 2013 19:12:00 +0000 (22:12 +0300)]
pc: use new api to add builtin tables

At this point the only builtin table we have is
the DSDT used for Q35.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi: add interface to access user-installed tables
Michael S. Tsirkin [Mon, 7 Oct 2013 11:41:40 +0000 (14:41 +0300)]
acpi: add interface to access user-installed tables

Also add a new API to install builtin tables, so
that we can distinguish between the two.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohpet: add API to find it
Michael S. Tsirkin [Wed, 24 Jul 2013 15:56:13 +0000 (18:56 +0300)]
hpet: add API to find it

Add API to find HPET using QOM.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopvpanic: add API to access io port
Michael S. Tsirkin [Wed, 24 Jul 2013 15:56:12 +0000 (18:56 +0300)]
pvpanic: add API to access io port

Add API to find pvpanic device and get its io port.
Will be used to fill in guest info structure.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>