sdk/emulator/qemu.git
11 years agoMerge remote-tracking branch 'kraxel/usb.71' into staging
Anthony Liguori [Mon, 19 Nov 2012 15:26:48 +0000 (09:26 -0600)]
Merge remote-tracking branch 'kraxel/usb.71' into staging

* kraxel/usb.71:
  usb-host: fix splitted transfers
  usb-host: update tracing
  usb-redir: Set default debug level to warning
  usb-redir: Only add actually in flight packets to the in flight queue
  ehci: handle dma errors
  ehci: keep the frame timer running in case the guest asked for frame list rollover interrupts
  ehci: Don't verify the next pointer for periodic qh-s and qtd-s
  ehci: Better detection for qtd-s linked in circles
  ehci: Fixup q->qtdaddr after cancelling an already completed packet
  ehci: Don't access packet after freeing it
  usb: host-linux: Ignore parsing errors of the device descriptors
  usb-host: scan for usb devices when the vm starts
  usb: Fix (another) bug in usb_packet_map() for IOMMU handling
  fix live migration

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Mon, 19 Nov 2012 14:32:03 +0000 (08:32 -0600)]
Merge remote-tracking branch 'stefanha/tracing' into staging

* stefanha/tracing:
  trace: Remove "info trace" from documents
  trace: document '-' syntax for disabling events
  trace: allow disabling events in events file
  Avoid all systemtap reserved words

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'amit/loadvm-irq-inj-fix' into staging
Anthony Liguori [Mon, 19 Nov 2012 14:31:48 +0000 (08:31 -0600)]
Merge remote-tracking branch 'amit/loadvm-irq-inj-fix' into staging

* amit/loadvm-irq-inj-fix:
  virtio-serial-bus: post_load send_event when vm is running

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Mon, 19 Nov 2012 14:31:24 +0000 (08:31 -0600)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

* afaerber/qom-cpu:
  target-i386: Add Haswell CPU model
  target-i386/cpu: Add new Opteron CPU model
  target-i386/cpu: Name new CPUID bits
  qapi-types.h: Don't include qemu-common.h
  osdep: Move qemu_{open,close}() prototypes
  qemu-config.h: Include headers it needs
  vnc-palette.h: Include <stdbool.h>
  qemu-fsdev-dummy.c: Include module.h
  qdev: Split up header so it can be used in cpu.h
  Move qemu_irq typedef out of qemu-common.h
  qemu-common.h: Comment about usage rules

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Mon, 19 Nov 2012 14:30:45 +0000 (08:30 -0600)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

* qemu-kvm/uq/master:
  kvm: Actually remove software breakpoints from list on cleanup
  acpi_piix4: fix migration of gpe fields

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agorng-random: only build on POSIX platforms
Anthony Liguori [Sat, 17 Nov 2012 13:40:47 +0000 (07:40 -0600)]
rng-random: only build on POSIX platforms

There is no /dev/random on win32.

Cc: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agotci: Support deposit operations
Stefan Weil [Tue, 18 Sep 2012 20:52:14 +0000 (22:52 +0200)]
tci: Support deposit operations

The operations for INDEX_op_deposit_i32 and INDEX_op_deposit_i64
are now supported and enabled by default.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotci: Fix build breakage (unresolved symbol tcg_out_tb_finalize)
Stefan Weil [Sun, 18 Nov 2012 19:16:26 +0000 (20:16 +0100)]
tci: Fix build breakage (unresolved symbol tcg_out_tb_finalize)

Commit 32761257c0b9fa7ee04d2871a6e48a41f119c469 enabled
qemu_ld/st optimization unconditionally for some hosts.

The TCG interpreter still does not support this kind of
optimization. Therefore builds with TCI fail with an
unresolved symbol tcg_out_tb_finalize. This is fixed here.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotci: fix build breakage for target MIPS
Stefan Weil [Sun, 18 Nov 2012 19:06:19 +0000 (20:06 +0100)]
tci: fix build breakage for target MIPS

commit 5f7319cd introduced GETPC() usage for MIPS, which is currently
not defined when building with --enable-tcg-interpreter. Add MIPS to
the list of targets we selectively define GETPC() for.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agobuild: replace weak symbols with a static library
Paolo Bonzini [Fri, 16 Nov 2012 17:35:27 +0000 (18:35 +0100)]
build: replace weak symbols with a static library

Weak symbols were a nice idea, but they turned out not to be a good one.
Toolchain support is just too sparse, in particular llvm-gcc is totally
broken.

This patch uses a surprisingly low-tech approach: a static library.
Symbols in a static library are always overridden by symbols in an
object file.  Furthermore, if you place each function in a separate
source file, object files for unused functions will not be taken in.
This means that each function can use all the dependencies that it needs
(especially QAPI stuff such as error_setg).

Thus, all stubs are placed in separate object files and put together in
a static library.  The library then is linked to all programs.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agolibseccomp: require version 1.0.0
Blue Swirl [Sat, 3 Nov 2012 15:42:21 +0000 (15:42 +0000)]
libseccomp: require version 1.0.0

Debian Wheezy has version 0.1.0 which is not compatible, avoid it.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMerge branch 'vga.1' of git://git.kraxel.org/qemu
Blue Swirl [Sat, 17 Nov 2012 16:38:05 +0000 (16:38 +0000)]
Merge branch 'vga.1' of git://git.kraxel.org/qemu

* 'vga.1' of git://git.kraxel.org/qemu:
  vga: fix mmio vga register mapping
  vga: fix bochs alignment issue

11 years agoTCG: Remove unused global variables
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:49 +0000 (13:27 +0400)]
TCG: Remove unused global variables

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoTCG: Use gen_opparam_buf from context instead of global variable.
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:48 +0000 (13:27 +0400)]
TCG: Use gen_opparam_buf from context instead of global variable.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoTCG: Use gen_opc_buf from context instead of global variable.
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:47 +0000 (13:27 +0400)]
TCG: Use gen_opc_buf from context instead of global variable.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoTCG: Use gen_opparam_ptr from context instead of global variable.
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:46 +0000 (13:27 +0400)]
TCG: Use gen_opparam_ptr from context instead of global variable.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoTCG: Use gen_opc_ptr from context instead of global variable.
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:45 +0000 (13:27 +0400)]
TCG: Use gen_opc_ptr from context instead of global variable.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotcg/tcg.h: Duplicate global TCG variables in TCGContext
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:44 +0000 (13:27 +0400)]
tcg/tcg.h: Duplicate global TCG variables in TCGContext

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotarget-cris/translate.c: Code style clean-up
Evgeny Voevodin [Mon, 12 Nov 2012 09:27:43 +0000 (13:27 +0400)]
target-cris/translate.c: Code style clean-up

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agorng-egd: don't use gslist_free_full
Anthony Liguori [Fri, 16 Nov 2012 19:09:34 +0000 (13:09 -0600)]
rng-egd: don't use gslist_free_full

This function was only introduced in glib 2.28.0.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-rng-pci: create a default backend if none exists
Anthony Liguori [Fri, 26 Oct 2012 17:05:49 +0000 (12:05 -0500)]
virtio-rng-pci: create a default backend if none exists

This allows you to specify:

  $ qemu -device virtio-rng-pci

And things will Just Work with a reasonable default.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-rng: add rate limiting support
Anthony Liguori [Tue, 30 Oct 2012 22:45:05 +0000 (17:45 -0500)]
virtio-rng: add rate limiting support

This adds parameters to virtio-rng-pci to allow rate limiting the entropy a
guest receives.  An example command line:

$ qemu -device virtio-rng-pci,max-bytes=1024,period=1000

Would limit entropy collection to 1Kb/s.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-rng: hardware random number generator device
Amit Shah [Wed, 20 Jun 2012 06:59:32 +0000 (12:29 +0530)]
virtio-rng: hardware random number generator device

The Linux kernel already has a virtio-rng driver, this is the device
implementation.

When the guest asks for entropy from the virtio hwrng, it puts a buffer
in the vq.  We then put entropy into that buffer, and push it back to
the guest.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
aliguori: converted to new RngBackend interface
aliguori: remove entropy needed event
aliguori: fix migration

11 years agorng-egd: introduce EGD compliant RNG backend
Anthony Liguori [Mon, 25 Jun 2012 18:13:31 +0000 (13:13 -0500)]
rng-egd: introduce EGD compliant RNG backend

This backend talks EGD to a CharDriverState.  A typical way to invoke this would
be:

qemu -chardev socket,host=localhost,port=1024,id=chr0 \
     -object rng-egd,chardev=chr0,id=egd0 \
     -device virtio-rng-pci,rng=egd0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agorng-random: add an RNG backend that uses /dev/random (v3)
Anthony Liguori [Mon, 25 Jun 2012 15:34:09 +0000 (10:34 -0500)]
rng-random: add an RNG backend that uses /dev/random (v3)

The filename can be overridden but it expects a non-blocking source of entropy.
A typical invocation would be:

qemu -object rng-random,id=rng0 -device virtio-rng-pci,rng=rng0

This can also be used with /dev/urandom by using the command line:

qemu -object rng-random,filename=/dev/urandom,id=rng0 \
     -device virtio-rng-pci,rng=rng0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - merged header split patch into this one
v2 -> v3
 - bug fix in rng-random (Paolo)

11 years agorng: add RndBackend abstract object class
Anthony Liguori [Mon, 25 Jun 2012 15:03:47 +0000 (10:03 -0500)]
rng: add RndBackend abstract object class

This is the backend used by devices that need to request entropy.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoobject: add object_property_add_bool (v2)
Anthony Liguori [Mon, 25 Jun 2012 15:32:46 +0000 (10:32 -0500)]
object: add object_property_add_bool (v2)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Fix whitespace (Andreas Faerber)

11 years agovl: add -object option to create QOM objects from the command line
Anthony Liguori [Mon, 25 Jun 2012 19:36:33 +0000 (14:36 -0500)]
vl: add -object option to create QOM objects from the command line

This will create a new QOM object in the '/objects' path.  Note that properties
are set in order which allows for simple objects to be initialized entirely
with this option and then realized.

This option is roughly equivalent to -device but for things that are not
devices.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agotrace: Remove "info trace" from documents
Liming Wang [Fri, 16 Nov 2012 07:10:49 +0000 (15:10 +0800)]
trace: Remove "info trace" from documents

commit 88affa1c monitor: remove unused do_info_trace

has removed "info trace" function from monitor, so remove it from documents.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agotrace: document '-' syntax for disabling events
Stefan Hajnoczi [Mon, 5 Nov 2012 07:48:29 +0000 (08:48 +0100)]
trace: document '-' syntax for disabling events

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agotrace: allow disabling events in events file
Gerd Hoffmann [Fri, 26 Oct 2012 11:46:34 +0000 (13:46 +0200)]
trace: allow disabling events in events file

Disable trace events prefixed with a '-'.  Useful
to enable a group of tracepoints with exceptions,
like this:

  usb_xhci_port_*
  -usb_xhci_port_read

which will enable all xhci port tracepoints except reads.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoAvoid all systemtap reserved words
Daniel P. Berrange [Fri, 2 Nov 2012 12:00:53 +0000 (12:00 +0000)]
Avoid all systemtap reserved words

Over time various systemtap reserved words have been blacklisted
in the trace backend generator. The list is not complete though,
so there is continued risk of problems in the future. Preempt
such problems by specifying the full list of systemtap keywords
listed in its parser as identified here:

  http://sourceware.org/ml/systemtap/2012-q4/msg00157.html

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agousb-host: fix splitted transfers
Gerd Hoffmann [Thu, 15 Nov 2012 15:11:49 +0000 (16:11 +0100)]
usb-host: fix splitted transfers

USBPacket->actual_length wasn't updated correctly for USBPackets
splitted into multiple urbs.  Fix it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-host: update tracing
Gerd Hoffmann [Thu, 15 Nov 2012 15:11:20 +0000 (16:11 +0100)]
usb-host: update tracing

Now that we have separate status and length fields in USBPacket
update the completion tracepoint to log both.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-redir: Set default debug level to warning
Hans de Goede [Thu, 15 Nov 2012 13:15:00 +0000 (14:15 +0100)]
usb-redir: Set default debug level to warning

The previous default of 0 means that even errors and warnings would not
get printed, which is really not a good default.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-redir: Only add actually in flight packets to the in flight queue
Hans de Goede [Thu, 15 Nov 2012 13:14:59 +0000 (14:14 +0100)]
usb-redir: Only add actually in flight packets to the in flight queue

Packets which are queued up, but not yet handed over to the device, are
*not* in flight.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: handle dma errors
Gerd Hoffmann [Thu, 15 Nov 2012 12:07:49 +0000 (13:07 +0100)]
ehci: handle dma errors

Starting with commit 1c380f9460522f32c8dd2577b2a53d518ec91c6d dma
transfers can actually fail.  This patch makes ehci keep track
of the busmaster bit in pci config space, by setting/clearing the
dma_context pointer.  Attempts to dma without context will result
in raising HSE (Host System Error) interrupt and stopping the host
controller.

This patch fixes WinXP not booting with a usb stick attached to ehci.
Root cause is seabios activating ehci so you can boot from the stick,
and WinXP clearing the busmaster bit before resetting the host
controller, leading to ehci actually trying dma while it is disabled.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: keep the frame timer running in case the guest asked for frame list rollover...
Gerd Hoffmann [Tue, 13 Nov 2012 16:20:05 +0000 (17:20 +0100)]
ehci: keep the frame timer running in case the guest asked for frame list rollover interrupts

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Don't verify the next pointer for periodic qh-s and qtd-s
Hans de Goede [Thu, 15 Nov 2012 13:14:58 +0000 (14:14 +0100)]
ehci: Don't verify the next pointer for periodic qh-s and qtd-s

While testing the move to async packet handling for interrupt endpoints I
noticed that Windows-XP likes to play tricks with the next pointer for
periodic qh-s, so we should not fail qh / qtd verification when it changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Better detection for qtd-s linked in circles
Hans de Goede [Wed, 14 Nov 2012 16:21:38 +0000 (17:21 +0100)]
ehci: Better detection for qtd-s linked in circles

Windows links interrupt qtd-s in circles, which means that when interrupt
endpoints return USB_RET_ASYNC, combined with the recent
"ehci: Retry to fill the queue while waiting for td completion" patch,
we keep adding the tds to the queue over and over again, as we detect the
circle from fill_queue, but we call it over and over again ...

This patch fixes this by changing the circle detection to also detect
circling into tds already queued up previously.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Fixup q->qtdaddr after cancelling an already completed packet
Hans de Goede [Wed, 14 Nov 2012 16:21:37 +0000 (17:21 +0100)]
ehci: Fixup q->qtdaddr after cancelling an already completed packet

This avoids the q->qtdaddr == p->qtdaddr asserts we have triggering, when
a queue contains multiple completed packages when we cancel the queue.

I triggered this with windows7 + async interrupt endpoint handling (*)
+ not detecting circles in ehci_fill_queue() properly, which makes the qtd
validation in ehci_fill_queue fail, causing cancellation of the queue on every
mouse event ...

*) Which is not going upstream as it will cause loss of interrupt events on
migration.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Don't access packet after freeing it
Hans de Goede [Wed, 14 Nov 2012 16:21:36 +0000 (17:21 +0100)]
ehci: Don't access packet after freeing it

ehci_state_writeback() will free the packet, so we should not access
the packet after calling ehci_state_writeback().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: host-linux: Ignore parsing errors of the device descriptors
Jan Kiszka [Thu, 15 Nov 2012 08:23:30 +0000 (09:23 +0100)]
usb: host-linux: Ignore parsing errors of the device descriptors

The Linux is more tolerant here as well: Just stop parsing the device
descriptors when an error is detected but do not reset what was found
so far. This allows to run buggy devices with partially invalid
descriptors.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agovga: fix mmio vga register mapping
Gerd Hoffmann [Mon, 12 Nov 2012 21:33:21 +0000 (22:33 +0100)]
vga: fix mmio vga register mapping

11 years agovga: fix bochs alignment issue
Gerd Hoffmann [Mon, 12 Nov 2012 11:40:46 +0000 (12:40 +0100)]
vga: fix bochs alignment issue

The bochs dispi interface traditionally uses port 0x1ce as 16bit index
register and port 0x1cf as 16bit data register.  The later is unaligned,
and probably for that reason the the data register was moved to 0x1d0
for non-x86 archs.

This patch makes the data register available at 0x1d0 on x86 too.  The
old x86 location is kept for compatibility reasons, so both 0x1cf and
0x1d0 can be used as data register on x86.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-host: scan for usb devices when the vm starts
Gerd Hoffmann [Wed, 14 Nov 2012 14:51:18 +0000 (15:51 +0100)]
usb-host: scan for usb devices when the vm starts

Commit a844ed842d9a9d929645c09ae0f52f753d7a02e0 leads to usb-host
detecting devices not right after qemu startup because the guest
isn't running yet.  Instead they are found on the first of the
regular usb device poll runs.  Which is too late for seabios to see
them, so booting from usb sticks fails.

Fix this by adding a vm state change handler which triggers a device
scan when the vm is started.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Fix (another) bug in usb_packet_map() for IOMMU handling
David Gibson [Wed, 14 Nov 2012 05:23:50 +0000 (16:23 +1100)]
usb: Fix (another) bug in usb_packet_map() for IOMMU handling

Elements in qemu SGLists can cross IOMMU page boundaries.  So, in commit
39c138c8420f51a7da7b35233a8d7400a0b589ac "usb: Fix usb_packet_map() in the
presence of IOMMUs", I changed usb_packet_map() to split up each SGList
element on IOMMU page boundaries and each resulting piece of qemu's memory
space separately to the iovec the usb code uses internally.

That was correct in concept, but the patch has a bug.  The 'base' variable
correctly steps through the dma address of each piece, but then we call
the dma_memory_map() function on the base address of the whole SGList
element every time.

This patch fixes at least one problem using XHCI on the pseries guest
machine.  It didn't affect OHCI because that doesn't use usb_packet_map().
In theory it also affects EHCI, but we haven't observed that in practice.
I think the transfers were small enough on EHCI that they never crossed an
IOMMU page boundary in practice.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agofix live migration
Gerd Hoffmann [Thu, 8 Nov 2012 14:54:05 +0000 (15:54 +0100)]
fix live migration

Commit 1c380f9460522f32c8dd2577b2a53d518ec91c6d breaks live migration.
DMA stops working for ehci (and probably for any pci device) after
restoring the guest because the bus master region never gets enabled.
Add code doing that after loading the pci config space from vmstate.

Cc: Avi Kivity <avi@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agovirtio-serial-bus: post_load send_event when vm is running
Alon Levy [Wed, 14 Nov 2012 13:09:07 +0000 (15:09 +0200)]
virtio-serial-bus: post_load send_event when vm is running

Alexander Larsson found irq injection to Windows guests stopped after a
migration.  The symptom was the mouse stopped working.

Reproduction steps are:
1. On src, start qemu with a virtio-serial port without any backend
2. On dest, start qemu with a virtio-serial port with a backend
3. Migrate.

Upon migration, the older code detected the change in backend connection
status, and sent a notification to the guest.  However, it's not
guaranteed that the apic is ready to inject irqs into the guest, and the
irq line remained high, resulting in any future interrupts going
unnoticed by the guest as well.

Add a new timer based on vm_clock for 1 ns in the future from post_load
to do the event send in case host_connected differs between migration
source and target.

RHBZ: 867366

Signed-off-by: Alon Levy <alevy@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com> # verbose commit log
11 years agotarget-mips: fix wrong microMIPS opcode encoding
陳韋任 (Wei-Ren Chen) [Wed, 14 Nov 2012 02:49:55 +0000 (10:49 +0800)]
target-mips: fix wrong microMIPS opcode encoding

While reading microMIPS decoding, I found a possible wrong opcode
encoding. According to [1] page 166, the bits 13..12 for MULTU is
0x01 rather than 0x00. Please review, thanks.

[1] MIPS Architecture for Programmers VolumeIV-e: The MIPS DSP
    Application-Specific Extension to the microMIPS32 Architecture

Signed-off-by: Chen Wei-Ren <chenwj@iis.sinica.edu.tw>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips/malta: fix CBUS UART interrupt pin
Aurelien Jarno [Wed, 14 Nov 2012 14:04:42 +0000 (15:04 +0100)]
mips/malta: fix CBUS UART interrupt pin

According to the MIPS Malta Developement Platform User's Manual, the
i8259 interrupt controller is supposed to be connected to the hardware
IRQ0, and the CBUS UART to the hardware interrupt 2.

In QEMU they are both connected to hardware interrupt 0, the CBUS UART
interrupt being wrong. This patch fixes that. It should be noted that
the irq array in QEMU includes the software interrupts, hence
env->irq[2] is the first hardware interrupt.

Cc: Ralf Baechle <ralf@linux-mips.org>
Reviewed-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-i386: Add Haswell CPU model
Eduardo Habkost [Wed, 14 Nov 2012 18:28:54 +0000 (16:28 -0200)]
target-i386: Add Haswell CPU model

Features added to the model, in relation to SandyBridge:

fma       CPUID[1].ECX[12]
pcid      CPUID[1].ECX[17]
movbe     CPUID[1].ECX[22]
fsgsbase  CPUID[EAX=7,ECX=0].EBX[0]
bmi1      CPUID[EAX=7,ECX=0].EBX[3]
hle       CPUID[EAX=7,ECX=0].EBX[4]
avx2      CPUID[EAX=7,ECX=0].EBX[5]
smep      CPUID[EAX=7,ECX=0].EBX[7]
bmi2      CPUID[EAX=7,ECX=0].EBX[8]
erms      CPUID[EAX=7,ECX=0].EBX[9]
invpcid   CPUID[EAX=7,ECX=0].EBX[10]
rtm       CPUID[EAX=7,ECX=0].EBX[11]

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386/cpu: Add new Opteron CPU model
Andre Przywara [Wed, 14 Nov 2012 18:28:53 +0000 (16:28 -0200)]
target-i386/cpu: Add new Opteron CPU model

Add a new base CPU model called Opteron_G5 to model the latest
Opteron CPUs. This increases the model value and model numbers and
adds TBM, F16C and FMA over the latest G4 model.

Signed-off-by: Andre Przywara <osp@andrep.de>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
[ehabkost: edited commit message]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386/cpu: Name new CPUID bits
Andre Przywara [Wed, 14 Nov 2012 18:28:52 +0000 (16:28 -0200)]
target-i386/cpu: Name new CPUID bits

Update QEMU's knowledge of CPUID bit names. This allows to
enable/disable those new features on QEMU's command line when
using KVM and prepares future feature enablement in QEMU.

This adds F16C, RDRAND, LWP, TBM, TopoExt, PerfCtr_Core, PerfCtr_NB,
FSGSBASE, BMI1, AVX2, BMI2, ERMS, PCID, InvPCID, RTM, RDSeed and ADX.

Sources where the AMD BKDG for Family 15h/Model 10h, Intel Software
Developer Manual, and the Linux kernel for the leaf 7 bits.

Signed-off-by: Andre Przywara <osp@andrep.de>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
[ehabkost: added CPUID_EXT_PCID]
[ehabkost: edited commit message]
[ehabkost: rebased against latest qemu.git master]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqapi-types.h: Don't include qemu-common.h
Igor Mammedov [Sun, 19 Aug 2012 23:39:37 +0000 (01:39 +0200)]
qapi-types.h: Don't include qemu-common.h

Needed to prevent build breakage when CPUState becomes a child of
DeviceState.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: include <stdbool.h> too]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoosdep: Move qemu_{open,close}() prototypes
Andreas Färber [Wed, 14 Nov 2012 15:42:39 +0000 (16:42 +0100)]
osdep: Move qemu_{open,close}() prototypes

They are implemented in osdep.c, so keep the prototypes in osdep.h.

Suggested-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
11 years agoqemu-config.h: Include headers it needs
Eduardo Habkost [Tue, 23 Oct 2012 23:29:38 +0000 (21:29 -0200)]
qemu-config.h: Include headers it needs

Include:
- <stdio.h> for FILE
- qemu-option.h for QemuOptsList

Some of those headers were probably being included by accident because
some other headers were including qemu-common.h, but those headers
should eventually stop including qemu-common.h.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agovnc-palette.h: Include <stdbool.h>
Eduardo Habkost [Tue, 23 Oct 2012 23:01:36 +0000 (21:01 -0200)]
vnc-palette.h: Include <stdbool.h>

<stdbool.h> is needed for the 'bool' type, used in the header.

The header is probably being included by accident because some other
headers are including qemu-common.h, but those headers should eventually
stop including qemu-common.h.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqemu-fsdev-dummy.c: Include module.h
Eduardo Habkost [Tue, 23 Oct 2012 21:43:01 +0000 (19:43 -0200)]
qemu-fsdev-dummy.c: Include module.h

module.h is where machine_init() is defined, but qemu-fsdev-dummy.c
doesn't include it.

The header is probably being included by accident because some other
headers are including qemu-common.h, but those headers should eventually
stop including qemu-common.h.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqdev: Split up header so it can be used in cpu.h
Anthony Liguori [Fri, 10 Aug 2012 17:00:43 +0000 (12:00 -0500)]
qdev: Split up header so it can be used in cpu.h

Header file dependency is a frickin' nightmare right now.  cpu.h tends
to get included in our 'include everything' header files but qdev also
needs to include those headers mainly for qdev-properties since it knows
about CharDriverState and friends.

We can solve this for now by splitting out qdev.h along the same lines
that we previously split the C file.  Then cpu.h just needs to include
qdev-core.h.

hw/qdev.h is split into following new headers:
    hw/qdev-core.h
    hw/qdev-properties.h
    hw/qdev-monitor.h

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
[ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the
 original patch (by mistake, I guess)]
[ehabkost: kill qdev_prop_set_vlan() declaration]
[ehabkost: moved get_fw_dev_path() comment to the original location
 (I don't know why it was moved)]
[ehabkost: removed qdev_exists() declaration]
[ehabkost: keep using 'QemuOpts' instead of 'struct QemuOpts', as
 qdev-core.h includes qemu-option.h]

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoMove qemu_irq typedef out of qemu-common.h
Igor Mammedov [Tue, 16 Oct 2012 01:57:21 +0000 (03:57 +0200)]
Move qemu_irq typedef out of qemu-common.h

It's necessary for making CPU child of DEVICE without
causing circular header deps.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[ehabkost: re-added the typedef to hw/irq.h after rebasing]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqemu-common.h: Comment about usage rules
Eduardo Habkost [Tue, 23 Oct 2012 21:44:02 +0000 (19:44 -0200)]
qemu-common.h: Comment about usage rules

Every time we make a tiny change on a header file, we often find
circular header dependency problems. To avoid this nightmare, we need to
stop including qemu-common.h from other headers, and we should gradually
move the declarations from the catch-all qemu-common.h header to their
specific headers.

This simply adds a comment documenting the rules about qemu-common.h,
hoping that people will see it before including qemu-common.h from other
header files, and before adding more declarations to qemu-common.h.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agokvm: Actually remove software breakpoints from list on cleanup
Jan Kiszka [Mon, 12 Nov 2012 14:04:35 +0000 (15:04 +0100)]
kvm: Actually remove software breakpoints from list on cleanup

So far we only removed them from the guest, leaving its states in the
list. This made it impossible for gdb to re-enable breakpoints on the
same address after re-attaching.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoacpi_piix4: fix migration of gpe fields
Marcelo Tosatti [Tue, 30 Oct 2012 23:14:19 +0000 (21:14 -0200)]
acpi_piix4: fix migration of gpe fields

Migrate 16 bytes for en/sts fields (which is the correct size),
increase version to 3, and document how to support incoming
migration from qemu-kvm 1.2.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoMerge remote-tracking branch 'awilliam/tags/vfio-pci-for-qemu-1.3.0-rc0' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:53:40 +0000 (08:53 -0600)]
Merge remote-tracking branch 'awilliam/tags/vfio-pci-for-qemu-1.3.0-rc0' into staging

vfio-pci: KVM INTx accel & common msi_get_message

* awilliam/tags/vfio-pci-for-qemu-1.3.0-rc0:
  vfio-pci: Use common msi_get_message
  vfio-pci: Add KVM INTx acceleration
  linux-headers: Update to 3.7-rc5

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/pixman.v5' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:53:03 +0000 (08:53 -0600)]
Merge remote-tracking branch 'kraxel/pixman.v5' into staging

* kraxel/pixman.v5:
  pixman: cleanup properly on make distclean
  pixman: add licensing info
  pixman: build internal version early
  pixman: pass cflags, add -fPIC
  pixman: disable gtk
  pixman: set --host for cross builds
  pixman: add output dir to include path

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'bonzini/nbd-next' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:51:06 +0000 (08:51 -0600)]
Merge remote-tracking branch 'bonzini/nbd-next' into staging

* bonzini/nbd-next:
  nbd: fixes to read-only handling
  hmp: add NBD server commands
  nbd: disallow nbd-server-add before nbd-server-start
  nbd: force read-only export for read-only devices
  nbd: fix nbd_server_stop crash when no server was running
  nbd: accept URIs
  nbd: accept relative path to Unix socket
  qemu-nbd: initialize main loop before block layer

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:50:45 +0000 (08:50 -0600)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

* bonzini/scsi-next:
  virtio-scsi: use dma_context_memory
  dma: Define dma_context_memory and use in sysbus-ohci
  megasas: Correct target/lun mapping
  scsi-disk: flush cache after disabling it
  megasas: do not include block_int.h
  scsi: remove superfluous call to scsi_device_set_ua
  virtio-scsi: factor checks for VIRTIO_SCSI_S_DRIVER_OK when reporting events
  scsi: do not return short responses for emulated commands

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/usb.70' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:50:18 +0000 (08:50 -0600)]
Merge remote-tracking branch 'kraxel/usb.70' into staging

* kraxel/usb.70:
  ehci: fix migration
  xhci: Fix some DMA host endian bugs
  usb/combined-packet: Move freeing of combined to usb_combined_packet_remove()
  xhci: Add support for packets with both data and an error status
  ehci: Add support for packets with both data and an error status
  ehci: Get rid of the magical PROC_ERR status
  usb-redir: Allow packets to have both data and an error-status
  usb: split packet result into actual_length + status

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'spice/spice.v63' into staging
Anthony Liguori [Wed, 14 Nov 2012 14:49:54 +0000 (08:49 -0600)]
Merge remote-tracking branch 'spice/spice.v63' into staging

* spice/spice.v63:
  spice: fix initialization order
  pflib: unused, remove it.
  spice: switch to pixman
  qxl: call dpy_gfx_resize when entering vga mode
  qxl: fix cursor reset
  hw/qxl: qxl_send_events: nop if stopped
  hw/qxl: guest bug on primary create with stride %4 != 0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopixman: cleanup properly on make distclean
Gerd Hoffmann [Wed, 14 Nov 2012 12:45:55 +0000 (13:45 +0100)]
pixman: cleanup properly on make distclean

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: add licensing info
Gerd Hoffmann [Tue, 13 Nov 2012 08:38:06 +0000 (09:38 +0100)]
pixman: add licensing info

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: build internal version early
Gerd Hoffmann [Mon, 12 Nov 2012 11:18:38 +0000 (12:18 +0100)]
pixman: build internal version early

Signed-off-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: pass cflags, add -fPIC
Gerd Hoffmann [Wed, 14 Nov 2012 12:26:54 +0000 (13:26 +0100)]
pixman: pass cflags, add -fPIC

Pass on CFLAGS to the pixman configure script.
Add -fPIC to the cflags, needed to make the final link succeed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: disable gtk
Gerd Hoffmann [Wed, 7 Nov 2012 10:41:01 +0000 (11:41 +0100)]
pixman: disable gtk

gtk is only needed to build test cases.
Disable it to simplify the build.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: set --host for cross builds
Gerd Hoffmann [Wed, 7 Nov 2012 10:09:52 +0000 (11:09 +0100)]
pixman: set --host for cross builds

Set --host when calling pixman configure while doing cross builds so
pixman's autoconf picks up the cross build tools correctly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agopixman: add output dir to include path
Gerd Hoffmann [Wed, 7 Nov 2012 10:06:23 +0000 (11:06 +0100)]
pixman: add output dir to include path

Needed to make sure the (generated) pixman-version.h file is found.
Based on a patch from Blue Swirl.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agovfio-pci: Use common msi_get_message
Alex Williamson [Tue, 13 Nov 2012 19:27:40 +0000 (12:27 -0700)]
vfio-pci: Use common msi_get_message

We can get rid of our local version now that a helper exists.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
11 years agovfio-pci: Add KVM INTx acceleration
Alex Williamson [Tue, 13 Nov 2012 19:27:40 +0000 (12:27 -0700)]
vfio-pci: Add KVM INTx acceleration

This makes use of the new level irqfd support enabling bypass of qemu
userspace both on INTx injection and unmask.  This significantly
boosts the performance of devices making use of legacy interrupts (ex.
~60% better netperf TCP_RR scores for an e1000e assigned to a Linux
guest and booted with pci=nomsi).  This also avoids flipping mmaps on
and off to simulate EOIs, so greatly improves performance of device
access in addition to interrupt latency.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
11 years agolinux-headers: Update to 3.7-rc5
Alex Williamson [Tue, 13 Nov 2012 19:27:40 +0000 (12:27 -0700)]
linux-headers: Update to 3.7-rc5

update-linux-headers.sh script run against Linux tag v3.7-rc5

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
11 years agonbd: fixes to read-only handling
Paolo Bonzini [Tue, 13 Nov 2012 09:34:17 +0000 (10:34 +0100)]
nbd: fixes to read-only handling

We do not need BLKROSET if the kernel supports setting flags.
Also, always do BLKROSET even for a read-write export, otherwise
the read-only state remains "sticky" after the invocation of
"qemu-nbd -r".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoaio: fix aio_ctx_prepare with idle bottom halves
Paolo Bonzini [Mon, 12 Nov 2012 12:30:10 +0000 (13:30 +0100)]
aio: fix aio_ctx_prepare with idle bottom halves

Commit ed2aec4867f0d5f5de496bb765347b5d0cfe113d changed the return
value of aio_ctx_prepare from false to true when only idle bottom
halves are available.  This broke PC old-style DMA, which uses them.
Fix this by making aio_ctx_prepare return true only when non-idle
bottom halves are scheduled to run.

Reported-by: malc <av1474@comtv.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
11 years agovirtio-scsi: use dma_context_memory
Paolo Bonzini [Tue, 30 Oct 2012 16:31:43 +0000 (17:31 +0100)]
virtio-scsi: use dma_context_memory

Until address_space_rw was introduced, NULL was accepted as a
placeholder for DMA with no IOMMU (to address_space_memory).

This does not work anymore, and dma_context_memory needs to
be specified explicitly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agodma: Define dma_context_memory and use in sysbus-ohci
Peter Maydell [Mon, 29 Oct 2012 01:34:32 +0000 (11:34 +1000)]
dma: Define dma_context_memory and use in sysbus-ohci

Define a new global dma_context_memory which is a DMAContext corresponding
to the global address_space_memory AddressSpace. This can be used by
sysbus peripherals like sysbus-ohci which need to do DMA.

In particular, use it in the sysbus-ohci device, which fixes a
segfault when attempting to use that device.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
11 years agomegasas: Correct target/lun mapping
Hannes Reinecke [Mon, 12 Nov 2012 14:42:42 +0000 (15:42 +0100)]
megasas: Correct target/lun mapping

The structure to reference a logical drive has an unused field,
which can be used to carry the lun ID. This enabled seabios to
establish the proper target/LUN mapping.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoscsi-disk: flush cache after disabling it
Paolo Bonzini [Wed, 31 Oct 2012 16:14:41 +0000 (17:14 +0100)]
scsi-disk: flush cache after disabling it

SBC says that "if an application client changes the WCE bit from one to
zero via a MODE SELECT command, then the device server shall write
any data in volatile cache to non-volatile medium before completing
the command".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agomegasas: do not include block_int.h
Paolo Bonzini [Fri, 28 Sep 2012 14:43:41 +0000 (16:43 +0200)]
megasas: do not include block_int.h

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoscsi: remove superfluous call to scsi_device_set_ua
Paolo Bonzini [Mon, 8 Oct 2012 14:46:54 +0000 (16:46 +0200)]
scsi: remove superfluous call to scsi_device_set_ua

Suggested by Laszlo Ersek.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agovirtio-scsi: factor checks for VIRTIO_SCSI_S_DRIVER_OK when reporting events
Paolo Bonzini [Mon, 8 Oct 2012 14:50:51 +0000 (16:50 +0200)]
virtio-scsi: factor checks for VIRTIO_SCSI_S_DRIVER_OK when reporting events

Suggested by Laszlo Ersek.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoscsi: do not return short responses for emulated commands
Paolo Bonzini [Wed, 10 Oct 2012 10:18:03 +0000 (12:18 +0200)]
scsi: do not return short responses for emulated commands

The inquiry command, for the case of VPD=1, was returning short
responses; the number of returned bytes was just the number of bytes
in the request, without padding to the specified allocation length
with zero bytes.  This is usually harmless, but it is a violation
of the SCSI specification.

To fix this, always pad with zero bytes to r->cmd.xfer in
scsi_disk_emulate_command, and return at most r->buflen bytes
(the size of the buffer for command data) rather than at most
buflen bytes (the number of bytes that was filled in).

Before this patch, "strace sg_inq -p0x83 /dev/sda" would report a
non-zero resid value.  After this patch, it reports resid=0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agohmp: add NBD server commands
Paolo Bonzini [Thu, 23 Aug 2012 09:53:04 +0000 (11:53 +0200)]
hmp: add NBD server commands

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agonbd: disallow nbd-server-add before nbd-server-start
Paolo Bonzini [Mon, 12 Nov 2012 13:25:17 +0000 (14:25 +0100)]
nbd: disallow nbd-server-add before nbd-server-start

It works nicely with the QMP commands, but it adds useless complication
with HMP.  In particular, see the following:

    (qemu) nbd_server_add -w scsi0-hd0
    (qemu) nbd_server_start -a localhost:10809
    NBD server already exporting device scsi0-hd0

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agonbd: force read-only export for read-only devices
Paolo Bonzini [Sun, 4 Nov 2012 11:43:37 +0000 (12:43 +0100)]
nbd: force read-only export for read-only devices

This is the desired behavior for HMP, but it is a better choice for QMP as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agonbd: fix nbd_server_stop crash when no server was running
Paolo Bonzini [Mon, 12 Nov 2012 13:12:54 +0000 (14:12 +0100)]
nbd: fix nbd_server_stop crash when no server was running

This failed on the new assertion of qemu_set_fd_handler2:

qemu-system-x86_64: /home/pbonzini/work/upstream/qemu/iohandler.c:60: qemu_set_fd_handler2: Assertion `fd >= 0' failed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agonbd: accept URIs
Paolo Bonzini [Sun, 4 Nov 2012 12:04:24 +0000 (13:04 +0100)]
nbd: accept URIs

The URI syntax is consistent with the Gluster syntax.  Export names
are specified in the path, preceded by one or more (otherwise unused)
slashes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agonbd: accept relative path to Unix socket
Paolo Bonzini [Sun, 4 Nov 2012 11:56:39 +0000 (12:56 +0100)]
nbd: accept relative path to Unix socket

Adding the "is_unix" member now will simplify the parsing of NBD URIs.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoqemu-nbd: initialize main loop before block layer
Paolo Bonzini [Sat, 3 Nov 2012 17:06:26 +0000 (18:06 +0100)]
qemu-nbd: initialize main loop before block layer

qemu-nbd was broken because they initialized the block layer while
qemu_aio_context was still NULL.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agotcg: properly check that op's output needs to be synced to memory
Kirill Batuzov [Wed, 7 Nov 2012 11:26:38 +0000 (15:26 +0400)]
tcg: properly check that op's output needs to be synced to memory

Fix typo introduced in b3a1be87bac3a6aaa59bb88c1410f170dc9b22d5.

Reported-by: Ruslan Savchenko <ruslan.savchenko@gmail.com>
Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Fix seg fault for LUI when MIPS_DEBUG_DISAS==1.
Eric Johnson [Sat, 10 Nov 2012 03:40:51 +0000 (19:40 -0800)]
target-mips: Fix seg fault for LUI when MIPS_DEBUG_DISAS==1.

The call to gen_logic_imm for OPC_LUI passes -1 for rs.  This
causes the MIPS_DEBUG statement to seg fault due to the deference
of regnames[rs].  This patch fixes that.

Signed-off-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(aurel32: replaced static string formating by a static string)

11 years agotarget-i386: avoid using cpu_single_env
Blue Swirl [Sat, 8 Sep 2012 13:26:02 +0000 (13:26 +0000)]
target-i386: avoid using cpu_single_env

Pass around CPUArchState instead of using global cpu_single_env.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>