sdk/emulator/qemu.git
13 years agosdl: Factor out event handlers from sdl_refresh
Jan Kiszka [Sat, 30 Jul 2011 09:39:17 +0000 (11:39 +0200)]
sdl: Factor out event handlers from sdl_refresh

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Add zoom hot keys
Jan Kiszka [Sat, 30 Jul 2011 09:39:16 +0000 (11:39 +0200)]
sdl: Add zoom hot keys

Allow to enlarge or shrink the screen via CTRL-ALT-+/-. In contrast to
scaling the window, these controls always preserve the aspect ratio of
the current console.

CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Dynamically grab input in absolute mouse mode
Jan Kiszka [Sat, 30 Jul 2011 09:39:15 +0000 (11:39 +0200)]
sdl: Dynamically grab input in absolute mouse mode

Not grabbing the input means that special keys like ALT+TAB are still
handled by the host. Improve the usability by grabbing input once the
mouse is inside the guest screen, provided the SDL window has the input
focus. Release it again when the mouse is moved to any border. Also grab
the input when we gain the input focus and the mouse is within the
screen limits.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Fix cursor handling when switching consoles in absolute mouse mode
Jan Kiszka [Sat, 30 Jul 2011 09:39:14 +0000 (11:39 +0200)]
sdl: Fix cursor handling when switching consoles in absolute mouse mode

Restore the cursor when switching from graphic to text console while the
mouse is in absolute mode. Disable it again when returning.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Never release input while in full screen mode
Jan Kiszka [Sat, 30 Jul 2011 09:39:13 +0000 (11:39 +0200)]
sdl: Never release input while in full screen mode

It's confusing to suddenly find two mice in full screen mode when
switching consoles or accidentally hitting the grab hot keys.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Consistently avoid grabbing input for text consoles
Jan Kiszka [Sat, 30 Jul 2011 09:39:12 +0000 (11:39 +0200)]
sdl: Consistently avoid grabbing input for text consoles

There were some preexisting bits that released the input when switching
to text console. This patch spreads this logic consistently and also
avoids grabbing the input while a text console is active.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Initialize gui_fullscreen earlier during setup
Jan Kiszka [Sat, 30 Jul 2011 09:39:11 +0000 (11:39 +0200)]
sdl: Initialize gui_fullscreen earlier during setup

This ensures that we actually enter full screen on startup when e.g.
'-vga none -full-screen' was specified.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Drop bogus gui_fullscreen_initial_grab
Jan Kiszka [Sat, 30 Jul 2011 09:39:10 +0000 (11:39 +0200)]
sdl: Drop bogus gui_fullscreen_initial_grab

There must be no difference between initial -full-screen and switching
to this mode via the hot key.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Restore scaling mode on return from full screen
Jan Kiszka [Sat, 30 Jul 2011 09:39:09 +0000 (11:39 +0200)]
sdl: Restore scaling mode on return from full screen

Save the scaling mode and its geometry when going full screen, restore
it when returning to windowed mode.

CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Fix full screen toggling from scaled mode
Jan Kiszka [Sat, 30 Jul 2011 09:39:08 +0000 (11:39 +0200)]
sdl: Fix full screen toggling from scaled mode

When switching to full screen mode from a scaled window, we need to
resize to DisplayState's dimension, not the scaled "real" screen size.
Moreover, scaling mode may have manipulated the bpp. So we need to
restore it from the DisplayState as well.

CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Properly mark modifier+u as hotkey
Jan Kiszka [Sat, 30 Jul 2011 09:39:07 +0000 (11:39 +0200)]
sdl: Properly mark modifier+u as hotkey

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Avoid redundant scaling deactivation
Jan Kiszka [Sat, 30 Jul 2011 09:39:06 +0000 (11:39 +0200)]
sdl: Avoid redundant scaling deactivation

Prevents screen flickering.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Do not make full screen mode resizable
Jan Kiszka [Sat, 30 Jul 2011 09:39:05 +0000 (11:39 +0200)]
sdl: Do not make full screen mode resizable

This prevents continuous resizing events and improper screen setups when
going full screen.

CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosdl: Fix termination in -no-shutdown mode
Jan Kiszka [Sat, 30 Jul 2011 09:39:04 +0000 (11:39 +0200)]
sdl: Fix termination in -no-shutdown mode

Just like the monitor does, we need to clear no_shutdown before calling
qemu_system_shutdown_request on quit requests. Otherwise, QEMU just
stops the VM.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoCheck fread() results to avoid gcc 4.6 warnings
David Gibson [Mon, 1 Aug 2011 06:49:59 +0000 (16:49 +1000)]
Check fread() results to avoid gcc 4.6 warnings

When compiling with gcc 4.6, some code in fw_cfg.c complains that fop_ret
is assigned but not used (which is true).  However, it looks like the
meaningless assignments to fop_ret were done to suppress other gcc warnings
due to the fact that fread() is labelled as warn_unused_result in glibc.

This patch avoids both errors, by actually checking the fread() result code
and dropping out with an error message if it fails.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMAINTAINERS: add entry for Xen
Stefano Stabellini [Fri, 29 Jul 2011 15:05:13 +0000 (16:05 +0100)]
MAINTAINERS: add entry for Xen

Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqcow2: Fix L1 table size after bdrv_snapshot_goto
Kevin Wolf [Fri, 5 Aug 2011 10:06:11 +0000 (12:06 +0200)]
qcow2: Fix L1 table size after bdrv_snapshot_goto

When loading an internal snapshot whose L1 table is smaller than the current L1
table, the size of the current L1 would be shrunk to the snapshot's L1 size in
memory, but not on disk. This lead to incorrect refcount updates and eventuelly
to image corruption.

Instead of writing the new L1 size to disk, this simply retains the bigger L1
size that is currently in use and makes sure that the unused part is zeroed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Tested-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMerge remote-tracking branch 'mst/for_anthony' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:15:22 +0000 (17:15 -0500)]
Merge remote-tracking branch 'mst/for_anthony' into staging

13 years agoMerge remote-tracking branch 'alon/pull-libcacard.data' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:14:49 +0000 (17:14 -0500)]
Merge remote-tracking branch 'alon/pull-libcacard.data' into staging

13 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:14:01 +0000 (17:14 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

13 years agoMerge remote-tracking branch 'spice/spice.v40' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:13:26 +0000 (17:13 -0500)]
Merge remote-tracking branch 'spice/spice.v40' into staging

13 years agoMerge remote-tracking branch 'kiszka/queues/slirp' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:12:34 +0000 (17:12 -0500)]
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

13 years agoMerge remote-tracking branch 'kraxel/usb.22' into staging
Anthony Liguori [Thu, 4 Aug 2011 22:10:36 +0000 (17:10 -0500)]
Merge remote-tracking branch 'kraxel/usb.22' into staging

13 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Thu, 4 Aug 2011 21:45:17 +0000 (16:45 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

13 years agoguest agent: add --enable-guest-agent config option
Michael Roth [Mon, 1 Aug 2011 19:52:57 +0000 (14:52 -0500)]
guest agent: add --enable-guest-agent config option

QAPI will require glib/python, but for now the guest agent is the only
user. For now, make these dependencies an explicit guest agent one, and
give users the option to disable it if need be.

Once QAPI is adopted in core QEMU code, we would basically revert this
patch.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoAdd support for finding libpng via pkg-config.
Brad [Sat, 30 Jul 2011 05:45:55 +0000 (01:45 -0400)]
Add support for finding libpng via pkg-config.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoalpha-softmmu: Disable for the 0.15 release branch.
Richard Henderson [Sun, 31 Jul 2011 23:47:20 +0000 (16:47 -0700)]
alpha-softmmu: Disable for the 0.15 release branch.

The system emulation code was not merged before the branch.
Let's leave that work for the next release.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoconfigure: Fix bad shell expression for non-Linux hosts
Stefan Weil [Fri, 29 Jul 2011 20:40:45 +0000 (22:40 +0200)]
configure: Fix bad shell expression for non-Linux hosts

With vhost_net="" (most non-Linux hosts), configure prints an
error message:

test: 2551: =: unexpected operator

Fix this and similar code by adding the missing "".

Cc: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovirtio-balloon: Unregister savevm section on device unplug
Amit Shah [Thu, 28 Jul 2011 06:06:26 +0000 (11:36 +0530)]
virtio-balloon: Unregister savevm section on device unplug

Migrating after unplugging a virtio-balloon device resulted in an error
message on the destination:

Unknown savevm section or instance '0000:00:04.0/virtio-balloon' 0
load of migration failed

Fix this by unregistering the section on device unplug.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
13 years agovirtio-balloon: Add exit handler, fix memleaks
Amit Shah [Wed, 27 Jul 2011 08:20:41 +0000 (13:50 +0530)]
virtio-balloon: Add exit handler, fix memleaks

Add an exit handler that will free up RAM after a virtio-balloon device
is unplugged.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoballoon: Reject negative balloon values
Amit Shah [Wed, 27 Jul 2011 11:20:54 +0000 (16:50 +0530)]
balloon: Reject negative balloon values

Negative balloon values don't make sense, reject them and throw a qerror
with QERR_INVALID_PARAMETER_VALUE.

Reported-by: Mike Cao <bcao@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
13 years agovirtio-balloon: Check if balloon registration failed
Amit Shah [Wed, 27 Jul 2011 06:59:33 +0000 (12:29 +0530)]
virtio-balloon: Check if balloon registration failed

Multiple balloon registrations are not allowed; check if the
registration with the qemu balloon api succeeded.  If not, fail the
device init.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoballoon: Don't allow multiple balloon handler registrations
Amit Shah [Wed, 27 Jul 2011 06:58:19 +0000 (12:28 +0530)]
balloon: Don't allow multiple balloon handler registrations

Multiple balloon devices don't make sense; disallow more than one
registration attempt to register handlers.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
13 years agovirtio-balloon: Fix header comment; add Copyright
Amit Shah [Wed, 20 Jul 2011 08:07:01 +0000 (13:37 +0530)]
virtio-balloon: Fix header comment; add Copyright

Signed-off-by: Amit Shah <amit.shah@redhat.com>
13 years agoballoon: Fix header comment; add Copyright
Amit Shah [Wed, 20 Jul 2011 08:05:30 +0000 (13:35 +0530)]
balloon: Fix header comment; add Copyright

Signed-off-by: Amit Shah <amit.shah@redhat.com>
13 years agoballoon: Separate out stat and balloon handling
Amit Shah [Wed, 20 Jul 2011 08:00:56 +0000 (13:30 +0530)]
balloon: Separate out stat and balloon handling

Passing on '0' as ballooning target to indicate retrieval of stats is
bad API.  It also makes 'balloon 0' in the monitor cause a segfault.
Have two different functions handle the different functionality instead.

Detailed explanation from Markus's review:

1. do_info_balloon() is an info_async() method.  It receives a callback
   with argument, to be called exactly once (callback frees the
   argument).  It passes the callback via qemu_balloon_status() and
   indirectly through qemu_balloon_event to virtio_balloon_to_target().

   virtio_balloon_to_target() executes its balloon stats half.  It
   stores the callback in the device state.

   If it can't send a stats request, it resets stats and calls the
   callback right away.

   Else, it sends a stats request.  The device model runs the callback
   when it receives the answer.

   Works.

2. do_balloon() is a cmd_async() method.  It receives a callback with
   argument, to be called when the command completes.  do_balloon()
   calls it right before it succeeds.  Odd, but should work.

   Nevertheless, it passes the callback on via qemu_ballon() and
   indirectly through qemu_balloon_event to virtio_balloon_to_target().

   a. If the argument is non-zero, virtio_balloon_to_target() executes
      its balloon half, which doesn't use the callback in any way.

      Odd, but works.

   b. If the argument is zero, virtio_balloon_to_target() executes its
      balloon stats half, just like in 1.  It either calls the callback
      right away, or arranges for it to be called later.

      Thus, the callback runs twice: use after free and double free.

Test case: start with -S -device virtio-balloon, execute "balloon 0" in
human monitor.  Runs the callback first from virtio_balloon_to_target(),
then again from do_balloon().

Reported-by: Mike Cao <bcao@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agovirtio-balloon: Separate status handling into separate function
Amit Shah [Wed, 20 Jul 2011 07:49:07 +0000 (13:19 +0530)]
virtio-balloon: Separate status handling into separate function

Separate out the code to retrieve balloon info from the code that sets
balloon values.

This will be used to separate the two callbacks from balloon.c and help
cope with 'balloon 0' on the monitor.  Currently, 'balloon 0' causes a
segfault in monitor_resume().

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agoballoon: Simplify code flow
Amit Shah [Wed, 20 Jul 2011 07:44:12 +0000 (13:14 +0530)]
balloon: Simplify code flow

Replace:
  if (foo) {
    ...
  } else {
    return 0;
  }

by

  if (!foo) {
    return 0;
  }
  ...

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agoballoon: Add braces around if statements
Amit Shah [Wed, 20 Jul 2011 07:42:15 +0000 (13:12 +0530)]
balloon: Add braces around if statements

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agoballoon: Make functions, local vars static
Amit Shah [Wed, 20 Jul 2011 07:38:46 +0000 (13:08 +0530)]
balloon: Make functions, local vars static

balloon.h had function declarations for a couple of functions that are
local to balloon.c.  Make them static.

Drop the 'qemu_' prefix for balloon.c-local variables, and make them
static.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agobluetooth: kill dummy usb device, use hid code directly.
Gerd Hoffmann [Fri, 15 Jul 2011 14:14:59 +0000 (16:14 +0200)]
bluetooth: kill dummy usb device, use hid code directly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agohid: move idle+protocol from usb-hid to hid too.
Gerd Hoffmann [Fri, 15 Jul 2011 13:52:33 +0000 (15:52 +0200)]
hid: move idle+protocol from usb-hid to hid too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hid: split hid code to hw/hid.[ch]
Gerd Hoffmann [Fri, 15 Jul 2011 13:08:01 +0000 (15:08 +0200)]
usb-hid: split hid code to hw/hid.[ch]

Almost pure code motion.  Unstatic hid interface functions and add
them to the header file.  Some renames.  Some code style cleanups.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hid: add hid_has_events()
Gerd Hoffmann [Fri, 15 Jul 2011 12:46:39 +0000 (14:46 +0200)]
usb-hid: add hid_has_events()

Add hid_has_events function, use it to figure whenever there are pending
events instead of checking and updating USBHIDState->changed.

Setting ->changed to 1 on init is removed, that should have absolutely
no effect as the initial state of ->idle is 0 so we report hid state
anyway until the guest configures some idle time.  Also should clear
->idle on reset.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hid: add event callback
Gerd Hoffmann [Fri, 15 Jul 2011 12:37:15 +0000 (14:37 +0200)]
usb-hid: add event callback

Add callback for event notification, which allows to un-usbify more
functions.  Also split separate hid_* functions for reset and release.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hid: create & use HIDState
Gerd Hoffmann [Fri, 15 Jul 2011 11:12:44 +0000 (13:12 +0200)]
usb-hid: create & use HIDState

First step in separating out the HID emulation code from usb-hid, so it
can be reused without creating a dummy usb device like bluetooth does.

This creates a HIDState struct, moves the non-usbish fields from
USBHIDStruct there.  Renames non-usbish structs, defines and functions
from usb* to hid*.  Adapts the code to that.

Also cleans up a bunch of code style issues along the way.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoehci: iovec support, remove buffer
Gerd Hoffmann [Wed, 13 Jul 2011 15:36:46 +0000 (17:36 +0200)]
ehci: iovec support, remove buffer

Map guest memory and pass on a direct pointer instead of copying
the bits to a indirect buffer.  EHCI transfer descriptors can
reference multiple (physical guest) pages so we'll actually start
seeing usb packets wich carry iovec with more than one element.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agouhci: remove buffer
Gerd Hoffmann [Wed, 13 Jul 2011 13:37:29 +0000 (15:37 +0200)]
uhci: remove buffer

Map guest memory and pass on a direct pointer instead of copying
the bits to a indirect buffer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-storage: iovec support
Gerd Hoffmann [Wed, 13 Jul 2011 10:32:06 +0000 (12:32 +0200)]
usb-storage: iovec support

Add full iovec support to usb-storage.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-host: iovec support
Gerd Hoffmann [Wed, 13 Jul 2011 09:28:17 +0000 (11:28 +0200)]
usb-host: iovec support

Add full support for iovecs to usb-host.  The code can split large
transfers into smaller ones already, we are using this to also split
requests at iovec borders.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-serial: iovec support
Gerd Hoffmann [Wed, 13 Jul 2011 08:53:23 +0000 (10:53 +0200)]
usb-serial: iovec support

Add full support for iovecs to usb-serial.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb: use iovecs in USBPacket
Gerd Hoffmann [Tue, 12 Jul 2011 13:22:25 +0000 (15:22 +0200)]
usb: use iovecs in USBPacket

Zap data pointer from USBPacket, add a QEMUIOVector instead.
Add a bunch of helper functions to manage USBPacket data.
Switch over users to the new interface.

Note that USBPacket->len was used for two purposes:  First to
pass in the buffer size and second to return the number of
transfered bytes or the status code on async transfers.  There
is a new result variable for the latter.  A new status code
was added to catch uninitialized result.

Nobody creates iovecs with more than one element (yet).
Some users are (temporarely) limited to iovecs with a single
element to keep the patch size as small as possible.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agomove QEMUSGList typedef
Gerd Hoffmann [Tue, 12 Jul 2011 11:36:23 +0000 (13:36 +0200)]
move QEMUSGList typedef

Move the QEMUSGList typedef to qemu-common so it can easily be used.
The actual struct definition stays in dma.h.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoAdd iov_clear()
Gerd Hoffmann [Wed, 13 Jul 2011 13:16:08 +0000 (15:16 +0200)]
Add iov_clear()

Fill the spefified area with zeros.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoAdd iov_hexdump()
Gerd Hoffmann [Tue, 12 Jul 2011 11:35:10 +0000 (13:35 +0200)]
Add iov_hexdump()

Useful for debugging purposes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agore-activate usb-host for bsd
Gerd Hoffmann [Thu, 4 Aug 2011 12:54:19 +0000 (14:54 +0200)]
re-activate usb-host for bsd

A bunch of code was disabled via #if 0, for a quite long time (since
Sept 2009).  Surprisingly the code builds just fine when they are
removed (tested on OpenBSD).  /me wonders nevertheless whenever there
are any users of those bits when this went unnoticed for almost two
years ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoblock: Use bdrv_co_* instead of synchronous versions in coroutines
Kevin Wolf [Fri, 15 Jul 2011 14:05:00 +0000 (16:05 +0200)]
block: Use bdrv_co_* instead of synchronous versions in coroutines

If we're already in a coroutine, there is no reason to use the synchronous
version of block layer functions when a coroutine one exists. This makes
bdrv_read/write/flush use bdrv_co_* when used inside a coroutine.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agolm32: softusb: claim to support full speed
Michael Walle [Thu, 21 Jul 2011 18:52:24 +0000 (20:52 +0200)]
lm32: softusb: claim to support full speed

The QEMU keyboard and mouse reports themselves as full speed devices,
though they are actually low speed devices. Until this is fixed, claim that
we are supporting full speed devices.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agovhost: remove an incorrect assert
Michael S. Tsirkin [Wed, 3 Aug 2011 12:24:41 +0000 (15:24 +0300)]
vhost: remove an incorrect assert

The 'to' can go negative when the first region gets removed
(it gets incremented by to 0 immediately afterward), which
makes the assertion fail. Nothing breaks if
to < 0 here so just remove the assert.

Tested-by: David Ahern <daahern@cisco.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoDelayed IP packets
Fabien Chouteau [Mon, 1 Aug 2011 16:18:37 +0000 (18:18 +0200)]
Delayed IP packets

In the current implementation, if Slirp tries to send an IP packet to a client
with an unknown hardware address, the packet is simply dropped and an ARP
request is sent (if_encap in slirp/slirp.c).

With this patch, Slirp will send the ARP request, re-queue the packet and try
to send it later. The packet is dropped after one second if the ARP reply is
not received.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 years agoSimple ARP table
Fabien Chouteau [Wed, 3 Aug 2011 10:52:54 +0000 (12:52 +0200)]
Simple ARP table

This patch adds a simple ARP table in Slirp and also adds handling of
gratuitous ARP requests.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 years agoMakefile: delete config.log in distclean
Alexandre Raymond [Tue, 26 Jul 2011 03:56:02 +0000 (23:56 -0400)]
Makefile: delete config.log in distclean

Distclean should remove anything created by the configure script.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoHMP: Remove the duplicated info "info kvm" in hmp-commands.hx.
Zhi Yong Wu [Wed, 27 Jul 2011 09:48:16 +0000 (17:48 +0800)]
HMP: Remove the duplicated info "info kvm" in hmp-commands.hx.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoconfigure: display "no" for disabled kvm/vhost-net
Brad [Wed, 27 Jul 2011 03:11:26 +0000 (23:11 -0400)]
configure: display "no" for disabled kvm/vhost-net

Fix configure display for non-Linux OS's and the KVM /
vhost-net features to show "no" output instead of nothing
at the end of the line.

Signed-off-by: Brad Smith <brad@comstyle.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqxl: bump pci rev
Gerd Hoffmann [Wed, 20 Jul 2011 09:21:00 +0000 (12:21 +0300)]
qxl: bump pci rev

Inform guest drivers about the new features I/O commands we have
now (async commands, S3 support) if building with newer spice, i.e.
if SPICE_INTERFACE_QXL_MINOR >= 1.

sneaked in some 81+ column line spliting.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoqxl: add QXL_IO_FLUSH_{SURFACES,RELEASE} for guest S3&S4 support
Alon Levy [Wed, 20 Jul 2011 09:20:59 +0000 (12:20 +0300)]
qxl: add QXL_IO_FLUSH_{SURFACES,RELEASE} for guest S3&S4 support

Add two new IOs.
 QXL_IO_FLUSH_SURFACES - equivalent to update area for all surfaces, used
  to reduce vmexits from NumSurfaces to 1 on guest S3, S4 and resolution change (windows
  driver implementation is such that this is done on each of those occasions).
 QXL_IO_FLUSH_RELEASE - used to ensure anything on last_release is put on the release ring
  for the client to free.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: async io support using new spice api
Alon Levy [Wed, 20 Jul 2011 09:20:58 +0000 (12:20 +0300)]
qxl: async io support using new spice api

Some of the QXL port i/o commands are waiting for the spice server to
complete certain actions.  Add async versions for these commands, so we
don't block the vcpu while the spice server processses the command.
Instead the qxl device will raise an IRQ when done.

The async command processing relies on an added QXLInterface::async_complete
and added QXLWorker::*_async additions, in spice server qxl >= 3.1

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoslirp: Take maintainer token
Jan Kiszka [Wed, 27 Jul 2011 12:21:32 +0000 (14:21 +0200)]
slirp: Take maintainer token

Anthony asked me to pick up the maintenance of this subsystem, and I
agreed.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 years agoposix-aio-compat: Allow read after EOF
Kevin Wolf [Mon, 25 Jul 2011 17:42:37 +0000 (19:42 +0200)]
posix-aio-compat: Allow read after EOF

In order to be able to transparently replace bdrv_read calls by bdrv_co_read,
reading beyond EOF must produce zeros instead of short reads for AIO, too.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agocoroutines: Use one global bottom half for CoQueue
Kevin Wolf [Wed, 13 Jul 2011 13:42:52 +0000 (15:42 +0200)]
coroutines: Use one global bottom half for CoQueue

Now that AsyncContexts don't exist any more, we can use one global bottom half
for restarting coroutines instead of allocating a new one every time (before
removing AsyncContexts, the problem with having a global BH was that it had to
belong to a single AsyncContexts and wouldn't be executed in a different one -
which leads to deadlocks)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoasync: Remove AsyncContext
Kevin Wolf [Fri, 15 Jul 2011 14:36:40 +0000 (16:36 +0200)]
async: Remove AsyncContext

The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancy
during an emulated bdrv_read/write (which includes a qemu_aio_wait() call and
can run AIO callbacks of different requests if it weren't for AsyncContexts).

Now both qcow and qcow2 are protected by CoMutexes and AsyncContexts can be
removed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow: Use coroutines
Kevin Wolf [Fri, 15 Jul 2011 14:27:42 +0000 (16:27 +0200)]
qcow: Use coroutines

The old qcow format is another user of the AsyncContext infrastructure.
Converting it to coroutines (and therefore CoMutexes) allows to remove
AsyncContexts.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2: Use coroutines
Kevin Wolf [Thu, 30 Jun 2011 15:42:09 +0000 (17:42 +0200)]
qcow2: Use coroutines

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agocoroutines: Locks
Kevin Wolf [Thu, 30 Jun 2011 15:56:46 +0000 (17:56 +0200)]
coroutines: Locks

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Add bdrv_co_readv/writev emulation
Kevin Wolf [Fri, 15 Jul 2011 11:50:26 +0000 (13:50 +0200)]
block: Add bdrv_co_readv/writev emulation

In order to be able to call bdrv_co_readv/writev for drivers that don't
implement the functions natively, add an emulation that uses the AIO functions
to implement them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Emulate AIO functions with bdrv_co_readv/writev
Kevin Wolf [Thu, 30 Jun 2011 08:05:46 +0000 (10:05 +0200)]
block: Emulate AIO functions with bdrv_co_readv/writev

Use the bdrv_co_readv/writev callbacks to implement bdrv_aio_readv/writev and
bdrv_read/write if a driver provides the coroutine version instead of the
synchronous or AIO version.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Add bdrv_co_readv/writev
Kevin Wolf [Thu, 14 Jul 2011 15:27:13 +0000 (17:27 +0200)]
block: Add bdrv_co_readv/writev

Add new block driver callbacks bdrv_co_readv/writev, which work on a
QEMUIOVector like bdrv_aio_*, but don't need a callback. The function may only
be called inside a coroutine, so a block driver implementing this interface can
yield instead of blocking during I/O.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agocoroutine: add test-coroutine --benchmark-lifecycle
Stefan Hajnoczi [Thu, 12 May 2011 07:27:39 +0000 (08:27 +0100)]
coroutine: add test-coroutine --benchmark-lifecycle

Add a microbenchmark for coroutine create, enter, and return (aka
lifecycle).  This is a useful benchmark because users are expected to
create many coroutines, one per I/O request for example, and we
therefore need to provide good performance in that scenario.

To run:

  make test-coroutine
  ./test-coroutine --benchmark-lifecycle 20000000

This will do 20,000,000 coroutine create, enter, return iterations and
print the resulting time.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocoroutine: add test-coroutine automated tests
Stefan Hajnoczi [Tue, 10 May 2011 09:21:18 +0000 (10:21 +0100)]
coroutine: add test-coroutine automated tests

To run automated tests for coroutines:

  make test-coroutine
  ./test-coroutine

On success the program terminates with exit status 0.  On failure an
error message is written to stderr and the program exits with exit
status 1.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agolibcacard: use INSTALL_DATA for data
Alon Levy [Thu, 28 Jul 2011 09:34:13 +0000 (12:34 +0300)]
libcacard: use INSTALL_DATA for data

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoSparc: fix non-faulting unassigned memory accesses
Blue Swirl [Mon, 1 Aug 2011 21:26:03 +0000 (21:26 +0000)]
Sparc: fix non-faulting unassigned memory accesses

Commit b14ef7c9ab41ea824c3ccadb070ad95567cca84e
introduced cpu_unassigned_access() function. On Sparc,
the function does not restore AREG0 used for global CPUState
on function exit, causing bugs with non-faulting unassigned
memory accesses. Alpha, Microblaze and MIPS are not affected.

Fix by restoring AREG0 on exit. Remove excess saving by
do_unassigned_access() functions.

Also ignore unassigned accesses outside of CPU context.

Reported-by: Bob Breuer <breuerr@mc.net>
Tested-by: Bob Breuer <breuerr@mc.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoqxl: only disallow specific io's in vga mode
Alon Levy [Wed, 20 Jul 2011 09:20:57 +0000 (12:20 +0300)]
qxl: only disallow specific io's in vga mode

Since the driver is still in operation even after moving to UNDEFINED, i.e.
by destroying primary in any way.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: make qxl_guest_bug take variable arguments
Alon Levy [Wed, 20 Jul 2011 09:20:56 +0000 (12:20 +0300)]
qxl: make qxl_guest_bug take variable arguments

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: error handling fixes and cleanups.
Gerd Hoffmann [Wed, 20 Jul 2011 09:20:55 +0000 (12:20 +0300)]
qxl: error handling fixes and cleanups.

Add qxl_guest_bug() function which is supposed to be called in case
sanity checks of guest requests fail.  It raises an error IRQ and
logs a message in case guest debugging is enabled.

Make PANIC_ON() abort instead of exit.  That macro should be used
for qemu bugs only, any guest-triggerable stuff should use the new
qxl_guest_bug() function instead.

Convert a few easy cases from PANIC_ON() to qxl_guest_bug() to
show intended usage.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: add io_port_to_string
Alon Levy [Wed, 20 Jul 2011 09:20:54 +0000 (12:20 +0300)]
qxl: add io_port_to_string

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: fix surface tracking & locking
Gerd Hoffmann [Wed, 20 Jul 2011 09:20:53 +0000 (12:20 +0300)]
qxl: fix surface tracking & locking

Surface tracking needs proper locking since it is used from vcpu and spice
worker threads, add it.  Also reset the surface counter when zapping all
surfaces.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agospice/qxl: move worker wrappers
Gerd Hoffmann [Wed, 20 Jul 2011 09:20:52 +0000 (12:20 +0300)]
spice/qxl: move worker wrappers

Move the wrapper functions which are used by qxl only to qxl.c.
Rename them from qemu_spice_* to qxl_spice_*.  Also pass in a
qxl state pointer instead of a SimpleSpiceDisplay pointer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agospice: add qemu_spice_display_init_common
Gerd Hoffmann [Wed, 20 Jul 2011 09:20:51 +0000 (12:20 +0300)]
spice: add qemu_spice_display_init_common

Factor out SimpleSpiceDisplay initialization into
qemu_spice_display_init_common() and call it from
both qxl.c (for vga mode) and spice-display.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agospice: add worker wrapper functions.
Gerd Hoffmann [Wed, 20 Jul 2011 09:20:50 +0000 (12:20 +0300)]
spice: add worker wrapper functions.

Add wrapper functions for all spice worker calls.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agocoroutine: implement coroutines using gthread
Aneesh Kumar K.V [Thu, 9 Jun 2011 17:41:06 +0000 (23:11 +0530)]
coroutine: implement coroutines using gthread

On platforms that don't support makecontext(3) use gthread based
coroutine implementation.

Darwin has makecontext(3) but getcontext(3) is stubbed out to return
ENOTSUP.  Andreas Färber <andreas.faerber@web.de> debugged this and
contributed the ./configure test which solves the issue for Darwin/ppc64
(and ppc) v10.5.

[Original patch by Aneesh, made consistent with coroutine-ucontext.c and
switched to GStaticPrivate by Stefan.  Tested on Linux and OpenBSD.]

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocoroutine: introduce coroutines
Kevin Wolf [Mon, 17 Jan 2011 16:08:14 +0000 (16:08 +0000)]
coroutine: introduce coroutines

Asynchronous code is becoming very complex.  At the same time
synchronous code is growing because it is convenient to write.
Sometimes duplicate code paths are even added, one synchronous and the
other asynchronous.  This patch introduces coroutines which allow code
that looks synchronous but is asynchronous under the covers.

A coroutine has its own stack and is therefore able to preserve state
across blocking operations, which traditionally require callback
functions and manual marshalling of parameters.

Creating and starting a coroutine is easy:

  coroutine = qemu_coroutine_create(my_coroutine);
  qemu_coroutine_enter(coroutine, my_data);

The coroutine then executes until it returns or yields:

  void coroutine_fn my_coroutine(void *opaque) {
      MyData *my_data = opaque;

      /* do some work */

      qemu_coroutine_yield();

      /* do some more work */
  }

Yielding switches control back to the caller of qemu_coroutine_enter().
This is typically used to switch back to the main thread's event loop
after issuing an asynchronous I/O request.  The request callback will
then invoke qemu_coroutine_enter() once more to switch back to the
coroutine.

Note that if coroutines are used only from threads which hold the global
mutex they will never execute concurrently.  This makes programming with
coroutines easier than with threads.  Race conditions cannot occur since
only one coroutine may be active at any time.  Other coroutines can only
run across yield.

This coroutines implementation is based on the gtk-vnc implementation
written by Anthony Liguori <anthony@codemonkey.ws> but it has been
significantly rewritten by Kevin Wolf <kwolf@redhat.com> to use
setjmp()/longjmp() instead of the more expensive swapcontext() and by
Paolo Bonzini <pbonzini@redhat.com> for Windows Fibers support.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoraw-posix: Always check paio_init result
Frediano Ziglio [Wed, 27 Jul 2011 18:12:02 +0000 (20:12 +0200)]
raw-posix: Always check paio_init result

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoraw-posix: Typo fix
Frediano Ziglio [Wed, 27 Jul 2011 18:12:01 +0000 (20:12 +0200)]
raw-posix: Typo fix

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Removed unused function bdrv_write_sync
Frediano Ziglio [Wed, 27 Jul 2011 18:12:00 +0000 (20:12 +0200)]
block: Removed unused function bdrv_write_sync

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi-disk: Remove 'drive_kind'
Hannes Reinecke [Fri, 22 Jul 2011 14:44:46 +0000 (16:44 +0200)]
scsi-disk: Remove 'drive_kind'

Instead of using its own definitions scsi-disk should
be using the device type of the parent device.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi: Sanitize command definitions
Hannes Reinecke [Fri, 22 Jul 2011 14:51:15 +0000 (16:51 +0200)]
scsi: Sanitize command definitions

Sanitize SCSI command definitions.
Add _10 suffix to READ_CAPACITY, WRITE_VERIFY, VERIFY, READ_LONG,
WRITE_LONG, and WRITE_SAME.
Add new command definitions for LOCATE_10, UNMAP, VARLENGTH_CDB,
WRITE_FILEMARKS_16, EXTENDED_COPY, ATA_PASSTHROUGH, ACCESS_CONTROL_IN,
ACCESS_CONTROL_OUT, COMPARE_AND_WRITE, VERIFY_16, SYNCHRONIZE_CACHE_16,
LOCATE_16, ERASE_16, WRITE_LONG_16, LOAD_UNLOAD, VERIFY_12.
Remove invalid definition of WRITE_LONG_2.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi: Remove REZERO_UNIT emulation
Hannes Reinecke [Fri, 22 Jul 2011 14:51:14 +0000 (16:51 +0200)]
scsi: Remove REZERO_UNIT emulation

REZERO_UNIT command is obsolete. Remove support for it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi: Remove references to SET_WINDOW
Hannes Reinecke [Fri, 22 Jul 2011 14:51:13 +0000 (16:51 +0200)]
scsi: Remove references to SET_WINDOW

SET_WINDOW command is vendor-specific only.
So we shouldn't try to emulate it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi-disk: Codingstyle fixes
Hannes Reinecke [Fri, 22 Jul 2011 14:51:12 +0000 (16:51 +0200)]
scsi-disk: Codingstyle fixes

Replace tabs with spaces.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/vpc.c: Detect too-large vpc file
Serge E. Hallyn [Mon, 25 Jul 2011 18:34:35 +0000 (18:34 +0000)]
block/vpc.c: Detect too-large vpc file

VHD files technically can be up to 2Tb, but virtual pc is limited
to 127G.  Currently qemu-img refused to create vpc files > 127G,
but it is failing to return error when converting from a non-vpc
VHD file which is >127G.  It returns success, but creates a truncated
converted image.  Also, qemu-img info claims the vpc file is 127G
(and clean).

This patch detects a too-large vpc file and returns -EFBIG.  Without
this patch,

=============================================================
root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/140g-dynamic.vhd
image: /mnt/140g-dynamic.vhd
file format: vpc
virtual size: 127G (136899993600 bytes)
disk size: 284K
root@ip-10-38-123-242:~/qemu-fixed# qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y
root@ip-10-38-123-242:~/qemu-fixed# echo $?
0
root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/y
image: /mnt/y
file format: raw
virtual size: 127G (136899993600 bytes)
disk size: 0
=============================================================

(The 140G image was truncated with no warning or error.)

With the patch, I get:

=============================================================
root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img info /mnt/140g-dynamic.vhd
qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large
root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y
qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large
qemu-img: Could not open '/mnt/140g-dynamic.vhd'
=============================================================

See https://bugs.launchpad.net/qemu/+bug/814222 for details.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>