]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
9 years agoslirp: udp: fix NULL pointer dereference because of uninitialized socket
Petr Matousek [Thu, 18 Sep 2014 06:35:37 +0000 (08:35 +0200)]
slirp: udp: fix NULL pointer dereference because of uninitialized socket

When guest sends udp packet with source port and source addr 0,
uninitialized socket is picked up when looking for matching and already
created udp sockets, and later passed to sosendto() where NULL pointer
dereference is hit during so->slirp->vnetwork_mask.s_addr access.

Fix this by checking that the socket is not just a socket stub.

This is CVE-2014-3640.

Signed-off-by: Petr Matousek <pmatouse@redhat.com>
Reported-by: Xavier Mehrenberger <xavier.mehrenberger@airbus.com>
Reported-by: Stephane Duverger <stephane.duverger@eads.net>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-id: 20140918063537.GX9321@dhcp-25-225.brq.redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20140923-1' into staging
Peter Maydell [Tue, 23 Sep 2014 13:43:47 +0000 (14:43 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20140923-1' into staging

usb: enable hotplug, switch to realize, ohci tracing, misc fixes.

# gpg: Signature made Tue 23 Sep 2014 12:42:29 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-usb-20140923-1: (26 commits)
  usb: tag standalone ehci as hotpluggable
  usb: tag standalone uhci as hotpluggable
  usb: tag xhci as hotpluggable
  usb-serial: only check speed once at realize time
  usb-bus: introduce a wrapper function to check speed
  usb-bus: remove "init" from USBDeviceClass struct
  usb-mtp: convert init to realize
  usb-redir: convert init to realize
  usb-audio: convert init to realize
  dev-wacom: convert init to realize
  dev-hid: convert init to realize
  usb-ccid: convert init to realize
  dev-serial: convert init to realize
  dev-bluetooth: convert init to realize
  dev-uas: using error_report instead of fprintf
  dev-uas: convert init to realize
  dev-storage: usring error_report instead of fprintf/printf
  dev-storage: convert init to realize
  usb-hub: convert init to realize
  libusb: using error_report instead of fprintf
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/borntraeger/tags/s390x-20140923' into staging
Peter Maydell [Tue, 23 Sep 2014 12:28:06 +0000 (13:28 +0100)]
Merge remote-tracking branch 'remotes/borntraeger/tags/s390x-20140923' into staging

s390x/kvm: some fixes and cleanups

1. sclp: get of of duplicate defines
2. ccw: implement and fix handling of some special cases

# gpg: Signature made Tue 23 Sep 2014 13:10:47 BST using RSA key ID B5A61C7C
# gpg: Can't check signature: public key not found

* remotes/borntraeger/tags/s390x-20140923:
  s390x/css: catch ccw sequence errors
  s390x/css: support format-0 ccws
  s390x: remove duplicate defines in SCLP code

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agos390x/css: catch ccw sequence errors
Cornelia Huck [Fri, 5 Sep 2014 07:33:18 +0000 (09:33 +0200)]
s390x/css: catch ccw sequence errors

We must not allow chains of more than 255 ccws without data transfer.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
9 years agos390x/css: support format-0 ccws
Cornelia Huck [Fri, 5 Sep 2014 07:33:17 +0000 (09:33 +0200)]
s390x/css: support format-0 ccws

Add support for format-0 ccws in channel programs. As a format-1 ccw
contains the same information as format-0 ccws, only supporting larger
addresses, simply convert every ccw to format-1 as we walk the chain.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
9 years agos390x: remove duplicate defines in SCLP code
Jens Freimann [Fri, 5 Sep 2014 07:33:16 +0000 (09:33 +0200)]
s390x: remove duplicate defines in SCLP code

Let's get rid of these duplicate defines.

Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
9 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Tue, 23 Sep 2014 11:08:55 +0000 (12:08 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Mon 22 Sep 2014 12:41:59 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request: (59 commits)
  block: Always compile virtio-blk dataplane
  vring: Better error handling if num is too large
  virtio: Import virtio_vring.h
  async: aio_context_new(): Handle event_notifier_init failure
  block: vhdx - fix reading beyond pointer during image creation
  block: delete cow block driver
  block/archipelago: Fix typo in qemu_archipelago_truncate()
  ahci: Add test_identify case to ahci-test.
  ahci: Add test_hba_enable to ahci-test.
  ahci: Add test_hba_spec to ahci-test.
  ahci: properly shadow the TFD register
  ahci: add test_pci_enable to ahci-test.
  ahci: Add test_pci_spec to ahci-test.
  ahci: MSI capability should be at 0x80, not 0x50.
  ahci: Adding basic functionality qtest.
  layout: Add generators for refcount table and blocks
  fuzz: Add fuzzing functions for entries of refcount table and blocks
  docs: List all image elements currently supported by the fuzzer
  qapi/block-core: Add "new" qcow2 options
  qcow2: Add overlap-check.template option
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agousb: tag standalone ehci as hotpluggable
Gerd Hoffmann [Fri, 29 Aug 2014 12:40:08 +0000 (14:40 +0200)]
usb: tag standalone ehci as hotpluggable

Add a flag to EHCIPCIInfo saying whenever the controller supports
companions or not.  Make sure we only allow registering companions for
ehci versions supporting that.  Enable pci hotplug for the ehci
variants not supporting companions.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb: tag standalone uhci as hotpluggable
Gerd Hoffmann [Fri, 29 Aug 2014 12:13:11 +0000 (14:13 +0200)]
usb: tag standalone uhci as hotpluggable

uhci hostadapters in companion setups can't be hotplugged.  So leave
hotplug disabled for all ich9 variants (which are already tagged with
unplug = true in the info struct).  For the other variants we'll enable
hotplug and remove the companion setup properties.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb: tag xhci as hotpluggable
Gerd Hoffmann [Fri, 29 Aug 2014 12:06:15 +0000 (14:06 +0200)]
usb: tag xhci as hotpluggable

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-serial: only check speed once at realize time
Gonglei [Fri, 19 Sep 2014 07:25:21 +0000 (15:25 +0800)]
usb-serial: only check speed once at realize time

Whatever the chardev is open or not, we should assure
the speed is matched each other. So, call usb_check_attach()
check speed. And then pass &error_abort at all calls to
usb_device_attach().

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-bus: introduce a wrapper function to check speed
Gonglei [Fri, 19 Sep 2014 07:25:20 +0000 (15:25 +0800)]
usb-bus: introduce a wrapper function to check speed

In this way, we can check speed directly, don't need
call usb_device_attach(), which has other conditions,
such as checking the chardev is open.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-bus: remove "init" from USBDeviceClass struct
Gonglei [Fri, 19 Sep 2014 06:48:41 +0000 (14:48 +0800)]
usb-bus: remove "init" from USBDeviceClass struct

All usb-bus devices are realized by realize(),
remove init callback function from USBDeviceClass struct.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-mtp: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:40 +0000 (14:48 +0800)]
usb-mtp: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-redir: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:39 +0000 (14:48 +0800)]
usb-redir: convert init to realize

In this way, all the implementations now use
error_setg instead of qerror_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-audio: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:38 +0000 (14:48 +0800)]
usb-audio: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-wacom: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:37 +0000 (14:48 +0800)]
dev-wacom: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-hid: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:36 +0000 (14:48 +0800)]
dev-hid: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-ccid: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:35 +0000 (14:48 +0800)]
usb-ccid: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-serial: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:34 +0000 (14:48 +0800)]
dev-serial: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-bluetooth: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:33 +0000 (14:48 +0800)]
dev-bluetooth: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-uas: using error_report instead of fprintf
Gonglei [Fri, 19 Sep 2014 06:48:32 +0000 (14:48 +0800)]
dev-uas: using error_report instead of fprintf

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-uas: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:31 +0000 (14:48 +0800)]
dev-uas: convert init to realize

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-storage: usring error_report instead of fprintf/printf
Gonglei [Fri, 19 Sep 2014 06:48:30 +0000 (14:48 +0800)]
dev-storage: usring error_report instead of fprintf/printf

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agodev-storage: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:29 +0000 (14:48 +0800)]
dev-storage: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-hub: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:28 +0000 (14:48 +0800)]
usb-hub: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agolibusb: using error_report instead of fprintf
Gonglei [Fri, 19 Sep 2014 06:48:27 +0000 (14:48 +0800)]
libusb: using error_report instead of fprintf

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agolibusb: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:26 +0000 (14:48 +0800)]
libusb: convert init to realize

In this way, all the implementations now use
error_setg instead of error_report for reporting error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-net: convert init to realize
Gonglei [Fri, 19 Sep 2014 06:48:25 +0000 (14:48 +0800)]
usb-net: convert init to realize

meanwhile, qerror_report_err() is a transitional interface to
help with converting existing HMP commands to QMP. It should
not be used elsewhere.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agousb-bus: convert USBDeviceClass init to realize
Gonglei [Fri, 19 Sep 2014 06:48:24 +0000 (14:48 +0800)]
usb-bus: convert USBDeviceClass init to realize

Add "realize/unrealize" in USBDeviceClass, which has errp
as a parameter. So all the implementations now use
error_setg instead of error_report for reporting error.

Note: this patch still keep "init" in USBDeviceClass, and
call kclass->init in usb_device_realize(), avoid breaking
git bisect. After realize all usb devices, will be removed.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agoohci: Convert fprint/DPRINTF/print to traces
Alexey Kardashevskiy [Fri, 12 Sep 2014 08:55:26 +0000 (18:55 +1000)]
ohci: Convert fprint/DPRINTF/print to traces

This converts many kinds of debug prints to traces.

This implements packets logging to avoid unnecessary calculations if
usb_ohci_td_pkt_short/usb_ohci_td_pkt_long is not enabled.

This makes OHCI errors (such as "DMA error") invisible by default.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agoMerge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-09-22' into staging
Peter Maydell [Tue, 23 Sep 2014 10:00:07 +0000 (11:00 +0100)]
Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-09-22' into staging

trivial patches for 2014-09-22

# gpg: Signature made Mon 22 Sep 2014 09:10:03 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-09-22:
  arch_init: Setting QEMU_ARCH enum straight
  pc: Add missing 'static' attribute
  block: allow creation of fixed vhdx images
  vl: Print maxmem in hex format for error message
  configure: trivial fixes
  xen-hvm.c: Always return -1 when failure occurs in xen_hvm_init()
  rdma: Fix incorrect description in comments
  Fix typos and misspellings in comments
  qemu-char: Permit only a single "stdio" character device

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agousb-storage: fix possible memory leak and missing error message
Gonglei [Fri, 19 Sep 2014 06:48:23 +0000 (14:48 +0800)]
usb-storage: fix possible memory leak and missing error message

When scsi_bus_legacy_add_drive() return NULL, meanwhile err will
be not NULL, which will casue memory leak and missing error message.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agoblock: Always compile virtio-blk dataplane
Fam Zheng [Wed, 10 Sep 2014 06:17:51 +0000 (14:17 +0800)]
block: Always compile virtio-blk dataplane

Dataplane doesn't depend on linux-aio any more, so we don't need the
compiling condition now.

Configure options are kept but just print a message.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1410329871-28885-4-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agovring: Better error handling if num is too large
Fam Zheng [Wed, 10 Sep 2014 06:17:50 +0000 (14:17 +0800)]
vring: Better error handling if num is too large

To be more consistent inside this function.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1410329871-28885-3-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agovirtio: Import virtio_vring.h
Fam Zheng [Wed, 10 Sep 2014 06:17:49 +0000 (14:17 +0800)]
virtio: Import virtio_vring.h

This header has no further dependencies. It only has some stable data
types and primitive functions, so we can copy it to include/hw/virtio in
order to allow vring code (and its user virtio-blk dataplane) to be
built unconditionally, even for cross compiling.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1410329871-28885-2-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoasync: aio_context_new(): Handle event_notifier_init failure
Chrysostomos Nanakos [Thu, 18 Sep 2014 11:30:49 +0000 (14:30 +0300)]
async: aio_context_new(): Handle event_notifier_init failure

On a system with a low limit of open files the initialization
of the event notifier could fail and QEMU exits without printing any
error information to the user.

The problem can be easily reproduced by enforcing a low limit of open
files and start QEMU with enough I/O threads to hit this limit.

The same problem raises, without the creation of I/O threads, while
QEMU initializes the main event loop by enforcing an even lower limit of
open files.

This commit adds an error message on failure:

 # qemu [...] -object iothread,id=iothread0 -object iothread,id=iothread1
 qemu: Failed to initialize event notifier: Too many open files in system

Signed-off-by: Chrysostomos Nanakos <cnanakos@grnet.gr>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: vhdx - fix reading beyond pointer during image creation
Jeff Cody [Tue, 16 Sep 2014 19:12:06 +0000 (15:12 -0400)]
block: vhdx - fix reading beyond pointer during image creation

In vhdx_create_metadata(), we allocate 40 bytes to entry_buffer for
the various metadata table entries.  However, we write out 64kB from
that buffer into the new file.  Only write out the correct 40 bytes.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: delete cow block driver
Stefan Hajnoczi [Tue, 16 Sep 2014 14:24:24 +0000 (15:24 +0100)]
block: delete cow block driver

This patch removes support for the cow file format.

Normally we do not break backwards compatibility but in this case there
is no impact and it is the most logical option.  Extraordinary claims
require extraordinary evidence so I will show why removing the cow block
driver is the right thing to do.

The cow file format is the disk image format for Usermode Linux, a way
of running a Linux system in userspace.  The performance of UML was
never great and it was hacky, but it enjoyed some popularity before
hardware virtualization support became mainstream.

QEMU's block/cow.c is supposed to read this image file format.
Unfortunately the file format was underspecified:

1. Earlier Linux versions used the MAXPATHLEN constant for the backing
   filename field.  The value of MAXPATHLEN can change, so Linux
   switched to a 4096 literal but QEMU has a 1024 literal.

2. Padding was not used on the header struct (both in the Linux kernel
   and in QEMU) so the struct layout varied across architectures.  In
   particular, i386 and x86_64 were different due to int64_t alignment
   differences.  Linux now uses __attribute__((packed)), QEMU does not.

Therefore:

1. QEMU cow images do not conform to the Linux cow image file format.

2. cow images cannot be shared between different host architectures.

This means QEMU cow images are useless and QEMU has not had bug reports
from users actually hitting these issues.

Let's get rid of this thing, it serves no purpose and no one will be
affected.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1410877464-20481-1-git-send-email-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock/archipelago: Fix typo in qemu_archipelago_truncate()
Chrysostomos Nanakos [Tue, 16 Sep 2014 09:17:11 +0000 (12:17 +0300)]
block/archipelago: Fix typo in qemu_archipelago_truncate()

Fix a typo introduced by 94c80a438c85f2c19698547fbb115ea46d80c5f1

Signed-off-by: Chrysostomos Nanakos <cnanakos@grnet.gr>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: Add test_identify case to ahci-test.
John Snow [Thu, 21 Aug 2014 17:44:39 +0000 (13:44 -0400)]
ahci: Add test_identify case to ahci-test.

Utilizing all of the bring-up code in pci_enable and hba_enable,
this test issues a simple IDENTIFY command via the HBA and retrieves
the response via the PIO receive mechanisms of the HBA.

Bugs: The DPS interrupt (Descriptor Processed Status) does not
currently get set. This will need to be adjusted in a future
patch series when the AHCI DMA pathways are reworked to allow
the feature, which may be utilized by OSX guests.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-9-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: Add test_hba_enable to ahci-test.
John Snow [Thu, 21 Aug 2014 17:44:38 +0000 (13:44 -0400)]
ahci: Add test_hba_enable to ahci-test.

This test engages the HBA functionality and initializes
values to sane defaults to allow for minimal HBA functionality.

Buffers are allocated and pointers are updated to allow minimal
I/O commands to complete as expected. Error registers and responses
are sanity checked for specification adherence.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-8-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: Add test_hba_spec to ahci-test.
John Snow [Thu, 21 Aug 2014 17:44:37 +0000 (13:44 -0400)]
ahci: Add test_hba_spec to ahci-test.

Add a test routine that checks the boot-up values of the HBA
configuration memory space against the AHCI 1.3 specification
and Intel ICH9 data sheet (for Q35 machines) for adherence and
sane values.

The HBA is not yet engaged or put into the idle state.

[Replaced g_assert_false(...) with g_assert(!...) for glib <2.38
compatibility, reported by Peter Maydell <peter.maydell@linaro.org>.
--Stefan]

Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1408643079-30675-7-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: properly shadow the TFD register
John Snow [Thu, 21 Aug 2014 17:44:36 +0000 (13:44 -0400)]
ahci: properly shadow the TFD register

In a real AHCI device, several S/ATA registers are mirrored or shadowed
within the AHCI register set. These registers are not updated
synchronously for each read access, but are instead updated after a
Device-to-Host Register FIS packet is received. The D2H FIS contains
the values from these registers on the device.

In QEMU, by reaching directly into the device to grab these bits before
they are "sent," we may introduce race conditions where unexpected
values are present "before they are sent" which could cause issues for
some guests, particularly if an attempt is made to read the PxTFD
register prior to enabling the port, where incorrect values will be read.

This patch also addresses the boot-time values for the PxTFD and PxSIG
registers to bring them in line with the AHCI 1.3 specification.

Lastly, several fields (PxTFD, PxSIG and PxSACT) are read-only,
and any attempts to write to them should be ignored.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-6-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: add test_pci_enable to ahci-test.
John Snow [Thu, 21 Aug 2014 17:44:35 +0000 (13:44 -0400)]
ahci: add test_pci_enable to ahci-test.

This adds a test wherein we engage the PCI AHCI
device and ensure that the memory region for the
HBA functionality is now accessible.

Under Q35 environments, additional PCI configuration
is performed to ensure that the HBA functionality
will become usable.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-5-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: Add test_pci_spec to ahci-test.
John Snow [Thu, 21 Aug 2014 17:44:34 +0000 (13:44 -0400)]
ahci: Add test_pci_spec to ahci-test.

Adds a specification adherence test for AHCI
where the boot-up values for the PCI configuration space
are compared against the AHCI 1.3 specification.

This test does not itself attempt to engage the device.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-4-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: MSI capability should be at 0x80, not 0x50.
John Snow [Thu, 21 Aug 2014 17:44:33 +0000 (13:44 -0400)]
ahci: MSI capability should be at 0x80, not 0x50.

In the Intel ICH9 data sheet, the MSI capability offset
in the PCI configuration space for ICH9 AHCI devices is
specified to be 0x80.

Further, the PCI capability pointer should always point
to 0x80 in ICH9 devices, despite the fact that AHCI 1.3
specifies that it should be pointing to PMCAP (Which in
this instance would be 0x70) to maintain adherence to
the Intel data sheet specifications and real observed behavior.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-3-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoahci: Adding basic functionality qtest.
John Snow [Thu, 21 Aug 2014 17:44:32 +0000 (13:44 -0400)]
ahci: Adding basic functionality qtest.

Currently, there is no qtest to test the functionality of
the AHCI functionality present within the Q35 machine type.

This patch adds a skeleton for an AHCI test suite,
and adds a simple sanity-check test case where we
identify that the AHCI device is present, then
disengage the virtual machine.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1408643079-30675-2-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agolayout: Add generators for refcount table and blocks
Maria Kustova [Tue, 19 Aug 2014 12:25:13 +0000 (16:25 +0400)]
layout: Add generators for refcount table and blocks

Refcount structures are placed in clusters randomly selected from all
unallocated host clusters.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Maria Kustova <maria.k@catit.be>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 7e2f38608db6fba2da53997390b19400d445c45d.1408450493.git.maria.k@catit.be
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agofuzz: Add fuzzing functions for entries of refcount table and blocks
Maria Kustova [Tue, 19 Aug 2014 12:25:12 +0000 (16:25 +0400)]
fuzz: Add fuzzing functions for entries of refcount table and blocks

Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Maria Kustova <maria.k@catit.be>
Message-id: c9f4027b6f401c67e9d18f94aed29be445e81d48.1408450493.git.maria.k@catit.be
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agodocs: List all image elements currently supported by the fuzzer
Maria Kustova [Tue, 19 Aug 2014 12:25:11 +0000 (16:25 +0400)]
docs: List all image elements currently supported by the fuzzer

Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Maria Kustova <maria.k@catit.be>
Message-id: cb71485d0f55d1d8401eebaead8324eb78673060.1408450493.git.maria.k@catit.be
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqapi/block-core: Add "new" qcow2 options
Max Reitz [Wed, 20 Aug 2014 17:59:36 +0000 (19:59 +0200)]
qapi/block-core: Add "new" qcow2 options

qcow2 supports more than four options by now, add the new options
(overlap check mode and metadata cache size)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1408557576-14574-5-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqcow2: Add overlap-check.template option
Max Reitz [Wed, 20 Aug 2014 17:59:35 +0000 (19:59 +0200)]
qcow2: Add overlap-check.template option

Being able to set the overlap-check option to a string and then refine
it via the overlap-check.* options is a nice idea for the command line
but does not work so well for non-flattened dicts. In that case, one can
only specify either but not both, so add a field to overlap-check.*
which does the same as directly specifying overlap-check but can be used
in conjunction with the other fields in non-flattened dicts.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1408557576-14574-4-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqapi: Allow enums in anonymous unions
Max Reitz [Wed, 20 Aug 2014 17:59:34 +0000 (19:59 +0200)]
qapi: Allow enums in anonymous unions

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1408557576-14574-3-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqcow2: Fix leak of QemuOpts in qcow2_open()
Max Reitz [Wed, 20 Aug 2014 17:59:33 +0000 (19:59 +0200)]
qcow2: Fix leak of QemuOpts in qcow2_open()

Currently, the QemuOpts object opts is leaked if anything fails from its
creation up to and including the image repair block. Fix this by freeing
that object in the fail path.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Message-id: 1408557576-14574-2-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agohmp: fix memory leak at hmp_info_block_jobs()
Gonglei [Tue, 16 Sep 2014 13:36:55 +0000 (21:36 +0800)]
hmp: fix memory leak at hmp_info_block_jobs()

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1410874615-14292-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoimage-fuzzer: Trivial readability and formatting improvements
Maria Kustova [Sun, 14 Sep 2014 12:07:02 +0000 (16:07 +0400)]
image-fuzzer: Trivial readability and formatting improvements

Signed-off-by: Maria Kustova <maria.k@catit.be>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoiotests: Add more tests for qcow2 corruption
Max Reitz [Fri, 5 Sep 2014 14:07:19 +0000 (16:07 +0200)]
iotests: Add more tests for qcow2 corruption

Add tests for unaligned L1/L2/reftable entries and non-fatal corruption
reports.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1409926039-29044-6-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqcow2: Check L1/L2/reftable entries for alignment
Max Reitz [Fri, 5 Sep 2014 14:07:18 +0000 (16:07 +0200)]
qcow2: Check L1/L2/reftable entries for alignment

Offsets taken from the L1, L2 and refcount tables are generally assumed
to be correctly aligned. However, this cannot be guaranteed if the image
has been written to by something different than qemu, thus check all
offsets taken from these tables for correct cluster alignment.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1409926039-29044-5-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqcow2: Use qcow2_signal_corruption() for overlaps
Max Reitz [Fri, 5 Sep 2014 14:07:17 +0000 (16:07 +0200)]
qcow2: Use qcow2_signal_corruption() for overlaps

Use the new function in case of a failed overlap check.

This changes output in case of corruption, so adapt iotest 060's
reference output accordingly.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Message-id: 1409926039-29044-4-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqcow2: Add qcow2_signal_corruption()
Max Reitz [Fri, 5 Sep 2014 14:07:16 +0000 (16:07 +0200)]
qcow2: Add qcow2_signal_corruption()

Add a helper function for easily marking an image corrupt (on fatal
corruptions) while outputting an informative message to stderr and via
QAPI.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Message-id: 1409926039-29044-3-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqapi/block: Add "fatal" to BLOCK_IMAGE_CORRUPTED
Max Reitz [Fri, 5 Sep 2014 14:07:15 +0000 (16:07 +0200)]
qapi/block: Add "fatal" to BLOCK_IMAGE_CORRUPTED

Not every BLOCK_IMAGE_CORRUPTED event must be fatal; for example, when
reading from an image, they should generally not be. Nonetheless, even
an image only read from may of course be corrupted and this can be
detected during normal operation. In this case, a non-fatal event should
be emitted, but the image should not be marked corrupt (in accordance to
"fatal" set to false).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1409926039-29044-2-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqapi: Sort items in BlockdevOptions definition
Fam Zheng [Thu, 11 Sep 2014 06:09:58 +0000 (14:09 +0800)]
qapi: Sort items in BlockdevOptions definition

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1410415798-20673-4-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqapi: Sort BlockdevDriver enum data list
Fam Zheng [Thu, 11 Sep 2014 06:09:57 +0000 (14:09 +0800)]
qapi: Sort BlockdevDriver enum data list

Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1410415798-20673-3-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Introduce "null" drivers
Fam Zheng [Thu, 11 Sep 2014 06:09:56 +0000 (14:09 +0800)]
block: Introduce "null" drivers

This is an analogue to Linux null_blk. It can be used for testing or
benchmarking block device emulation and general block layer
functionalities such as coroutines and throttling, where disk IO is not
necessary or wanted.

Use null-aio:// for AIO version, and null-co:// for coroutine version.

[Resolved conflict with Fam's async bdrv_aio_cancel() series:
1. Drop .bdrv_aio_cancel() since it is now done by block.c
2. Rename qemu_aio_release() to qemu_aio_unref()
--Stefan]

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1410415798-20673-2-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoaio-win32: avoid out-of-bounds access to the events array
Paolo Bonzini [Mon, 15 Sep 2014 12:52:58 +0000 (14:52 +0200)]
aio-win32: avoid out-of-bounds access to the events array

If ret is WAIT_TIMEOUT and there was an event returned by select(),
we can write to a location after the end of the array.  But in
that case we can retry the WaitForMultipleObjects call with the
same set of events, so just move the event[ret - WAIT_OBJECT_0]
assignment inside the existin conditional.

Reported-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqdev-monitor: fix segmentation fault on qdev_device_help()
Gonglei [Tue, 16 Sep 2014 02:19:33 +0000 (10:19 +0800)]
qdev-monitor: fix segmentation fault on qdev_device_help()

Normally, qmp_device_list_properties() may return NULL when
a device haven't special properties excpet Object and DeviceState
properties, such as virtio-balloon-device.

We just need check local_err instead of prop_list.

Example:

Segmentation fault (core dumped)

The backtrace as below:

Program received signal SIGSEGV, Segmentation fault.
0x00005555559af1a8 in error_get_pretty (err=0x0) at util/error.c:152
152         return err->msg;
(gdb) bt
    func=0x55555574a6ca <device_help_func>, opaque=0x0, abort_on_failure=0) at util/qemu-option.c:1072

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Rename qemu_aio_release -> qemu_aio_unref
Fam Zheng [Thu, 11 Sep 2014 05:41:28 +0000 (13:41 +0800)]
block: Rename qemu_aio_release -> qemu_aio_unref

Suggested-by: Benoît Canet <benoit.canet@irqsave.net>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Drop AIOCBInfo.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:27 +0000 (13:41 +0800)]
block: Drop AIOCBInfo.cancel

Now that all the implementations are converted to asynchronous version
and we can emulate synchronous cancellation with it. Let's drop the
unused member.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoide: Convert trim_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:26 +0000 (13:41 +0800)]
ide: Convert trim_aiocb_info.cancel to .cancel_async

We know that either bh is scheduled or ide_issue_trim_cb will be called
again, so we just set i, j and ret to the right values. In both cases,
ide_trim_bh_cb will be called.

Also forward the cancellation to the iocb->aiocb which we get from
bdrv_aio_discard.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agowin32-aio: Drop win32_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:25 +0000 (13:41 +0800)]
win32-aio: Drop win32_aiocb_info.cancel

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agosheepdog: Convert sd_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:24 +0000 (13:41 +0800)]
sheepdog: Convert sd_aiocb_info.cancel to .cancel_async

Also drop the now unused SheepdogAIOCB.finished field. Note that this
aio is internal to sheepdog driver and has NULL cb and opaque, and
should be unused at all.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agorbd: Drop rbd_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:23 +0000 (13:41 +0800)]
rbd: Drop rbd_aiocb_info.cancel

And also drop the now unused "cancelled" field.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoquorum: Convert quorum_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:22 +0000 (13:41 +0800)]
quorum: Convert quorum_aiocb_info.cancel to .cancel_async

Before, we cancel all the child requests with bdrv_aio_cancel, then free
the acb..

Now we just kick off asynchronous cancellation of child requests and
return, we know quorum_aio_cb will be called later, so in the end
quorum_aio_finalize will take care of calling the caller's cb.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoquorum: fix quorum_aio_cancel()
Liu Yuan [Thu, 11 Sep 2014 05:41:21 +0000 (13:41 +0800)]
quorum: fix quorum_aio_cancel()

For a fifo read pattern, we only have one running aio (possible other cases that
has less number than num_children in the future), so we need to check if
.acb is NULL against bdrv_aio_cancel() to avoid segfault.

Cc: Eric Blake <eblake@redhat.com>
Cc: Benoit Canet <benoit@irqsave.net>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoqed: Drop qed_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:20 +0000 (13:41 +0800)]
qed: Drop qed_aiocb_info.cancel

Also drop the now unused ->finished field.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agocurl: Drop curl_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:19 +0000 (13:41 +0800)]
curl: Drop curl_aiocb_info.cancel

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblkverify: Drop blkverify_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:18 +0000 (13:41 +0800)]
blkverify: Drop blkverify_aiocb_info.cancel

Also the finished pointer is not used any more.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblkdebug: Drop blkdebug_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:17 +0000 (13:41 +0800)]
blkdebug: Drop blkdebug_aiocb_info.cancel

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoarchipelago: Drop archipelago_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:16 +0000 (13:41 +0800)]
archipelago: Drop archipelago_aiocb_info.cancel

The cancelled flag is no longer useful. Later the request will complete
as before, and cb will be called.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoiscsi: Convert iscsi_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:15 +0000 (13:41 +0800)]
iscsi: Convert iscsi_aiocb_info.cancel to .cancel_async

Also drop the unused field "canceled".

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agodma: Convert dma_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:14 +0000 (13:41 +0800)]
dma: Convert dma_aiocb_info.cancel to .cancel_async

Just forward the request to bdrv_aio_cancel_async.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agolinux-aio: Convert laio_aiocb_info.cancel to .cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:13 +0000 (13:41 +0800)]
linux-aio: Convert laio_aiocb_info.cancel to .cancel_async

Just call io_cancel (2), if it fails, it means the request is not
canceled, so the event loop will eventually call
qemu_laio_process_completion.

In qemu_laio_process_completion, change to call the cb unconditionally.
It is required by bdrv_aio_cancel_async.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agothread-pool: Convert thread_pool_aiocb_info.cancel to cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:12 +0000 (13:41 +0800)]
thread-pool: Convert thread_pool_aiocb_info.cancel to cancel_async

The .cancel_async shares the same the first half with .cancel: try to
steal the request if not submitted yet. In this case set the elem to
THREAD_DONE status and ret to -ECANCELED, which means
thread_pool_completion_bh will call the cb with -ECANCELED.

If the request is already submitted, do nothing, as we know the normal
completion will happen in the future.

Testing code update:

Before, done_cb is only called if the request is already submitted by
thread pool. Now done_cb is always called, even before it is submitted,
because we emulate bdrv_aio_cancel with bdrv_aio_cancel_async. So also
update the test criteria accordingly.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Drop bdrv_em_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:11 +0000 (13:41 +0800)]
block: Drop bdrv_em_aiocb_info.cancel

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Drop bdrv_em_co_aiocb_info.cancel
Fam Zheng [Thu, 11 Sep 2014 05:41:10 +0000 (13:41 +0800)]
block: Drop bdrv_em_co_aiocb_info.cancel

Also drop the now unused ->done pointer.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Add bdrv_aio_cancel_async
Fam Zheng [Thu, 11 Sep 2014 05:41:09 +0000 (13:41 +0800)]
block: Add bdrv_aio_cancel_async

This is the async version of bdrv_aio_cancel, which doesn't block the
caller. It guarantees that the cb is called either before returning or
some time later.

bdrv_aio_cancel can base on bdrv_aio_cancel_async, later we can convert
all .io_cancel implementations to .io_cancel_async, and the aio_poll is
the common logic. In the end, .io_cancel can be dropped.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock: Add refcnt in BlockDriverAIOCB
Fam Zheng [Thu, 11 Sep 2014 05:41:08 +0000 (13:41 +0800)]
block: Add refcnt in BlockDriverAIOCB

This will be useful in synchronous cancel emulation with
bdrv_aio_cancel_async.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoide/ahci: Check for -ECANCELED in aio callbacks
Fam Zheng [Thu, 11 Sep 2014 05:41:07 +0000 (13:41 +0800)]
ide/ahci: Check for -ECANCELED in aio callbacks

Before, bdrv_aio_cancel will either complete the request (like normal)
and call CB with an actual return code, or skip calling the request (for
example when the IO req is not submitted by thread pool yet).

We will change bdrv_aio_cancel to do it differently: always call CB
before return, with either [1] a normal req completion ret code, or [2]
ret == -ECANCELED. So the callers' callback must accept both cases. The
existing logic works with case [1], but not [2].

The simplest transition of callback code is do nothing in case [2], just
as if the CB is not called by the bdrv_aio_cancel() call.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoaio-win32: fix uninitialized use of have_select_revents
Paolo Bonzini [Fri, 12 Sep 2014 10:08:49 +0000 (12:08 +0200)]
aio-win32: fix uninitialized use of have_select_revents

Always initialize it with the return value of aio_prepare.

Reported-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoide/atapi: Mark non-data commands as complete
John Snow [Sat, 13 Sep 2014 03:51:12 +0000 (23:51 -0400)]
ide/atapi: Mark non-data commands as complete

When the command completion code in IDE and AHCI
was unified to put all command completion inside
of a callback, "cmd_done," we neglected to
ensure that all AHCI/ATAPI command paths would
eventually register as finished. for the PCI
interface to IDE this is not a problem because
cmd_done is a nop, but the AHCI implementation
needs to send a D2H_REG_FIS and interrupt back
to the guest to inform of completion.

This patch adds calls to ide_stop_transfer,
which calls ide_cmd_done, inside of
ide_atapi_cmd_ok and ide_atapi_cmd_error.

This fixes regressions observed by trying to boot QEMU
with a Fedora 20 live CD under Q35/AHCI, which uses
ATAPI command 0x00, which is a status check that may
cause a hang because we never complete, and ATAPI
command 0x56, which is unsupported by our current
implementation and results in an error that we never
report back to the guest.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoblock/vhdx.c: Mark parent_vhdx_guid variable as unused
Peter Maydell [Sun, 14 Sep 2014 19:29:59 +0000 (20:29 +0100)]
block/vhdx.c: Mark parent_vhdx_guid variable as unused

The parent_vhdx_guid variable is defined but never used, which provokes
complaints from newer versions of clang. Since the variable definition
is here acting as documentation of the image format, mark it with the
'unused' attribute to keep the compiler happy rather than simply
deleting it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoarch_init: Setting QEMU_ARCH enum straight
Bastian Koppelmann [Sun, 21 Sep 2014 11:07:21 +0000 (12:07 +0100)]
arch_init: Setting QEMU_ARCH enum straight

Every QEMU_ARCH is now in (1 << n) notation, instead of a mixture of decimal and hexadecimal.

Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agopc: Add missing 'static' attribute
Stefan Weil [Fri, 19 Sep 2014 20:49:03 +0000 (22:49 +0200)]
pc: Add missing 'static' attribute

This fixes a warning from smatch (static code analysis).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoblock: allow creation of fixed vhdx images
Adelina Tuvenie [Thu, 18 Sep 2014 15:17:44 +0000 (18:17 +0300)]
block: allow creation of fixed vhdx images

When trying to create a fixed vhd image qemu-img will return the
following error:

 qemu-img: test.vhdx: Could not create image: Cannot allocate memory

This happens because of a incorrect check in vhdx.c. Specifficaly,
in vhdx_create_bat(), after allocating memory for the BAT entry,
there is a check to determine if the allocation was unsuccsessful.
The error comes from the fact that it checks if s->bat isn't NULL,
which is true in case of succsessful allocation,  and exits with
error ENOMEM.

Signed-off-by: Adelina Tuvenie <atuvenie@cloudbasesolutions.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agousb-storage: Fix how legacy init handles option ID clash
Markus Armbruster [Fri, 12 Sep 2014 19:24:34 +0000 (21:24 +0200)]
usb-storage: Fix how legacy init handles option ID clash

usb_msd_init() calls qemu_opts_create() with a made-up ID and false
fail_if_exists.  If the ID already exists, it happily messes up those
options, then fails drive_new(), because the BlockDriverState with
that ID already exists, too.

Reproducer: -drive if=none,id=usb0,format=raw -usbdevice disk:tmp.qcow2

Pass true fail_if_exists to qemu_opts_create(), and if it fails, try
the next made-up ID.

The reproducer now succeeds, and creates an usb-storage device with ID
usb1.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agovl: Print maxmem in hex format for error message
zhanghailiang [Tue, 16 Sep 2014 10:45:36 +0000 (18:45 +0800)]
vl: Print maxmem in hex format for error message

In error message, maxmem is printed in Dec but ram_size in Hex.
It is better to print them in same format.
Also use error_report instead of fprintf.

Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoconfigure: trivial fixes
Gonglei [Sat, 20 Sep 2014 07:33:18 +0000 (15:33 +0800)]
configure: trivial fixes

Make them consistent with the others.

Cc: qemu-trivial@nongnu.org
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agoxen-hvm.c: Always return -1 when failure occurs in xen_hvm_init()
Chen Gang [Thu, 4 Sep 2014 14:32:46 +0000 (22:32 +0800)]
xen-hvm.c: Always return -1 when failure occurs in xen_hvm_init()

When failure occurs, it need to use "return -1" instead of exit(1), so
an upper layer has a chance to print failure information, too.

For simplicity, in xen_hvm_init(), also use '-1' instead of all
'-errno', since all related upper callers always exit(1) on failure.

It is not a normal function, it does not release related resources when
return -1, so need give related comments for it.

It passes common check:

  "./configure --enable-xen && make && make check"
  "echo $? == 0"

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9 years agordma: Fix incorrect description in comments
zhanghailiang [Fri, 12 Sep 2014 06:03:14 +0000 (14:03 +0800)]
rdma: Fix incorrect description in comments

Since we have supported memory hotplug, VM's ram include pc.ram
and hotplug-memory.

Fix the confused description for rdma migration: pc.ram -> VM's ram

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>