]> git.proxmox.com Git - qemu.git/log
qemu.git
11 years agoslirp: Fix error reported by static code analysis
Stefan Weil [Tue, 4 Sep 2012 21:20:36 +0000 (23:20 +0200)]
slirp: Fix error reported by static code analysis

Report from smatch:

slirp/tcp_subr.c:127 tcp_respond(17) error:
 we previously assumed 'tp' could be null (see line 124)

Return if 'tp' is NULL.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit e56afbc54a2132c56931f44bae1992c28119944f)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoslirp: Remove wrong type casts ins debug statements
Stefan Weil [Tue, 4 Sep 2012 21:20:35 +0000 (23:20 +0200)]
slirp: Remove wrong type casts ins debug statements

The type casts of pointers to long are not allowed
when sizeof(pointer) != sizeof(long).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit c4d12a743c73a5b88a8705ca68ff620ce0f8bba7)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agouhci: Don't queue up packets after one with the SPD flag set
Hans de Goede [Wed, 12 Sep 2012 13:08:40 +0000 (15:08 +0200)]
uhci: Don't queue up packets after one with the SPD flag set

Don't queue up packets after a packet with the SPD (short packet detect)
flag set. Since we won't know if the packet will actually be short until it
has completed, and if it is short we should stop the queue.

This fixes a miniature photoframe emulating a USB cdrom with the windows
software for it not working.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 72a04d0c178f01908d74539230d9de64ffc6da19)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Revert usb-redir part of commit 93bfef4c
Hans de Goede [Wed, 12 Sep 2012 13:08:39 +0000 (15:08 +0200)]
usb-redir: Revert usb-redir part of commit 93bfef4c

Commit 93bfef4c6e4b23caea9d51e1099d06433d8835a4 makes qemu-devices
which report the qemu version string to the guest in some way use a
qemu_get_version function which reports a machine-specific version string.

However usb-redir does not expose the qemu version to the guest, only to
the usbredir-host as part of the initial handshake. This can then be logged
on the usbredir-host side for debugging purposes and is otherwise completely
unused! For debugging purposes it is important to have the real qemu version
in there, rather then the machine-specific version.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 35efba2cc6812dc980c336d7b9bf81dbfb5daf00)

Conflicts:

hw/usb/redirect.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Walk async schedule before and after migration
Hans de Goede [Wed, 12 Sep 2012 13:08:33 +0000 (15:08 +0200)]
ehci: Walk async schedule before and after migration

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ceab6f96454fe6589d1b09ce64403c041d79f9d9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Don't set seen to 0 when removing unseen queue-heads
Hans de Goede [Wed, 12 Sep 2012 13:08:32 +0000 (15:08 +0200)]
ehci: Don't set seen to 0 when removing unseen queue-heads

When removing unseen queue-heads from the async queue list, we should not
set the seen flag to 0, as this may cause them to be removed by
ehci_queues_rip_unused() during the next call to ehci_advance_async_state()
if the timer is late or running at a low frequency.

Note:
1) This *may* have caused the instant unlink / relinks described in commit
   9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0

2) Rather then putting more if-s inside ehci_queues_rip_unused, this patch
   instead introduces a new ehci_queues_rip_unseen function.

3) This patch also makes it save to call ehci_queues_rip_unseen() multiple
   times, which gets used in the folluw up patch titled:
   "ehci: Walk async schedule before and after migration"

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 8f5457eb04140714eaf57a99bc08dc661d83fa87)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconfigure: usbredir fixes
Aurelien Jarno [Tue, 11 Sep 2012 18:57:58 +0000 (20:57 +0200)]
configure: usbredir fixes

usbredir is only used by system emulation, so add the libraries to
libs_softmmu instead of LIBS.

Cc: Michael Tokarev <mjt@tls.msk.ru>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 56ab2ad177dc43d474dc0a0bd84e81ef00f31e11)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agohw/qxl: tracing fixes
Alon Levy [Wed, 12 Sep 2012 13:13:26 +0000 (16:13 +0300)]
hw/qxl: tracing fixes

Add two new trace events:
qxl_send_events(int qid, uint32_t events) "%d %d"
qxl_set_guest_bug(int qid) "%d"

Change qxl_io_unexpected_vga_mode parameters to be equivalent to those
of qxl_io_write for easier grouping under a single systemtap probe.

Change d to qxl in one place.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 917ae08ca1565aab2d10c8b6269cd905d6c5c05b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoblock: Don't forget to delete temporary file
Dunrong Huang [Wed, 5 Sep 2012 13:26:22 +0000 (21:26 +0800)]
block: Don't forget to delete temporary file

The caller would not delete temporary file after failed get_tmp_filename().

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit fe235a06e1e008dedd2ac3cc0a3a655169ce9b33)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoDon't require encryption password for 'qemu-img info' command
Daniel P. Berrange [Mon, 10 Sep 2012 11:11:31 +0000 (12:11 +0100)]
Don't require encryption password for 'qemu-img info' command

The encryption password is only required if I/O is going to be
performed on a disk image. The 'qemu-img info' command merely
reports metadata, so it should not ask for a decryption password

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit f0536bb848ad6eb2709a7dc675f261bd160c751b)

Conflicts:

qemu-img.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoahci: properly reset PxCMD on HBA reset
Jason Baron [Tue, 4 Sep 2012 20:08:08 +0000 (16:08 -0400)]
ahci: properly reset PxCMD on HBA reset

While testing q35, I found that windows 7 (specifically, windows 7 ultimate
with sp1 x64), wouldn't install because it can't find the cdrom or disk drive.
The failure message is: 'A required cd/dvd device driver is missing. If you
have a driver floppy disk, CD, DVD, or USB flash drive, please insert it now.'
This can also be reproduced on piix by adding an ahci controller, and
observing that windows 7 does not see any devices behind it.

The problem is that when windows issues a HBA reset, qemu does not reset the
individual ports' PxCMD register. Windows 7 then reads back the PxCMD register
and presumably assumes that the ahci controller has already been initialized.
Windows then never sets up the PxIE register to enable interrupts, and thus it
never gets irqs back when it sends ata device inquiry commands.

This change brings qemu into ahci 1.3 specification compliance.

Section 10.4.3 HBA Reset:

"
When GHC.HR is set to '1', GHC.AE, GHC.IE, the IS register, and all port
register fields (except PxFB/PxFBU/PxCLB/PxCLBU) that are not HwInit in the
HBA's register memory space are reset.
"

I've also re-tested Fedora 16 and 17 to verify that they continue to work with
this change.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 2a4f4f34e6fe55f4c82507c3e7ec9b58c2e24ad4)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoblock: fix block tray status
Pavel Hrdina [Thu, 9 Aug 2012 10:44:48 +0000 (12:44 +0200)]
block: fix block tray status

The tray status should change also if you eject empty block device.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 9ca111544c64b5abed2e79cf52e19a8f227b347b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovdi: Fix warning from clang
Stefan Weil [Fri, 17 Aug 2012 13:23:24 +0000 (15:23 +0200)]
vdi: Fix warning from clang

ccc-analyzer reports these warnings:

block/vdi.c:704:13: warning: Dereference of null pointer
            bmap[i] = VDI_UNALLOCATED;
            ^
block/vdi.c:702:13: warning: Dereference of null pointer
            bmap[i] = i;
            ^

Moving some code into the if block fixes this.
It also avoids calling function write with 0 bytes of data.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 514f21a5d4613e495adc2e2dd48f18091454efb8)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoblock/curl: Fix wrong free statement
Stefan Weil [Sat, 1 Sep 2012 09:06:45 +0000 (11:06 +0200)]
block/curl: Fix wrong free statement

Report from smatch:
block/curl.c:546 curl_close(21) info: redundant null check on s->url calling free()

The check was redundant, and free was also wrong because the memory
was allocated using g_strdup.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 45724d6d02383b0d7d4a90e05787fca7c55cb070)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoide: Fix error messages from static code analysis (no real error)
Stefan Weil [Mon, 3 Sep 2012 20:13:56 +0000 (22:13 +0200)]
ide: Fix error messages from static code analysis (no real error)

Report from smatch:
hw/ide/core.c:1472 ide_exec_cmd(423) error: buffer overflow 'smart_attributes' 8 <= 29
hw/ide/core.c:1474 ide_exec_cmd(425) error: buffer overflow 'smart_attributes' 8 <= 29
hw/ide/core.c:1475 ide_exec_cmd(426) error: buffer overflow 'smart_attributes' 8 <= 29
...

The upper limit of 30 was never reached because both for loops terminated
when 'smart_attributes' reached end of list, so there was no real buffer
overflow.

Nevertheless, changing the code not only fixes the error report, but also
reduces the size of smart_attributes and simplifies the for loops.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 1e53537fdaa4657d11f130a0f2673fcfb1956381)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agosheepdog: fix savevm and loadvm
MORITA Kazutaka [Wed, 29 Aug 2012 18:39:45 +0000 (03:39 +0900)]
sheepdog: fix savevm and loadvm

This patch sets data to be sent to Sheepdog correctly and fixes savevm
and loadvm operations on a Sheepdog image.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 1f7a48de4467f31afc51169122453318efdb0f33)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Don't process too much frames in 1 timer tick (v2)
Hans de Goede [Mon, 10 Sep 2012 10:44:11 +0000 (12:44 +0200)]
ehci: Don't process too much frames in 1 timer tick (v2)

The Linux ehci isoc scheduling code fills the entire schedule ahead of
time minus 80 frames. If we make a large jump in where we are in the
schedule, ie 40 frames, then the scheduler all of a sudden will only have
40 frames left to work in, causing it to fail packet submissions
with error -27 (-EFBIG).

Changes in v2:
-Don't hardcode a maximum number of frames to process in one tick, instead:
 -Process a minimum number of frames to ensure we do eventually catch up
 -Stop (after the minimum number) when the guest has requested an irq

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 8f74ed1e43263293301031a10e440549bab19a6e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Fix interrupts stopping when Interrupt Threshold Control is 8
Hans de Goede [Mon, 10 Sep 2012 10:44:10 +0000 (12:44 +0200)]
ehci: Fix interrupts stopping when Interrupt Threshold Control is 8

If Interrupt Threshold Control is 8 or a multiple of 8, then
s->usbsts_frindex can become exactly 0x4000, at which point
(s->usbsts_frindex > s->frindex) will never become true, as
s->usbsts_frindex will not be lowered / reset in this case.

This patch fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ffa1f2e088eb7e3d57f2fc35f21e7bdb23e592c5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: switch to new-style memory ops
Gerd Hoffmann [Thu, 6 Sep 2012 09:24:51 +0000 (11:24 +0200)]
ehci: switch to new-style memory ops

Also register different memory regions for capabilities,
operational registers and port status registers.  Create
separate tracepoints for operational regs and port status
regs.  Ditch a bunch of sanity checks because the memory
core will do this for us now.

Offloading the byte, word and dword access handling to the
memory core also has the side effect of fixing ehci register
access on bigendian hosts.

Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 3e4f910c8d490a1490409a7e381dbbb229f9d272)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqxl: better cleanup for surface destroy
Uri Lublin [Tue, 11 Sep 2012 07:09:58 +0000 (10:09 +0300)]
qxl: better cleanup for surface destroy

Add back a call to qxl_spice_destroy_surface_wait_complete() in qxl_spice_destroy_surface_wait(),
that was removed by commit c480bb7da465186b84d8427e068ef7502e47ffbf

It is needed to complete surface-removal cleanup, for non async.
For async, qxl_spice_destroy_surface_wait_complete is called upon operation completion.

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 753b8b0d77ba1b343a35f9679cc777ea10a62bba)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-host: allow emulated (non-async) control requests without USBPacket
Gerd Hoffmann [Thu, 6 Sep 2012 10:03:41 +0000 (12:03 +0200)]
usb-host: allow emulated (non-async) control requests without USBPacket

xhci needs this for USB_REQ_SET_ADDRESS due to the way
usb addressing is handled by the xhci hardware.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 63587e31353b6652cadfcfb869f5692a2b69daeb)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqxl: dont update invalid area
Dunrong Huang [Thu, 30 Aug 2012 16:44:44 +0000 (00:44 +0800)]
qxl: dont update invalid area

This patch fixes the following error:

$ ~/usr/bin/qemu-system-x86_64 -enable-kvm -m 1024 -spice port=5900,disable-ticketing -vga qxl -cdrom ~/Images/linuxmint-13-mate-dvd-32bit.iso
(/home/mathslinux/usr/bin/qemu-system-x86_64:10068): SpiceWorker-CRITICAL **: red_worker.c:4599:red_update_area: condition `area->left >= 0 && area->top >= 0 && area->left < area->right && area->top < area->bottom' failed
Aborted

spice server terminates QEMU process if we pass invalid area to it,
so dont update those invalid areas.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ccc2960d654a233a6ed415b37d8ff41728d817c5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoxhci: allow bytewise capability register reads
Gerd Hoffmann [Tue, 4 Sep 2012 12:48:03 +0000 (14:48 +0200)]
xhci: allow bytewise capability register reads

Some guests need this according to
Alejandro Martinez Ruiz <alex@securiforest.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 6ee021d41078844df60a3a466e3829a3e82776f3)

Conflicts:

hw/usb/hcd-xhci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoxhci: fix runtime write tracepoint
Gerd Hoffmann [Thu, 30 Aug 2012 10:42:32 +0000 (12:42 +0200)]
xhci: fix runtime write tracepoint

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 8e9f18b6db1cd67f0a7efd7d0285bee489445197)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoxhci: drop buffering
Gerd Hoffmann [Fri, 17 Aug 2012 09:04:36 +0000 (11:04 +0200)]
xhci: drop buffering

This patch splits the xhci_xfer_data function into three.
The xhci_xfer_data function used to do does two things:

  (1) copy transfer data between guest memory and a temporary buffer.
  (2) report transfer results to the guest using events.

Now we three functions to handle this:

  (1) xhci_xfer_map creates a scatter list for the transfer and
      uses that (instead of the temporary buffer) to build a
      USBPacket.
  (2) xhci_xfer_unmap undoes the mapping.
  (3) xhci_xfer_report sends out events.

The patch also fixes reporting of transaction errors which must be
reported unconditinally, not only in case the guest asks for it
using the ISP flag.

[ v2: fix warning ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit d5a15814b413869667b2a3215772986885be574a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoxhci: rip out background transfer code
Gerd Hoffmann [Fri, 17 Aug 2012 12:05:21 +0000 (14:05 +0200)]
xhci: rip out background transfer code

original xhci code (the one which used libusb directly) used to use
'background transfers' for iso streams.  In upstream qemu the iso
stream buffering is handled by usb-host & usb-redir, so we will
never ever need this.  It has been left in as reference, but is dead
code anyway.  Rip it out.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 331e9406f152b6bae6859a153d36e5076c58901d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-audio: fix usb version
Gerd Hoffmann [Tue, 28 Aug 2012 14:43:34 +0000 (16:43 +0200)]
usb-audio: fix usb version

usb-audio is a full speed (1.1) device,
but bcdUSB claims it is usb 2.0.  Fix it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2bbd086c41a00dc4384727ec895a94890c688eb5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoBetter name usb braille device
Samuel Thibault [Thu, 23 Aug 2012 07:59:27 +0000 (09:59 +0200)]
Better name usb braille device

Windows users need to know that they have to use the Baum driver to make
the qemu braille device work.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2964cd9bfa5100e433471d3e3fedcc9d62891894)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Return babble when getting more bulk data then requested
Hans de Goede [Tue, 28 Aug 2012 09:33:47 +0000 (11:33 +0200)]
usb-redir: Return babble when getting more bulk data then requested

Babble is the appropriate error in this case (rather then signalling a stall).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2979a36183a3902cd75665e7c6bbc8668668fd17)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Move to core packet id and queue handling
Hans de Goede [Tue, 28 Aug 2012 09:30:13 +0000 (11:30 +0200)]
usb-redir: Move to core packet id and queue handling

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit de550a6afb468ed3b8171019e19b63ae8254886d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Get rid of unused async-struct dev member
Hans de Goede [Tue, 28 Aug 2012 07:08:45 +0000 (09:08 +0200)]
usb-redir: Get rid of unused async-struct dev member

This is a preparation patch for completely getting rid of the async-packet
struct in usb-redir, instead relying on the (new) per ep queues in the
qemu usb core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 206e7f20fe7b920b362bcc02608680c5d5527f2a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Get rid of local shadow copy of packet headers
Hans de Goede [Tue, 28 Aug 2012 07:05:38 +0000 (09:05 +0200)]
usb-redir: Get rid of local shadow copy of packet headers

The shadow copy only serves as an extra check (besides the packet-id) to
ensure the packet we get back is a reply to the packet we think it is.

This check has never triggered in all the time usb-redir is in use now,
and since the verified data in the returned packet-header is not used
otherwise, removing the check does not open any possibilities for the
usbredirhost to confuse us.

This is a preparation patch for completely getting rid of the async-packet
struct in usb-redir, instead relying on the (new) per ep queues in the
qemu usb core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 104981d52b63dc3d68f39d4442881c667f44bbb9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Get rid of async-struct get member
Hans de Goede [Mon, 27 Aug 2012 14:33:08 +0000 (16:33 +0200)]
usb-redir: Get rid of async-struct get member

This is a preparation patch for completely getting rid of the async-packet
struct in usb-redir, instead relying on the (new) per ep queues in the
qemu usb core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit cb897117cdedd488f19985c8ec5ea05971103a27)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Don't delay handling of open events to a bottom half
Hans de Goede [Thu, 23 Aug 2012 14:37:19 +0000 (16:37 +0200)]
usb-redir: Don't delay handling of open events to a bottom half

There is no need for this, and doing so means that a backend trying to
write immediately after an open event will see qemu_chr_be_can_write
returning 0, which not all backends handle well as there is no wakeup
mechanism to detect when the frontend does become writable.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ed9873bfbf145c084d039baab08c63b9d67e7bd3)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Never return USB_RET_NAK for async handled packets
Hans de Goede [Fri, 17 Aug 2012 15:27:08 +0000 (17:27 +0200)]
usb-redir: Never return USB_RET_NAK for async handled packets

USB_RET_NAK is not a valid response for async handled packets (and will
trigger an assert as such).

Also drop the warning when receiving a status of cancelled for packets not
cancelled by qemu itself, this can happen when a device gets unredirected
by the usbredir-host while transfers are pending.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 181133404f520fab40a3ad40d935d91cf3cf546c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Correct a comment in fetchqtd packet processing
Hans de Goede [Mon, 3 Sep 2012 10:17:48 +0000 (12:17 +0200)]
ehci: Correct a comment in fetchqtd packet processing

Since my previous comment said "Should never happen", I tried changing the
next line to an assert(0), which did not go well, which as the new comments
explains is logical if you think about it for a moment.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit cf1f81691d1998fa8fe5bfcb8b498fb3723cf3c3)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Handle USB_RET_PROCERR in ehci_fill_queue
Hans de Goede [Mon, 3 Sep 2012 09:35:58 +0000 (11:35 +0200)]
ehci: Handle USB_RET_PROCERR in ehci_fill_queue

USB_RET_PROCERR can be triggered by the guest (by for example requesting more
then BUFFSIZE bytes), so don't assert on it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit eff6dce79bd7ad3c16d75c5e55b5a2a137ba6a60)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Fix memory leak in handling of NAK-ed packets
Hans de Goede [Mon, 3 Sep 2012 09:01:13 +0000 (11:01 +0200)]
ehci: Fix memory leak in handling of NAK-ed packets

Currently each time we try to execute a NAK-ed packet we redo
ehci_init_transfer, and usb_packet_map, re-allocing (without freeing) the
sg list every time.

This patch fixes this, it does this by introducing another async state, so
that we also properly cleanup a NAK-ed packet on cancel.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ef5b234477df80700b128f561f5877a0688a70c8)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Add some additional ehci_trace_guest_bug() calls
Hans de Goede [Mon, 3 Sep 2012 08:22:16 +0000 (10:22 +0200)]
ehci: Add some additional ehci_trace_guest_bug() calls

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 3a8ca08e01ea4baafff2a513655008cdd00feebf)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: add doorbell trace events
Gerd Hoffmann [Fri, 31 Aug 2012 10:41:43 +0000 (12:41 +0200)]
ehci: add doorbell trace events

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 1defcbd1e81d67476b6e4e486bcd4d869162900d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: trace guest bugs
Gerd Hoffmann [Fri, 31 Aug 2012 08:44:21 +0000 (10:44 +0200)]
ehci: trace guest bugs

make qemu_queue_{cancel,reset} return the number of packets released,
so the caller can figure whenever there have been active packets even
though there shouldn't have been any.  Add tracepoint to log this.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 5c514681abbb3ae2f61f517c1aa3197f2f3ca93c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: check for EHCI_ASYNC_FINISHED first in ehci_free_packet
Gerd Hoffmann [Fri, 31 Aug 2012 08:31:54 +0000 (10:31 +0200)]
ehci: check for EHCI_ASYNC_FINISHED first in ehci_free_packet

Otherwise we'll see the packet free twice in the trace log even though
it actually happens only once.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 616789cde2a83fad5e634880fd20214f0c984fd5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Properly report completed but not yet processed packets to the guest
Hans de Goede [Thu, 30 Aug 2012 13:18:24 +0000 (15:18 +0200)]
ehci: Properly report completed but not yet processed packets to the guest

Reported packets which have completed before being cancelled as such to the
host. Note that the new code path this patch adds is untested since it I've
been unable to actually trigger the race which needs this code path.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 4b63a0df3bda8a2c278e45d9d94d9ba6d5791d8d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Properly cleanup packets on cancel
Hans de Goede [Thu, 30 Aug 2012 13:00:33 +0000 (15:00 +0200)]
ehci: Properly cleanup packets on cancel

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 0e7953525f52aa6c098dc0c1ce0b4a80ce82da45)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Update copyright headers to reflect recent work
Hans de Goede [Tue, 28 Aug 2012 14:21:12 +0000 (16:21 +0200)]
ehci: Update copyright headers to reflect recent work

Update copyright headers to reflect all the work Gerd and I have been doing
on the EHCI emulation.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 522079dd4461c38b9a88bf31a65ea038c5b2be45)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Validate qh is not changed unexpectedly by the guest
Hans de Goede [Wed, 29 Aug 2012 08:37:37 +0000 (10:37 +0200)]
ehci: Validate qh is not changed unexpectedly by the guest

-combine the qh check with the check for devaddr changes
-also ensure that p gets set to NULL when the queue gets cancelled on
 devaddr change, which was not done properly before this patch

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit dafe31fc2a8653b535d58f8c7b250c0827b14420)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoRevert "ehci: don't flush cache on doorbell rings."
Hans de Goede [Wed, 29 Aug 2012 08:12:52 +0000 (10:12 +0200)]
Revert "ehci: don't flush cache on doorbell rings."

This reverts commit 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0, which got
added to fix an issue where the real, underlying cause was not stopping
the ep queue on an error.

Now that the underlying cause is fixed by the "usb: Halt ep queue and
cancel pending packets on a packet error" patch, the "don't flush" fix
is no longer needed.

Not only is it not needed, it causes us to see cancellations (unlinks)
done by the Linux EHCI driver too late, which in combination with the new
usb-core packet-id generation where qtd addresses are used as ids, causes
duplicate ids for in flight packets.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 66f092d25697e11847b61d761c38ddebedaed8d1)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-core: Allow the first packet of a pipelined ep to complete immediately
Hans de Goede [Mon, 3 Sep 2012 10:48:49 +0000 (12:48 +0200)]
usb-core: Allow the first packet of a pipelined ep to complete immediately

This can happen with usb-redir live-migration when the packet gets re-queued
after the migration and the original queuing from the migration source side
has already finished.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 9c1f67654ab611553bbfca54a1e0922728c25760)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-core: Add a usb_ep_find_packet_by_id() helper function
Hans de Goede [Tue, 28 Aug 2012 07:43:18 +0000 (09:43 +0200)]
usb-core: Add a usb_ep_find_packet_by_id() helper function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit c13a9e61366cc3e28299d8faeb65e65c6e5964cf)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-core: Don't set packet state to complete on a nak
Hans de Goede [Mon, 3 Sep 2012 10:33:44 +0000 (12:33 +0200)]
usb-core: Don't set packet state to complete on a nak

This way the hcd can re-use the same packet to retry without needing
to re-init it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit cc40997489260f405aecccd30d4626ceee862502)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb: controllers do not need to check for babble themselves
Hans de Goede [Fri, 17 Aug 2012 09:39:16 +0000 (11:39 +0200)]
usb: controllers do not need to check for babble themselves

If an (emulated) usb-device tries to write more data to a packet then
its iov len, this will trigger an assert in usb_packet_copy(), and if
a driver somehow circumvents that check and writes more data to the
iov then there is space, we have a much bigger problem then not correctly
reporting babble to the guest.

In practice babble will only happen with (real) redirected devices, and there
both the usb-host os and the qemu usb-device code already check for it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 45b339b18c660eb85af2ba25bfcaed5469660d77)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoAdd ability to force enable/disable of tools build
Daniel P. Berrange [Mon, 10 Sep 2012 11:26:29 +0000 (12:26 +0100)]
Add ability to force enable/disable of tools build

The qemu-img, qemu-nbd and qemu-io tools are built conditionally
based on whether any softmmu target is enabled. These are useful
self-contained tools which can be used in many other scenarios.
Add new --enable-tools/--disable-tools args to configure to allow
the user to explicitly turn on / off their build. The default
behaviour is now to build these tools are all times, regardless
of whether any softmmu target is enabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 4b1c11fd20e8901f04a2d9c225cd10fc05a762ff)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agosocket: don't attempt to reconnect a TCP socket in server mode
Anthony Liguori [Wed, 5 Sep 2012 18:52:49 +0000 (13:52 -0500)]
socket: don't attempt to reconnect a TCP socket in server mode

Commit c3767ed0eb5d0bb25fe409ae5dec06e3411ff1b6 introduced a possible SEGV when
using a socket chardev with server=on because it assumes that all TCP sockets
are in client mode.

This patch adds a check to only reconnect when in client mode.

Cc: Lei Li <lilei@linux.vnet.ibm.com>
Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 455aa1e0818653c41fd794435b982426ce21ba2f)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agouse --libexecdir instead of ignoring it first and reinventing it later
Michael Tokarev [Wed, 6 Jun 2012 21:11:00 +0000 (01:11 +0400)]
use --libexecdir instead of ignoring it first and reinventing it later

Commit 7b93fadf3a38d1ed65ea5536a52efc2772c6e3b8 "Add basic version
of bridge helper" put the bridge helper executable into a fixed
${prefix}/libexec/ location, instead of using ${libexecdir} for
this.  At the same time, --libexecdir is being happily ignored
by ./configure.  Even more, the same patch sets unused $libexecdir
variable in the generated config-host.mak, and uses fixed string
(\${prefix}/libexecdir) for the bridge helper binary.

Fix this braindamage by introducing $libexecdir variable, using
it for the bridge helper binary, and recognizing --libexecdir.

This patch is applicable to stable-1.1.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: Richa Marwaha <rmarwah@linux.vnet.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 8bf188aa18ef7a8355d9edbd43871d590468c4ed)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agohw/mcf5206: Fix buffer overflow for MBAR read / write
Stefan Weil [Tue, 4 Sep 2012 17:37:39 +0000 (19:37 +0200)]
hw/mcf5206: Fix buffer overflow for MBAR read / write

Report from smatch:

mcf5206.c:384 m5206_mbar_readb(7) error: buffer overflow 'm5206_mbar_width' 128 <= 128
mcf5206.c:403 m5206_mbar_readw(8) error: buffer overflow 'm5206_mbar_width' 128 <= 128
mcf5206.c:427 m5206_mbar_readl(8) error: buffer overflow 'm5206_mbar_width' 128 <= 128
mcf5206.c:451 m5206_mbar_writeb(9) error: buffer overflow 'm5206_mbar_width' 128 <= 128
mcf5206.c:475 m5206_mbar_writew(9) error: buffer overflow 'm5206_mbar_width' 128 <= 128
mcf5206.c:503 m5206_mbar_writel(9) error: buffer overflow 'm5206_mbar_width' 128 <= 128

m5206_mbar_width has 0x80 elements and supports 0 <= offset < 0x200.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit a32354e206895400d17c3de9a8df1de96d3df289)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agohw/wm8750: Fix potential buffer overflow
Stefan Weil [Mon, 3 Sep 2012 20:56:00 +0000 (22:56 +0200)]
hw/wm8750: Fix potential buffer overflow

Report from smatch:

hw/wm8750.c:369 wm8750_tx(12) error: buffer overflow 's->i2c_data' 2 <= 2

It looks like the preprocessor statements were simply misplaced.

Replace also __FUNCTION__ by __func__ to please checkpatch.pl.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 149eeb5fe57b853081e8059575d91b8a58a4f96c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu: Use valgrind annotations to mark kvm guest memory as defined
Christian Borntraeger [Fri, 10 Aug 2012 13:11:45 +0000 (15:11 +0200)]
qemu: Use valgrind annotations to mark kvm guest memory as defined

valgrind with kvm produces a big amount of false positives regarding
"Conditional jump or move depends on uninitialised value(s)". This
happens because the guest memory is allocated with qemu_vmalloc which
boils down posix_memalign etc. This function is (correctly) considered
by valgrind as returning undefined memory.

Since valgrind is based on jitting code, it will not be able to see
changes made by the guest to guest memory if this is done by KVM_RUN,
thus keeping most of the guest memory undefined.

Now lots of places in qemu will then use guest memory to change behaviour.
To avoid the flood of these messages, lets declare the whole guest
memory as defined. This will reduce the noise and allows us to see real
problems.

In the future we might want to make this conditional, since there
is actually something that we can use those false positives for:
These messages will point to code that depends on guest memory, so
we can use these backtraces to actually make an audit that is focussed
only at those code places. For normal development we dont want to
see those messages, though.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 62fe83318d2fc5b31f473d66326910d94c1c4907)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomusicpal: Fix flash mapping
Jan Kiszka [Sat, 8 Sep 2012 09:52:39 +0000 (11:52 +0200)]
musicpal: Fix flash mapping

The old arithmetic assumed 32 physical address bits which is no longer
true for ARM since 3cc0cd61f4.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit 0c267217ca9985e6d118ec8368bebd382db7a099)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoAdd MAINTAINERS entry for leon3
Fabien Chouteau [Tue, 22 May 2012 08:14:28 +0000 (10:14 +0200)]
Add MAINTAINERS entry for leon3

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit ce6c760c37b9a88db87c5b9b9bf39ca866e570f6)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoMIPS/user: Fix reset CPU state initialization
Maciej W. Rozycki [Fri, 8 Jun 2012 01:04:40 +0000 (02:04 +0100)]
MIPS/user: Fix reset CPU state initialization

 This change updates the CPU reset sequence to use a common piece of code
that figures out CPU state flags, fixing the problem with MIPS_HFLAG_COP1X
not being set where applicable that causes floating-point MADD family
instructions (and other instructions from the MIPS IV FP subset) to trap.

 As compute_hflags is now shared between op_helper.c and translate.c, the
function is now moved to a common header.  There are no changes to this
function.

 The problem was seen with the 24Kf MIPS32r2 processor in user emulation.
The new approach prevents system and user emulation from diverging -- all
the hflags state is initialized in one place now.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 03e6e5017757645f00b2f3b4f3a257973985e455)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agolan9118: fix multicast filtering
Aurelien Jarno [Sun, 10 Jun 2012 21:18:44 +0000 (23:18 +0200)]
lan9118: fix multicast filtering

The lan9118 emulation tries to compute the multicast index by calling
directly the crc32() function from zlib, but fails to get the correct
result.

Use the common compute_mcast_idx() function instead, which gives the
correct result. This fixes IPv6 support.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 449bc90e1f2e2fbafb64eb0c76d16c9352b0d2df)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agofix entry pointer for ELF kernels loaded with -kernel option
Henning Schild [Wed, 5 Sep 2012 12:56:39 +0000 (14:56 +0200)]
fix entry pointer for ELF kernels loaded with -kernel option

 Find a hopefully proper patch attached. Take it or leave it.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Henning Schild <henning@hennsch.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 7e9c7ffe9fd9dfc3d0168dd584936db8144b230b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agopcie_aer: clear cmask for Advanced Error Interrupt Message Number
Jason Baron [Tue, 4 Sep 2012 20:22:46 +0000 (16:22 -0400)]
pcie_aer: clear cmask for Advanced Error Interrupt Message Number

The Advanced Error Interrupt Message Number (bits 31:27 of the Root
Error Status Register) is updated when the number of msi messages assigned to a
device changes. Migration of windows 7 on q35 chipset failed because the check
in get_pci_config_device() fails due to cmask being set on these bits. Its valid
to update these bits and we must restore this state across migration.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0e180d9c8a7429c55d23d2e7855f1e490a063aaa)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agopcie: drop version_id field for live migration
Jason Baron [Wed, 8 Aug 2012 18:29:12 +0000 (14:29 -0400)]
pcie: drop version_id field for live migration

While testing q35 live migration, I found that the migration would abort with
the following error: "Unknown savevm section type 76".

The error is due to this check failing in 'vmstate_load_state()':

    while(field->name) {
        if ((field->field_exists &&
             field->field_exists(opaque, version_id)) ||
            (!field->field_exists &&
             field->version_id <= version_id)) {

The VMSTATE_PCIE_DEVICE() currently has a 'version_id' set to 2. However,
'version_id' in the above check is 1. And thus we fail to load the pcie device
field. Further the code returns to 'qemu_loadvm_state()' which produces the
error that I saw.

I'm proposing to fix this by simply dropping the 'version_id' field from
VMSTATE_PCIE_DEVICE(). VMSTATE_PCI_DEVICE() defines no such field and further
the vmstate_pcie_device that VMSTATE_PCI_DEVICE() refers to is already
versioned. Thus, any versioning issues could be detected at the vmsd level.

Taking a step back, I think that the 'field->version_id' should be compared
against a saved version number for the field not the 'version_id'. Futhermore,
once vmstate_load_state() is called recursively on another vmsd, the check of:

    if (version_id > vmsd->version_id) {
        return -EINVAL;
    }

Will never fail since version_id is always equal to vmsd->version_id. So I'm
wondering why we aren't storing the vmsd version id of the source in the
migration stream?

This patch also renames the 'name' field of vmstate_pcie_device from:
PCIDevice -> PCIEDevice to differentiate it from vmstate_pci_device.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 1de53459272d89c52bb21b45d5d970de40fbb642)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agojson-parser: Fix potential NULL pointer segfault
Stefan Weil [Mon, 3 Sep 2012 19:19:11 +0000 (21:19 +0200)]
json-parser: Fix potential NULL pointer segfault

Report from smatch:
json-parser.c:474 parse_object(62) error: potential null derefence 'dict'.
json-parser.c:553 parse_array(75) error: potential null derefence 'list'.

Label 'out' in json-parser.c can be called with list == NULL
which is passed to QDECREF.

Modify QDECREF to handle a NULL argument (inline function qobject_decref
already handles them, too).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 149474c93490e1c66f838391bd491db83136d91d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqapi: Fix potential NULL pointer segfault
Stefan Weil [Sat, 1 Sep 2012 07:30:39 +0000 (09:30 +0200)]
qapi: Fix potential NULL pointer segfault

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
 we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
 we previously assumed 'obj' could be null (see line 2431)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 227ccf6bff234c29974c2c18ecd3a29e6b965e3d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agofix doc of using raw values with sendkey
Amos Kong [Fri, 31 Aug 2012 02:56:20 +0000 (10:56 +0800)]
fix doc of using raw values with sendkey

(qemu) sendkey a
(qemu) sendkey 0x1e
(qemu) sendkey #0x1e
 unknown key: '#0x1e'

The last command doesn't work, '#' is not requested before
raw values, and the raw value in decimal format is not supported.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 886cc706ce5d4d3d1c296f028ddc2991cfbe3bbe)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconfigure: print spice-protocol and spice-server versions
Alon Levy [Wed, 22 Aug 2012 08:16:26 +0000 (11:16 +0300)]
configure: print spice-protocol and spice-server versions

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2e0e3c399aa8067148055b9ea0edb822c5b584d2)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqxl: add QXL_IO_MONITORS_CONFIG_ASYNC
Alon Levy [Wed, 22 Aug 2012 08:16:25 +0000 (11:16 +0300)]
qxl: add QXL_IO_MONITORS_CONFIG_ASYNC

Revision bumped to 4 for new IO support, enabled for spice-server >=
0.11.1. New io enabled if revision is 4. Revision can be set to 4.

[ kraxel: 3 continues to be the default revision.  Once we have a new
          stable spice-server release and the qemu patches to enable
          the new bits merged we'll go flip the switch and make rev4
          the default ]

This io calls the corresponding new spice api
spice_qxl_monitors_config_async to let spice-server read a new guest set
monitors config and notify the client.

On migration reissue spice_qxl_monitors_config_async.

RHBZ: 770842

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
fixup

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 020af1c45fec664d5d4cf3b8e5117f8bc1d691f2)

Conflicts:

hw/qxl.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqxl/update_area_io: guest_bug on invalid parameters
Alon Levy [Tue, 21 Aug 2012 10:51:31 +0000 (13:51 +0300)]
qxl/update_area_io: guest_bug on invalid parameters

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 511b13e2c9b426b3c56060909693de5097f0b496)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: increase the verbosity of spice section in "qemu --help"
Yonit Halperin [Tue, 21 Aug 2012 10:54:20 +0000 (13:54 +0300)]
spice: increase the verbosity of spice section in "qemu --help"

Added all spice options to the help string. This can be used by libvirt
to determine which spice related features are supported by qemu.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 27af778828db9aa893fa1de928744141e5de20e5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: adding seamless-migration option to the command line
Yonit Halperin [Tue, 21 Aug 2012 08:51:59 +0000 (11:51 +0300)]
spice: adding seamless-migration option to the command line

The seamless-migration flag is required in order to identify
whether libvirt supports the new QEVENT_SPICE_MIGRATE_COMPLETED or not
(by default the flag is off).
New libvirt versions that wait for QEVENT_SPICE_MIGRATE_COMPLETED should turn on this flag.
When this flag is off, spice fallbacks to its old migration method, which
can result in data loss.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 8c9570530c819821b9b5cc3113d2b2966afe7621)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: add 'migrated' flag to spice info
Yonit Halperin [Tue, 21 Aug 2012 08:51:58 +0000 (11:51 +0300)]
spice: add 'migrated' flag to spice info

The flag is 'true' when spice migration has completed on the src side.
It is needed for a case where libvirt dies before migration completes
and it misses the event QEVENT_SPICE_MIGRATE_COMPLETED.
When libvirt is restored and queries the migration status, it also needs
to query spice and check if its migration has completed.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 61c4efe2cb85b0a9c6bc68f6a2dd107c8d7ec080)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice migration: add QEVENT_SPICE_MIGRATE_COMPLETED
Yonit Halperin [Tue, 21 Aug 2012 08:51:57 +0000 (11:51 +0300)]
spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED

When migrating, libvirt queries the migration status, and upon migration
completions, it closes the migration src. On the other hand, when
migration is completed, spice transfers data from the src to destination
via the client. This data is required for keeping the spice session
after migration, without suffering from data loss and inconsistencies.
In order to allow this data transfer, we add QEVENT for signaling
libvirt that spice migration has completed, and libvirt needs to wait
for this event before quitting the src process.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2fdd16e239c2a2763aa3266e637718123328688c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: notify on vm state change only via spice_server_vm_start/stop
Yonit Halperin [Tue, 21 Aug 2012 08:51:56 +0000 (11:51 +0300)]
spice: notify on vm state change only via spice_server_vm_start/stop

QXLWorker->start/stop are deprecated since spice-server 0.11.2

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 71d388d420e68ac77cd42f15f7e68cf5a6fb01b2)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: notify spice server on vm start/stop
Yonit Halperin [Tue, 21 Aug 2012 08:51:55 +0000 (11:51 +0300)]
spice: notify spice server on vm start/stop

Spice server needs to know about the vm state in order to prevent
attempts to write to devices when they are stopped, mainly during
the non-live stage of migration.
Instead, spice will take care of restoring this writes, on the migration
target side, after migration completes.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit f5bb039c6d97ef3e664094eab3c9a4dc1824ed73)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agospice: abort on invalid streaming cmdline params
Christophe Fergeau [Mon, 13 Aug 2012 08:32:32 +0000 (10:32 +0200)]
spice: abort on invalid streaming cmdline params

When parsing its command line parameters, spice aborts when it
finds unexpected values, except for the 'streaming-video' option.
This happens because the parsing of the parameters for this option
is done using the 'name2enum' helper, which does not error out
on unknown values. Using the 'parse_name' helper makes sure we
error out in this case. Looking at git history, the use of
'name2enum' instead of 'parse_name' seems to have been an oversight,
so let's change to that now.

Fixes rhbz#831708

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 835cab85ad83ed8dfe1c13243aeda5959b153e3e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotci: Fix for AREG0 free mode
Stefan Weil [Tue, 18 Sep 2012 20:43:38 +0000 (22:43 +0200)]
tci: Fix for AREG0 free mode

Support for helper functions with 5 arguments was missing
in the code generator and in the interpreter.

There is no need to pass the constant TCG_AREG0 from the
code generator to the interpreter. Remove that code for
the INDEX_op_qemu_st* opcodes.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg: Fix MAX_OPC_PARAM_IARGS
Stefan Weil [Wed, 12 Sep 2012 17:18:55 +0000 (19:18 +0200)]
tcg: Fix MAX_OPC_PARAM_IARGS

DEF_HELPER_FLAGS_5 was added some time ago without adjusting
MAX_OPC_PARAM_IARGS.

Fixing the definition becomes more important as QEMU is using
an increasing number of helper functions called with 5 arguments.

Add also a comment to avoid future problems when DEF_HELPER_FLAGS_6
will be added.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/i386: fix build with -march < i686
Aurelien Jarno [Tue, 25 Sep 2012 22:30:12 +0000 (00:30 +0200)]
tcg/i386: fix build with -march < i686

The movcond_i32 op has to be protected with TCG_TARGET_HAS_movcond_i32
to fix the build with -march < i686.

Thanks to Richard Henderson for the hint.

Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg: Adjust descriptions of *cond opcodes
Richard Henderson [Sat, 22 Sep 2012 00:18:09 +0000 (17:18 -0700)]
tcg: Adjust descriptions of *cond opcodes

The README file documented the operand ordering of the tcg_gen_*
functions.  Since we're documenting opcodes here, use the true
operand ordering.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Cc: malc <av1474@comtv.ru>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/mips: fix MIPS32(R2) detection
Aurelien Jarno [Sat, 22 Sep 2012 21:08:38 +0000 (23:08 +0200)]
tcg/mips: fix MIPS32(R2) detection

Fix the MIPS32(R2) cpu detection so that it also works with
-march=octeon. Thanks to Andrew Pinski for the hint.

Cc: Andrew Pinski <apinski@cavium.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-alpha: Initialize env->cpu_model_str
Richard Henderson [Fri, 21 Sep 2012 12:15:36 +0000 (14:15 +0200)]
target-alpha: Initialize env->cpu_model_str

Save the cpu_model_str so that we have a non-null value when
creating a new cpu during clone.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Preserve branch destinations during retranslation
Richard Henderson [Fri, 21 Sep 2012 18:00:23 +0000 (11:00 -0700)]
tcg-sparc: Preserve branch destinations during retranslation

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Fix and enable direct TB chaining.
Richard Henderson [Fri, 21 Sep 2012 17:48:51 +0000 (10:48 -0700)]
tcg-sparc: Fix and enable direct TB chaining.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Add %g/%o registers to alloc_order
Richard Henderson [Sun, 25 Mar 2012 20:43:17 +0000 (22:43 +0200)]
tcg-sparc: Add %g/%o registers to alloc_order

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Use defines for temporaries.
Richard Henderson [Sun, 25 Mar 2012 20:04:59 +0000 (22:04 +0200)]
tcg-sparc: Use defines for temporaries.

And change from %i4/%i5 to %g1/%o7 to remove a v8plus fixme.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Mask shift immediates to avoid illegal insns.
Richard Henderson [Sun, 25 Mar 2012 19:36:28 +0000 (21:36 +0200)]
tcg-sparc: Mask shift immediates to avoid illegal insns.

The xtensa-test image generates a sra_i32 with count 0x40.
Whether this is accident of tcg constant propagation or
originating directly from the instruction stream is immaterial.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Clean up cruft stemming from attempts to use global registers.
Richard Henderson [Sun, 25 Mar 2012 19:21:46 +0000 (21:21 +0200)]
tcg-sparc: Clean up cruft stemming from attempts to use global registers.

Don't use -ffixed-gN.  Don't link statically.  Don't save/restore
AREG0 around calls.  Don't allocate space on the stack for AREG0 save.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Change AREG0 in generated code to %i0.
Richard Henderson [Sun, 25 Mar 2012 17:52:11 +0000 (19:52 +0200)]
tcg-sparc: Change AREG0 in generated code to %i0.

We can now move the TCG variable from %g[56] to a call-preserved
windowed register.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Support GUEST_BASE.
Richard Henderson [Sat, 24 Mar 2012 21:11:25 +0000 (22:11 +0100)]
tcg-sparc: Support GUEST_BASE.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Fix qemu_ld/st to handle 32-bit host.
Richard Henderson [Fri, 23 Mar 2012 22:27:39 +0000 (23:27 +0100)]
tcg-sparc: Fix qemu_ld/st to handle 32-bit host.

At the same time, split out the tlb load logic to a new function.
Fixes the cases of two data registers and two address registers.
Fixes the signature of, and adds missing, qemu_ld/st opcodes.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode.
Richard Henderson [Fri, 21 Sep 2012 17:34:21 +0000 (10:34 -0700)]
tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode.

Current code doesn't actually work in 32-bit mode at all.  Since
no one really noticed, drop the complication of v7 and v8 cpus.
Eliminate the --sparc_cpu configure option and standardize macro
testing on TCG_TARGET_REG_BITS / HOST_LONG_BITS

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Don't MAP_FIXED on top of the program
Richard Henderson [Fri, 21 Sep 2012 17:40:48 +0000 (10:40 -0700)]
tcg-sparc: Don't MAP_FIXED on top of the program

The address we pick in sparc64.ld is also 0x60000000, so doing a fixed map
on top of that is guaranteed to blow up.  Choosing 0x40000000 is exactly
right for the max of code_gen_buffer_size set below.

No need to ever use MAP_FIXED.  While getting our desired address helps
optimize the generated code, we won't fail if we don't get it.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Fix ADDX opcode.
Richard Henderson [Fri, 23 Mar 2012 22:57:12 +0000 (23:57 +0100)]
tcg-sparc: Fix ADDX opcode.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg-sparc: Hack in qemu_ld/st64 for 32-bit.
Richard Henderson [Sat, 24 Mar 2012 20:30:20 +0000 (21:30 +0100)]
tcg-sparc: Hack in qemu_ld/st64 for 32-bit.

Not actually implemented, but at least we avoid the tcg assert at startup.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/ppc32: Implement movcond32
malc [Sat, 22 Sep 2012 15:14:33 +0000 (19:14 +0400)]
tcg/ppc32: Implement movcond32

Thanks to Richard Henderson

Signed-off-by: malc <av1474@comtv.ru>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agow64: Fix TCG helper functions with 5 arguments
Stefan Weil [Thu, 13 Sep 2012 17:37:43 +0000 (19:37 +0200)]
w64: Fix TCG helper functions with 5 arguments

TCG uses 6 registers for function arguments on 64 bit Linux hosts,
but only 4 registers on W64 hosts.

Commit 2999a0b20074a7e4a58f56572bb1436749368f59 increased the number
of arguments for some important helper functions from 4 to 5
which triggered a bug for W64 hosts: QEMU aborts when executing
helper_lcall_real in the guest's BIOS because function
tcg_target_get_call_iarg_regs_count always returned 6.

As W64 has only 4 registers for arguments, the 5th argument must be
passed on the stack using a correct stack offset.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/README: document tcg_gen_goto_tb restrictions
Max Filippov [Fri, 21 Sep 2012 00:18:07 +0000 (04:18 +0400)]
tcg/README: document tcg_gen_goto_tb restrictions

See
http://lists.nongnu.org/archive/html/qemu-devel/2012-09/msg03196.html
for the whole story.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/optimize: add constant folding for deposit
Aurelien Jarno [Fri, 21 Sep 2012 09:07:29 +0000 (11:07 +0200)]
tcg/optimize: add constant folding for deposit

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>