Commit graph

20561 commits

Author SHA1 Message Date
Michael Roth 173bbb754f qapi: String visitor, use %f representation for floats
Currently string-output-visitor formats floats as %g, which is nice in
that trailing 0's are automatically truncated, but otherwise this causes
some issues:

 - it uses 6 significant figures instead of 6 decimal places, which
   means something like 155777.5 (which even has an exact floating point
   representation) will be rounded to 155778 when converted to a string.

 - output will be presented in scientific notation when the normalized
   form requires a 10^x multiplier. Not a huge deal, but arguably less
   readable for command-line arguments.

 - due to using scientific notation for numbers requiring more than 6
   significant figures, instead of hard-defined decimal places, it
   fails a lot of the test-visitor-serialization unit tests for floats.

Instead, let's just use %f, which is what the QJSON and the QMP visitors
use.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08 16:11:14 +02:00
Michael Roth 2d49610539 qapi: Unit tests for visitor-based serialization
Currently we test our visitors individually, and seperately for input
vs. output. This is useful for validating internal representations
against the native C types and vice-versa, and other visitor-specific
testing, but it doesn't cover the potential use-case of using visitor
pairs for serialization/deserialization very well, and makes it
hard to easily extend the coverage for different C types / boundary
conditions.

To cover that we add a set of unit tests that takes a number of native C
values, passes them into an output visitor, extracts the values with an
input visitor, then compares the result to the original.

Plugging in new visitors to the test harness only requires a user to
implement the SerializeOps interface and add it to a list.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08 16:11:14 +02:00
Michael Roth 4e27e819be qapi: Add Visitor interfaces for uint*_t and int*_t
This adds visitor interfaces for fixed-width integers types.
Implementing these in visitors is optional, otherwise we fall back to
visit_type_int() (int64_t) with some additional bounds checking to avoid
integer overflows for cases where the value fetched exceeds the bounds
of our target C type.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[LE: exclude negative values in uint*_t Visitor interfaces]
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
[AF: Merged fix by Laszlo]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08 16:11:14 +02:00
Harsh Prateek Bora 263ddcc81b configure: report missing libraries for virtfs
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-06-08 10:01:45 +01:00
Harsh Prateek Bora 0d665005c7 trace/simple.c: fix deprecated glib2 interface
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-06-08 09:32:40 +01:00
Jan Kiszka 8e0fdce32d Clarify comments of tb_invalidate_phys_[page_]range
They could suggest that all TBs of the page containing the range would
be invalidated.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-06-08 09:32:26 +01:00
Jan Kiszka 44701ab71a msi: Use msi/msix_present more consistently
Replace some open-coded msi/msix_present checks.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:19:01 +03:00
Jan Kiszka 95d6580024 msi: Invoke msi/msix_write_config from PCI core
Also this functions is better invoked by the core than by each and every
device. This allows to drop the config_write callbacks from ich and
intel-hda.

CC: Alexander Graf <agraf@suse.de>
CC: Gerd Hoffmann <kraxel@redhat.com>
CC: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:19:00 +03:00
Jan Kiszka 7c9958b043 msi: Guard msi/msix_write_config with msi_present
Terminate msi/msix_write_config early if support is not enabled. This
allows to remove checks at the caller site if MSI is optional.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:19:00 +03:00
Jan Kiszka cbd2d4342b msi: Invoke msi/msix_reset from PCI core
There is no point in pushing this burden to the devices, they tend to
forget to call them (like intel-hda, ahci, xhci did). Instead, reset
functions are now called from pci_device_reset. They do nothing if
MSI/MSI-X is not in use.

CC: Alexander Graf <agraf@suse.de>
CC: Gerd Hoffmann <kraxel@redhat.com>
CC: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:19:00 +03:00
Jan Kiszka 520064c8b1 msi: Guard msi_reset with msi_present
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:59 +03:00
Jan Kiszka 8ab60a0703 ahci: Clean up reset functions
Properly register reset functions via the device class.

CC: Alexander Graf <agraf@suse.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:59 +03:00
Jan Kiszka 8e729e3b52 intel-hda: Fix reset of MSI function
Call msi_reset on device reset as still required by the core.

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:59 +03:00
Jan Kiszka 868a1a5226 ahci: Fix reset of MSI function
Call msi_reset on device reset as still required by the core.

CC: Alexander Graf <agraf@suse.de>
CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:59 +03:00
Fernando Luis Vazquez Cao fee9d348ff rtl8139: honor RxOverflow flag in can_receive method
Some drivers (Linux' 8139too among them) rely on the NIC
injecting an interrupt in the event of a receive buffer overflow
and, accordingly, set the RxOverflow bit in the interrupt
mask. Unfortunately rtl8139's can_receive method ignores the
RxOverflow flag, which may lead to a situation where rtl8139
stops receiving packets (can_receive returns 0) when the receive
buffer becomes full.

If the driver eventually read from the receive buffer or reset
the card the emulator could recover from this situation. However
some implementations only do this upon receiving an interrupt
with either RxOK or RxOverflow set in the ISR; interrupt that
will never come because QEMU's flow control mechanisms would
prevent rtl8139 from receiving any packet.

Letting packets go through when the overflow interrupt is enabled
makes the QEMU emulator compliant to the spec and solves the
problem.

This patch should fix a relatively common (in our experience)
network stall observed when running enterprise distros with
rtl8139 as the NIC; in some cases the 8139too device driver gets
loaded and when under heavy load the network eventually stops
working.

Reported-by: Hayato Kakuta <kakuta.hayato@oss.ntt.co.jp>
Tested-by: Hayato Kakuta <kakuta.hayato@oss.ntt.co.jp>
Acked-by: Igor Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:58 +03:00
Michael S. Tsirkin e9adf2605d shpc: unparent device before free
Recent core change removed unparent
so we need to do this in all callers now.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-06-07 17:18:58 +03:00
Anthony Liguori fa79c914ef Merge remote-tracking branch 'bonzini/nested-makefiles-3' into staging
* bonzini/nested-makefiles-3: (29 commits)
  build: do not create directories at configure time
  configure: ensure directory exists when creating symlink
  build: compile oslib-obj-y once
  build: limit usage of vpath
  build: libcacard Makefile cleanups
  build: move device tree to per-target Makefile.objs
  build: move per-target hw/ objects to nested Makefile.objs
  build: convert libhw to nested Makefile.objs
  build: move target-independent hw/ objects to nested Makefile.objs
  build: move qga/ objects to nested Makefile.objs
  build: move qapi/ objects to nested Makefile.objs
  build: move slirp/ objects to nested Makefile.objs
  build: move audio/ objects to nested Makefile.objs
  build: move ui/ objects to nested Makefile.objs
  build: move fsdev/ objects to nested Makefile.objs
  build: move net/ objects to nested Makefile.objs
  build: move block/ objects to nested Makefile.objs
  build: adapt qom/Makefile and move it to Makefile.objs
  build: move rules for nesting to Makefile.objs
  build: move other target-*/ objects to nested Makefile.objs
  ...
2012-06-07 17:21:40 +08:00
Peter A. G. Crosthwaite 083dbf489d target-microblaze: fix swx build breakage
The lazy initialisation of r_check was throwing an error on --enable-debug.
Removed the lazy initialisation of r_check and swx_addr.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2012-06-07 10:12:00 +02:00
Gerd Hoffmann f020ed36fe ehci: rework frame skipping
Move the framecount check out of the loop and use the new
ehci_update_frindex function to skip frames if needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann 3a21532626 ehci: adaptive wakeup rate.
Adapt the frame timer sleeps according to the actual needs.  With the
periodic schedule being active we'll have to wakeup 1000 times per
second and go check for work.  In case only the async schedule is active
we can be more lazy though.  When idle ehci will increate the sleep time
step by step, so qemu has to wake up less frequently.  When we'll see
transactions on the bus or the guest fiddles with the schedule
enable/disable bits we'll return to a 1000 Hz wakeup rate and full
speed.  With both schedules disabled we stop wakeups altogether.

This patch also drops the freq property (configures wakeup rate
manually) which is obsoleted by this patch.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann 6ceced0b2e ehci: create ehci_update_frindex
Factor out code from ehci_frame_timer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann 863b474163 ehci: remove unused attach_poll_counter
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann daf25307b4 ehci: fix halt status handling
When the enable bits for controller / async schedule / periodic schedule
change just make sure we kick the frame timer and let
ehci_advance_periodic_state and ehci_advance_async_state handle the
controller state changes.

This will make ehci set USBSTS_HALT when the controller shutdown is
actually done, once both schedules are in inactive state and the
USBSTS_PSS and USBSTS_ASS bits are clear.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann b53f685d63 ehci: update status bits in ehci_set_state
Update the status register in the ehci_set_state function, to make sure
the guest-visible register is in sync with our internal schedule state.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann ec807d12bd ehci: add ehci_*_enabled() helpers
Add helper functions to query whenever the async / periodic schedule
is enabled or not.  Put them into use too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:23 +02:00
Gerd Hoffmann 7046530c36 ehci: fix reset
Check for the reset bit first when processing USBCMD register writes.
Also break out of the switch, there is no need to check the other bits.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 0f588df8b3 ehci: kick async schedule on wakeup
Kick async schedule when we get a wakeup
notification from a usb device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann ae710b9905 ehci: schedule async bh on async packet completion
When a packet completes which happens to be part of the async schedule
kick the async bottom half for processing,

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 0fb3e299bd ehci: move async schedule to bottom half
This way we can kick the async schedule independant from the
periodic frame timer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann ae0138a8ea ehci: add async field to EHCIQueue
Keep track whenever a EHCIQueue is part of the async or periodic
schedule.  This way we don't have to pass around the async flag
everywhere but can look it up from the EHCIQueue struct when needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 8f6d5e26b1 ehci: tweak queue initialization
Little tweak for the queue initialization, set the QH address in the
allocation function.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 773dc9cdfd ehci: add queuing support
Add packet queuing.  Follow the qTD chain to see if there are more
packets we can submit.  Improves performance on larger transfers,
especially with usb-host, as we don't have to wait for a packet to
finish before sending the next one to the host for processing.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann cd6657156e ehci: move ehci_flush_qh
Move ehci_flush_qh() function up in the source code.
No code change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann e59928b3d1 ehci: cache USBDevice in EHCIQueue
Keep a USBDevice pointer in EHCIQueue so we don't have to lookup the
device on each usb packet submission.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 4224558f87 ehci: make ehci_execute work on EHCIPacket instead of EHCIQueue
This way it is possible to use ehci_execute to submit others than the
first EHCIPacket of the EHCIQueue.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann eb36a88e6b ehci: add EHCIPacket
Add a separate EHCIPacket struct and move fields over from EHCIQueue.
Preparing for supporting multiple packets per queue being in flight at
the same time.  No functional changes yet.

Fix some codestyle issues along the way.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 348f10374a xhci: trace: slots
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 97df650bb9 xhci: trace: transfers
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann c1f6b49326 xhci: trace: endpoints
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 0703a4a7a6 xhci: trace: ring fetch
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:22 +02:00
Gerd Hoffmann 7acd279f83 xhci: trace: irq + events
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann fc0ddaca33 xhci: trace: run+stop
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 2d754a10e4 xhci: trace: mmio reads+writes
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Jan Kiszka 64619739c4 xhci: Clean up reset function
Properly register reset function via the device class.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 5de88b1d46 usb-storage: migration support
With all scsi migration support bits in place the
final step is pretty simple ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 1dc903673a usb-storage: add scsi_off, remove scsi_buf
Repace the running buffer pointer (scsi_buf) with a buffer offset
field (scsi_off).  The later is alot easier to live-migrate.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 1e6ed80b90 usb-storage: add usb_msd_packet_complete()
Factor out packet completion to a separate function which
cares to get the MSDState->packet update right.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 0659879e6e usb-storage: remove MSDState->residue
We have the field twice, once in MSDState directly and one in the status
word struct.  Drop one.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 18eef3bc4e scsi: prepare migration code for usb-storage support
usb-storage can't handle requests in one go as the data transfer can be
splitted into lots of usb packets.  Because of that there can be
normal in-flight requests at savevm time and we need to handle that.
With other scsi hba's this happens only in case i/o is stopped due to
errors and there are pending requests which need to be restarted
(req->retry = true).

So, first we need to save req->retry and then handle the req->retry =
false case.  Write requests are handled fine already.  For read requests
we have to save the buffer as we will not restart the request (and thus
not refill the buffer) on the target host.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:21 +02:00
Gerd Hoffmann 973002c114 uhci: fix irq routing
The multifunction ich9 ehci controller with uhci companions uses a
different interrupt pin for each function.  The three uhci devices
get pins A, B and C, whereas ehci uses pin D.  This way the guest
can assign different IRQ lines to each controller.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-06-07 10:02:20 +02:00