sdk/emulator/qemu.git
11 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Mon, 23 Sep 2013 16:52:49 +0000 (11:52 -0500)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

# By Alexey Kardashevskiy (3) and others
# Via Paolo Bonzini
* qemu-kvm/uq/master:
  target-i386: add feature kvm_pv_unhalt
  linux-headers: update to 3.12-rc1
  target-i386: forward CPUID cache leaves when -cpu host is used
  linux-headers: update to 3.11
  kvm: fix traces to use %x instead of %d
  kvmvapic: Clear also physical ROM address when entering INACTIVE state
  kvmvapic: Enter inactive state on hardware reset
  kvmvapic: Catch invalid ROM size
  kvm irqfd: support direct msimessage to irq translation
  fix steal time MSR vmsd callback to proper opaque type
  kvm: warn if num cpus is greater than num recommended
  cpu: Move cpu state syncs up into cpu_dump_state()
  exec: always use MADV_DONTFORK

Message-id: 1379694292-1601-1-git-send-email-pbonzini@redhat.com

11 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Mon, 23 Sep 2013 16:52:32 +0000 (11:52 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

# By Hervé Poussineau (5) and Stefan Weil (1)
# Via Paolo Bonzini
* bonzini/scsi-next:
  block/iscsi: Drop iscsi_co_get_block_status for older versions of libiscsi
  lsi: add 53C810 variant
  lsi: remove todo
  lsi: ignore write accesses to CTEST0 registers
  lsi: check ssid versus sdid only if ssid is valid
  lsi: use constant name instead of its value

11 years agoMerge remote-tracking branch 'spice/spice.v74' into staging
Anthony Liguori [Fri, 20 Sep 2013 13:08:18 +0000 (08:08 -0500)]
Merge remote-tracking branch 'spice/spice.v74' into staging

# By Gerd Hoffmann
# Via Gerd Hoffmann
* spice/spice.v74:
  qxl: compile only once
  qxl: simplify page dirtying
  qxl: simplify qxl_rom_size
  qxl: define qxl operating on 4k pages

Message-id: 1379583534-7831-1-git-send-email-kraxel@redhat.com

11 years agoMerge remote-tracking branch 'kraxel/usb.90' into staging
Anthony Liguori [Fri, 20 Sep 2013 13:08:08 +0000 (08:08 -0500)]
Merge remote-tracking branch 'kraxel/usb.90' into staging

# By Hans de Goede (6) and Gerd Hoffmann (1)
# Via Gerd Hoffmann
* kraxel/usb.90:
  usb: Fix iovec memleak on combined-packet free
  usb: Also reset max_packet_size on ep_reset
  xhci: Fix memory leak on xhci_disable_ep
  xhci: Add xhci_epid_to_usbep helper function
  xhci: Init a transfers xhci, slotid and epid member on epctx alloc
  xhci: Fix number of streams allocated when using streams
  usb: remove old usb-host code

Message-id: 1379583298-7524-1-git-send-email-kraxel@redhat.com

11 years agoMerge remote-tracking branch 'luiz/queue/qmp' into staging
Anthony Liguori [Fri, 20 Sep 2013 13:06:38 +0000 (08:06 -0500)]
Merge remote-tracking branch 'luiz/queue/qmp' into staging

# By Luiz Capitulino
# Via Luiz Capitulino
* luiz/queue/qmp:
  QMP: qmp-events.txt: alphabetical order fix and other minor changes
  QMP: Update qmp-spec.txt
  QMP: Update README file
  QMP: QMP/ -> docs/qmp/
  QMP: fix qmp-commands.txt generation path
  QMP: add scripts/qmp

Message-id: 1379509422-29115-1-git-send-email-lcapitulino@redhat.com

11 years agotarget-i386: add feature kvm_pv_unhalt
Andrew Jones [Wed, 18 Sep 2013 14:41:45 +0000 (16:41 +0200)]
target-i386: add feature kvm_pv_unhalt

I don't know yet if want this feature on by default, so for now I'm
just adding support for "-cpu ...,+kvm_pv_unhalt".

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolinux-headers: update to 3.12-rc1
Andrew Jones [Wed, 18 Sep 2013 14:41:44 +0000 (16:41 +0200)]
linux-headers: update to 3.12-rc1

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agotarget-i386: forward CPUID cache leaves when -cpu host is used
Benoît Canet [Mon, 2 Sep 2013 15:06:37 +0000 (17:06 +0200)]
target-i386: forward CPUID cache leaves when -cpu host is used

Some users running cpu intensive tasks checking the cache CPUID leaves at
startup and making decisions based on the result reported that the guest was
not reflecting the host CPUID leaves when -cpu host is used.

This patch fix this.

Signed-off-by: Benoît Canet <benoit@irqsave.net>
[Rename new field to cache_info_passthrough - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolinux-headers: update to 3.11
Alexey Kardashevskiy [Tue, 3 Sep 2013 08:27:37 +0000 (18:27 +1000)]
linux-headers: update to 3.11

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvm: fix traces to use %x instead of %d
Alexey Kardashevskiy [Wed, 4 Sep 2013 10:26:25 +0000 (20:26 +1000)]
kvm: fix traces to use %x instead of %d

KVM request types are normally defined using hex constants but QEMU traces
print decimal values instead, which is not very convenient.

This changes the request type format from %d to %x.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvmvapic: Clear also physical ROM address when entering INACTIVE state
Jan Kiszka [Tue, 3 Sep 2013 16:08:52 +0000 (18:08 +0200)]
kvmvapic: Clear also physical ROM address when entering INACTIVE state

To avoid misinterpreting INACTIVE after migration as old qemu-kvm's
STANDBY, also clear rom_state_paddr when going back to this state.

CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvmvapic: Enter inactive state on hardware reset
Jan Kiszka [Tue, 3 Sep 2013 16:08:51 +0000 (18:08 +0200)]
kvmvapic: Enter inactive state on hardware reset

ROM layout may change after reset of devices are hotplugged, so we have
to pick up the physical address again when the ROM is initialized. This
is best achieved by resetting the state to INACTIVE.

CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvmvapic: Catch invalid ROM size
Jan Kiszka [Tue, 3 Sep 2013 16:08:50 +0000 (18:08 +0200)]
kvmvapic: Catch invalid ROM size

If not caught early, a zero-length ROM will cause a NULL-pointer access
later on in patch_hypercalls when allocating a zero-length ROM copy and
trying to read from it.

CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvm irqfd: support direct msimessage to irq translation
Alexey Kardashevskiy [Tue, 3 Sep 2013 08:08:25 +0000 (18:08 +1000)]
kvm irqfd: support direct msimessage to irq translation

On PPC64 systems MSI Messages are translated to system IRQ in a PCI
host bridge. This is already supported for emulated MSI/MSIX but
not for irqfd where the current QEMU allocates IRQ numbers from
irqchip and maps MSIMessages to IRQ in the host kernel.

This adds a new direct mapping flag which tells
the kvm_irqchip_add_msi_route() function that a new VIRQ
should not be allocated, instead the value from MSIMessage::data
should be used. It is up to the platform code to make sure that
this contains a valid IRQ number as sPAPR does in spapr_pci.c.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agofix steal time MSR vmsd callback to proper opaque type
Marcelo Tosatti [Tue, 3 Sep 2013 21:55:16 +0000 (18:55 -0300)]
fix steal time MSR vmsd callback to proper opaque type

Convert steal time MSR vmsd callback pointer to proper X86CPU type.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agokvm: warn if num cpus is greater than num recommended
Andrew Jones [Fri, 23 Aug 2013 13:24:37 +0000 (15:24 +0200)]
kvm: warn if num cpus is greater than num recommended

The comment in kvm_max_vcpus() states that it's using the recommended
procedure from the kernel API documentation to get the max number
of vcpus that kvm supports. It is, but by always returning the
maximum number supported. The maximum number should only be used
for development purposes. qemu should check KVM_CAP_NR_VCPUS for
the recommended number of vcpus. This patch adds a warning if a user
specifies a number of cpus between the recommended and max.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
11 years agocpu: Move cpu state syncs up into cpu_dump_state()
James Hogan [Tue, 27 Aug 2013 11:19:10 +0000 (12:19 +0100)]
cpu: Move cpu state syncs up into cpu_dump_state()

The x86 and ppc targets call cpu_synchronize_state() from their
*_cpu_dump_state() callbacks to ensure that up to date state is dumped
when KVM is enabled (for example when a KVM internal error occurs).

Move this call up into the generic cpu_dump_state() function so that
other KVM targets (namely MIPS) can take advantage of it.

This requires kvm_cpu_synchronize_state() and cpu_synchronize_state() to
be moved out of the #ifdef NEED_CPU_H in <sysemu/kvm.h> so that they're
accessible to qom/cpu.c.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Andreas Färber <afaerber@suse.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: qemu-ppc@nongnu.org
Cc: kvm@vger.kernel.org
Signed-off-by: Gleb Natapov <gleb@redhat.com>
11 years agoexec: always use MADV_DONTFORK
Andrea Arcangeli [Thu, 25 Jul 2013 10:11:15 +0000 (12:11 +0200)]
exec: always use MADV_DONTFORK

MADV_DONTFORK prevents fork to fail with -ENOMEM if the default
overcommit heuristics decides there's too much anonymous virtual
memory allocated. If the KVM secondary MMU is synchronized with MMU
notifiers or not, doesn't make a difference in that regard.

Secondly it's always more efficient to avoid copying the guest
physical address space in the fork child (so we avoid to mark all the
guest memory readonly in the parent and so we skip the establishment
and teardown of lots of pagetables in the child).

In the common case we can ignore the error if MADV_DONTFORK is not
available. Leave a second invocation that errors out in the KVM path
if MMU notifiers are missing and KVM is enabled, to abort in such
case.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Tested-By: Benoit Canet <benoit@irqsave.net>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
11 years agousb: Fix iovec memleak on combined-packet free
Hans de Goede [Tue, 17 Sep 2013 19:44:52 +0000 (21:44 +0200)]
usb: Fix iovec memleak on combined-packet free

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Also reset max_packet_size on ep_reset
Hans de Goede [Tue, 17 Sep 2013 19:44:53 +0000 (21:44 +0200)]
usb: Also reset max_packet_size on ep_reset

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: Fix memory leak on xhci_disable_ep
Hans de Goede [Tue, 17 Sep 2013 19:44:51 +0000 (21:44 +0200)]
xhci: Fix memory leak on xhci_disable_ep

The USBPacket-s in the transfers need to be cleaned up so that the memory
allocated by the iovec in there gets freed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: Add xhci_epid_to_usbep helper function
Hans de Goede [Tue, 17 Sep 2013 19:44:50 +0000 (21:44 +0200)]
xhci: Add xhci_epid_to_usbep helper function

And use it instead of prying the USBEndpoint out of the packet struct
in various places.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: Init a transfers xhci, slotid and epid member on epctx alloc
Hans de Goede [Tue, 17 Sep 2013 19:44:49 +0000 (21:44 +0200)]
xhci: Init a transfers xhci, slotid and epid member on epctx alloc

Transfers are part of an epctx, which is part of a slot, which is part of
a xhci. Transfers cannot dynamically be moved from one epctx to another,
so once created their xhci, slotid and epid are constant, so lets set these
up at creation time, rather then re-initializing them with the same
value each time a transfer gets submitted.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: Fix number of streams allocated when using streams
Hans de Goede [Mon, 16 Sep 2013 15:04:27 +0000 (17:04 +0200)]
xhci: Fix number of streams allocated when using streams

According to the xhci spec the total number of streams is
2 ^ (MaxPStreams + 1), and this is also how the Linux xhci driver
uses this field.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: remove old usb-host code
Gerd Hoffmann [Tue, 10 Sep 2013 09:02:59 +0000 (11:02 +0200)]
usb: remove old usb-host code

The usb-host code has been rewritten for qemu 1.5 to use libusb,
the old code has been left in as temporary fallback.  Now we are
two releases further out, targeting the 1.7 release.  No major
issues with the new code poped up until now.  Time to remove it
from tre tree.  Should we ever need it again for some reason --
git has a copy for us in the history.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoQMP: qmp-events.txt: alphabetical order fix and other minor changes
Luiz Capitulino [Wed, 11 Sep 2013 17:58:12 +0000 (13:58 -0400)]
QMP: qmp-events.txt: alphabetical order fix and other minor changes

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQMP: Update qmp-spec.txt
Luiz Capitulino [Wed, 11 Sep 2013 17:52:51 +0000 (13:52 -0400)]
QMP: Update qmp-spec.txt

Simplify the text, fix some of the examples.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQMP: Update README file
Luiz Capitulino [Tue, 10 Sep 2013 21:15:49 +0000 (17:15 -0400)]
QMP: Update README file

Drop unneeded info, fix some of the examples and rename QEMU Monitor
Protocol to QEMU Machine Protocol.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQMP: QMP/ -> docs/qmp/
Luiz Capitulino [Tue, 10 Sep 2013 21:00:45 +0000 (17:00 -0400)]
QMP: QMP/ -> docs/qmp/

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQMP: fix qmp-commands.txt generation path
Luiz Capitulino [Tue, 10 Sep 2013 20:56:14 +0000 (16:56 -0400)]
QMP: fix qmp-commands.txt generation path

This file should be generated in the BUILD_DIR, as all other docs.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQMP: add scripts/qmp
Luiz Capitulino [Tue, 10 Sep 2013 20:39:23 +0000 (16:39 -0400)]
QMP: add scripts/qmp

Populate it with all scripts stored in QMP/. Also fixes trailing
whitespaces in qmp-shell and qmp.py.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqxl: compile only once
Gerd Hoffmann [Wed, 11 Sep 2013 11:32:07 +0000 (13:32 +0200)]
qxl: compile only once

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqxl: simplify page dirtying
Gerd Hoffmann [Wed, 11 Sep 2013 11:15:48 +0000 (13:15 +0200)]
qxl: simplify page dirtying

No need to do target page size calculations here,
memory_region_set_dirty will care for us.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqxl: simplify qxl_rom_size
Gerd Hoffmann [Wed, 11 Sep 2013 11:08:49 +0000 (13:08 +0200)]
qxl: simplify qxl_rom_size

Nowdays rom size is fixed at 8192 for live migration compat reasons.
So we can ditch the pointless math trying to calculate the size needed.
Also make the size sanity check fail at compile time not runtime.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqxl: define qxl operating on 4k pages
Gerd Hoffmann [Wed, 11 Sep 2013 11:14:25 +0000 (13:14 +0200)]
qxl: define qxl operating on 4k pages

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoblock/iscsi: Drop iscsi_co_get_block_status for older versions of libiscsi
Stefan Weil [Tue, 17 Sep 2013 17:33:49 +0000 (19:33 +0200)]
block/iscsi: Drop iscsi_co_get_block_status for older versions of libiscsi

Debian wheezy includes libiscsi-dev 1.4.0 which does not provide
SCSI_PROVISIONING_TYPE_DEALLOCATED. Drop iscsi_co_get_block_status
in this case to allow compilation without errors.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoMAINTAINERS: Add myself to MAINTAINERS file
Eduardo Otubo [Mon, 9 Sep 2013 17:04:15 +0000 (14:04 -0300)]
MAINTAINERS: Add myself to MAINTAINERS file

Add myself to the MAINTAINERS file. I'll be looking at qemu-seccomp.c
and include/sysemu/seccomp.h.

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Acked-by: Paul Moore <pmoore@redhat.com>
Message-id: 1378746255-2089-1-git-send-email-otubo@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agohmp: block-stream: fix typo
Anthony Liguori [Tue, 17 Sep 2013 16:10:47 +0000 (11:10 -0500)]
hmp: block-stream: fix typo

Found this by enabling C++ errors.  The bool and enum arguments
are mistakenly flipped.

Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoMerge remote-tracking branch 'kiszka/queues/slirp' into staging
Anthony Liguori [Tue, 17 Sep 2013 15:01:24 +0000 (10:01 -0500)]
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

# By Liu Ping Fan (3) and Jan Kiszka (1)
# Via Jan Kiszka
* kiszka/queues/slirp:
  slirp: clean up slirp_update_timeout
  slirp: set mainloop timeout with more precise value
  slirp: define timeout as macro
  slirp: make timeout local

Message-id: cover.1379415024.git.jan.kiszka@siemens.com

11 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 17 Sep 2013 14:51:40 +0000 (09:51 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

# By Max Reitz (16) and others
# Via Kevin Wolf
* kwolf/for-anthony: (33 commits)
  qemu-iotests: Fix test 038
  block: Assert validity of BdrvActionOps
  qemu-iotests: Cleanup test image in test number 007
  qemu-img: fix invalid JSON
  coroutine: add ./configure --disable-coroutine-pool
  qemu-iotests: Adjustments due to error propagation
  qcow2: Use Error parameter
  qemu-img create: Emit filename on error
  block: Error parameter for create functions
  block: Error parameter for open functions
  bdrv: Use "Error" for creating images
  bdrv: Use "Error" for opening images
  qemu-iotests: add 057 internal snapshot for block device test case
  hmp: add interface hmp_snapshot_delete_blkdev_internal
  hmp: add interface hmp_snapshot_blkdev_internal
  qmp: add interface blockdev-snapshot-delete-internal-sync
  qmp: add interface blockdev-snapshot-internal-sync
  qmp: add internal snapshot support in qmp_transaction
  snapshot: distinguish id and name in snapshot delete
  snapshot: new function bdrv_snapshot_find_by_id_and_name()
  ...

Message-id: 1379073063-14963-1-git-send-email-kwolf@redhat.com

11 years agoMerge remote-tracking branch 'rth/tgt-i386' into staging
Anthony Liguori [Tue, 17 Sep 2013 14:51:23 +0000 (09:51 -0500)]
Merge remote-tracking branch 'rth/tgt-i386' into staging

# By Paolo Bonzini (1) and Peter Maydell (1)
# Via Richard Henderson
* rth/tgt-i386:
  target-i386: Only provide CMOV and friends if feature bit set
  target-i386: fix disassembly with PAE=1, PG=0

Message-id: 1379010496-5875-1-git-send-email-rth@twiddle.net

11 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Tue, 17 Sep 2013 14:50:23 +0000 (09:50 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

# By Peter Lieven (3) and others
# Via Paolo Bonzini
* bonzini/scsi-next:
  spapr-vscsi: Report error on unsupported MAD requests
  spapr-vscsi: Adding VSCSI capabilities
  iscsi: split discard requests in multiple parts
  iscsi: add .bdrv_get_block_status
  iscsi: add logical block provisioning information to iscsilun
  hw/scsi/lsi53c895a: Use deposit32 rather than handcoded shift/mask
  hw/scsi/lsi53c895a: Use sextract32 for sign-extension
  scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
  virtio-scsi: Make type virtio-scsi-common abstract
  spapr-vscsi: add task management
  scsi: prefer UUID to VM name for the initiator name

Message-id: 1378984634-765-1-git-send-email-pbonzini@redhat.com

11 years agoMerge remote-tracking branch 'kraxel/chardev.7' into staging
Anthony Liguori [Tue, 17 Sep 2013 14:49:43 +0000 (09:49 -0500)]
Merge remote-tracking branch 'kraxel/chardev.7' into staging

# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/chardev.7:
  chardev: fix pty_chr_timer

Message-id: 1378972894-11185-1-git-send-email-kraxel@redhat.com

11 years agoslirp: clean up slirp_update_timeout
Jan Kiszka [Wed, 28 Aug 2013 17:12:15 +0000 (19:12 +0200)]
slirp: clean up slirp_update_timeout

No need to write out the timeout early, keep it local until we are done.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 years agoslirp: set mainloop timeout with more precise value
Liu Ping Fan [Sun, 25 Aug 2013 02:01:21 +0000 (10:01 +0800)]
slirp: set mainloop timeout with more precise value

If slirp needs to emulate tcp timeout, then the timeout value
for mainloop should be more precise, which is determined by
slirp's fasttimo or slowtimo. Achieve this by swap the logic
sequence of slirp_pollfds_fill and slirp_update_timeout.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 years agoslirp: define timeout as macro
Liu Ping Fan [Sun, 25 Aug 2013 02:01:20 +0000 (10:01 +0800)]
slirp: define timeout as macro

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 years agoslirp: make timeout local
Liu Ping Fan [Sun, 25 Aug 2013 02:01:19 +0000 (10:01 +0800)]
slirp: make timeout local

Each slirp has its own time to caculate timeout.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 years agolsi: add 53C810 variant
Hervé Poussineau [Sat, 14 Sep 2013 15:51:09 +0000 (17:51 +0200)]
lsi: add 53C810 variant

Currently, treat it exactly as a 53C895A.
53C895A is a 53C810 with more capabilities, so this should work.

However, this lets us test different code paths on Linux, which
don't use lastest features if it detect a 810, or on some OSes
which only support 810 and not 895A (like very old Windows NT
versions).

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolsi: remove todo
Hervé Poussineau [Sat, 14 Sep 2013 15:51:08 +0000 (17:51 +0200)]
lsi: remove todo

LSI emulation has been tested with Linux on PPC platform.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolsi: ignore write accesses to CTEST0 registers
Hervé Poussineau [Sat, 14 Sep 2013 15:51:07 +0000 (17:51 +0200)]
lsi: ignore write accesses to CTEST0 registers

53C895A datasheet says that this register is read/write, and that the value
returned on read access is dependant of DMA FIFO state. However, nothing is
said for written value.

53C810A datasheet gives more insight about this register:
"This was a general purpose read/write register in previous SYM53C8XX
family chips. Although it is still a read/write register, Symbios reserves
the right to use these bits for future 53C8XX family enhancements."

This prevents going to the default case, which prints an error message.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolsi: check ssid versus sdid only if ssid is valid
Hervé Poussineau [Sat, 14 Sep 2013 15:51:06 +0000 (17:51 +0200)]
lsi: check ssid versus sdid only if ssid is valid

This prevents some (invalid) error messages on console.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agolsi: use constant name instead of its value
Hervé Poussineau [Sat, 14 Sep 2013 15:51:05 +0000 (17:51 +0200)]
lsi: use constant name instead of its value

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoqemu-iotests: Fix test 038
Max Reitz [Fri, 13 Sep 2013 08:37:12 +0000 (10:37 +0200)]
qemu-iotests: Fix test 038

Test 038 uses asynchronous I/O, resulting (potentially) in a different
output for every run (regarding the order of the I/O accesses). This can
be fixed by simply sorting the I/O access messages, since their order is
irrelevant anyway (for this asynchonous I/O).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agotarget-i386: Only provide CMOV and friends if feature bit set
Peter Maydell [Mon, 15 Jul 2013 17:21:40 +0000 (18:21 +0100)]
target-i386: Only provide CMOV and friends if feature bit set

The instructions CMOVcc, FCMOVcc and F[U]COMI[P] should only be
present if the CMOV feature bit is set. Add missing feature bit
checks so we correctly fault if emulating a 486 or 586.
This fixes bug LP:1201446.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
11 years agotarget-i386: fix disassembly with PAE=1, PG=0
Paolo Bonzini [Fri, 30 Aug 2013 09:58:45 +0000 (11:58 +0200)]
target-i386: fix disassembly with PAE=1, PG=0

CR4.PAE=1 will not enable paging if CR0.PG=0, but the "if" chain
in x86_cpu_get_phys_page_debug says otherwise.  Check CR0.PG
before everything else.

Fixes "-d in_asm" for a code section at the beginning of OVMF.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
11 years agopc_sysfw: Fix ISA BIOS init for ridiculously big flash
Markus Armbruster [Wed, 31 Jul 2013 13:11:12 +0000 (15:11 +0200)]
pc_sysfw: Fix ISA BIOS init for ridiculously big flash

pc_isa_bios_init() suffers integer overflow for flash larger than
INT_MAX.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1375276272-15988-9-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Don't abort when we can't allocate guest memory
Markus Armbruster [Wed, 31 Jul 2013 13:11:11 +0000 (15:11 +0200)]
exec: Don't abort when we can't allocate guest memory

We abort() on memory allocation failure.  abort() is appropriate for
programming errors.  Maybe most memory allocation failures are
programming errors, maybe not.  But guest memory allocation failure
isn't, and aborting when the user asks for more memory than we can
provide is not nice.  exit(1) instead, and do it in just one place, so
the error message is consistent.

Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1375276272-15988-8-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Clean up unnecessary S390 ifdeffery
Markus Armbruster [Wed, 31 Jul 2013 13:11:10 +0000 (15:11 +0200)]
exec: Clean up unnecessary S390 ifdeffery

Another issue missed in commit fdec991 is -mem-path: it needs to be
rejected only for old S390 KVM, not for any S390.  Not that I
personally care, but the ifdeffery in qemu_ram_alloc_from_ptr() annoys
me.

Note that this doesn't actually make -mem-path work, as the kernel
doesn't (yet?)  support large pages in the host for KVM guests.  Clean
it up anyway.

Thanks to Christian Borntraeger for pointing out the S390 kernel
limitations.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1375276272-15988-7-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Drop incorrect & dead S390 code in qemu_ram_remap()
Markus Armbruster [Wed, 31 Jul 2013 13:11:09 +0000 (15:11 +0200)]
exec: Drop incorrect & dead S390 code in qemu_ram_remap()

Old S390 KVM wants guest RAM mapped in a peculiar way.  Commit 6b02494
implemented that.

When qemu_ram_remap() got added in commit cd19cfa, its code carefully
mimicked the allocation code: peculiar way if defined(TARGET_S390X) &&
defined(CONFIG_KVM), else normal way.

For new S390 KVM, we actually want the normal way.  Commit fdec991
changed qemu_ram_alloc_from_ptr() accordingly, but forgot to update
qemu_ram_remap().  If qemu_ram_alloc_from_ptr() maps RAM the normal
way, but qemu_ram_remap() remaps it the peculiar way, remapping
changes protection and flags, which it shouldn't.

Fortunately, this can't happen, as we never remap on S390.

Replace the incorrect code with an assertion.

Thanks to Christian Borntraeger for help with assessing the bug's
(non-)impact.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Message-id: 1375276272-15988-6-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Simplify the guest physical memory allocation hook
Markus Armbruster [Wed, 31 Jul 2013 13:11:08 +0000 (15:11 +0200)]
exec: Simplify the guest physical memory allocation hook

Make it a generic hook rather than a KVM hook.  Less code and
ifdeffery.

Since the only user of the hook is old S390 KVM, there's hope we can
get rid of it some day.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Message-id: 1375276272-15988-5-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Reduce ifdeffery around -mem-path
Markus Armbruster [Wed, 31 Jul 2013 13:11:07 +0000 (15:11 +0200)]
exec: Reduce ifdeffery around -mem-path

Instead of spreading its ifdeffery everywhere, confine it to
qemu_ram_alloc_from_ptr().  Everywhere else, simply test block->fd,
which is non-negative exactly when block uses -mem-path.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Message-id: 1375276272-15988-4-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Clean up fall back when -mem-path allocation fails
Markus Armbruster [Wed, 31 Jul 2013 13:11:06 +0000 (15:11 +0200)]
exec: Clean up fall back when -mem-path allocation fails

With -mem-path, qemu_ram_alloc_from_ptr() first tries to allocate
accordingly, but when it fails, it falls back to normal allocation.

The fall back allocation code used to be effectively identical to the
"-mem-path not given" code, until it started to diverge in commit
432d268.  I believe the code still works, but clean it up anyway: drop
the special fall back allocation code, and fall back to the ordinary
"-mem-path not given" code instead.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Message-id: 1375276272-15988-3-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoexec: Fix Xen RAM allocation with unusual options
Markus Armbruster [Wed, 31 Jul 2013 13:11:05 +0000 (15:11 +0200)]
exec: Fix Xen RAM allocation with unusual options

Issues:

* We try to obey -mem-path even though it can't work with Xen.

* To implement -machine mem-merge, we call
  memory_try_enable_merging(new_block->host, size).  But with Xen,
  new_block->host remains null.  Oops.

Fix by separating Xen allocation from normal allocation.

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1375276272-15988-2-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
11 years agoblock: Assert validity of BdrvActionOps
Max Reitz [Thu, 12 Sep 2013 12:57:27 +0000 (14:57 +0200)]
block: Assert validity of BdrvActionOps

In qmp_transaction, assert that the BdrvActionOps to be used is actually
valid.

This assertion failing is very improbable, however, it might happen, if
a new TransactionActionKind is introduced "out of order" and the
actions[] array is not updated.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: Cleanup test image in test number 007
Bharata B Rao [Thu, 12 Sep 2013 08:37:59 +0000 (14:07 +0530)]
qemu-iotests: Cleanup test image in test number 007

qemu-iotests number 007 doesn't do test image cleanup. This will affect
those protocols that expect a clean state before every test. Hence
ensure that test image is cleaned up in this test.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-img: fix invalid JSON
Paolo Bonzini [Wed, 11 Sep 2013 16:47:52 +0000 (18:47 +0200)]
qemu-img: fix invalid JSON

Single quotes for JSON are a QMP-ism, use real JSON in
qemu-img output.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agospapr-vscsi: Report error on unsupported MAD requests
Alexey Kardashevskiy [Thu, 29 Aug 2013 08:13:25 +0000 (18:13 +1000)]
spapr-vscsi: Report error on unsupported MAD requests

The existing driver just dropped unsupported requests. This adds error
responses to those unhandled requests.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agospapr-vscsi: Adding VSCSI capabilities
Nikunj A. Dadhania [Mon, 2 Sep 2013 05:03:38 +0000 (10:33 +0530)]
spapr-vscsi: Adding VSCSI capabilities

This implements capabilities exchange between vscsi host and client.  As
at the moment no capability is supported, put zero flags everywhere and
return.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
11 years agoiscsi: split discard requests in multiple parts
Peter Lieven [Fri, 19 Jul 2013 07:19:41 +0000 (09:19 +0200)]
iscsi: split discard requests in multiple parts

Replace .bdrv_aio_discard with .bdrv_co_discard so that discard
requests can be split in multiple parts, each for a small amount
of sectors.

This is useful because we expose a generic API with no limit
on the amount of sectors that can be unmapped in one request.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agocoroutine: add ./configure --disable-coroutine-pool
Stefan Hajnoczi [Wed, 11 Sep 2013 14:42:35 +0000 (16:42 +0200)]
coroutine: add ./configure --disable-coroutine-pool

The 'gthread' coroutine backend was written before the freelist (aka
pool) existed in qemu-coroutine.c.

This means that every thread is expected to exit when its coroutine
terminates.  It is not possible to reuse threads from a pool.

This patch automatically disables the pool when 'gthread' is used.  This
allows the 'gthread' backend to work again (for example,
tests/test-coroutine completes successfully instead of hanging).

I considered implementing thread reuse but I don't want quirks like CPU
affinity differences due to coroutine threads being recycled.  The
'gthread' backend is a reference backend and it's therefore okay to skip
the pool optimization.

Note this patch also makes it easy to toggle the pool for benchmarking
purposes:

  ./configure --with-coroutine-backend=ucontext \
              --disable-coroutine-pool

Reported-by: Gabriel Kerneis <gabriel@kerneis.info>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Gabriel Kerneis <gabriel@kerneis.info>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: Adjustments due to error propagation
Max Reitz [Tue, 10 Sep 2013 11:59:43 +0000 (13:59 +0200)]
qemu-iotests: Adjustments due to error propagation

When opening/creating images, propagating errors instead of immediately
emitting them on occurrence results in errors generally being printed on
a single line rather than being split up into multiple ones. This in
turn requires adjustments to some test results.

Also, test 060 used a sed to filter out the test image directory and
format by removing everything from the affected line after a certain
keyword; this now also removes the error message itself, which can be
fixed by using _filter_testdir and _filter_imgfmt.

Finally, _make_test_img in common.rc did not filter out the test image
directory etc. from stderr. This has been fixed through a redirection of
stderr to stdout (which is already done in _check_test_img and
_img_info).

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agoqcow2: Use Error parameter
Max Reitz [Thu, 5 Sep 2013 07:40:43 +0000 (09:40 +0200)]
qcow2: Use Error parameter

Employ usage of the new Error ** parameter in qcow2_open, qcow2_create
and associated functions.

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agoqemu-img create: Emit filename on error
Max Reitz [Fri, 6 Sep 2013 14:51:03 +0000 (16:51 +0200)]
qemu-img create: Emit filename on error

bdrv_img_create generally does not emit the target filename, although
this is pretty important information. Therefore, prepend its error
message with the output filename (if an error occurs).

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agoblock: Error parameter for create functions
Max Reitz [Fri, 6 Sep 2013 15:14:26 +0000 (17:14 +0200)]
block: Error parameter for create functions

Add an Error ** parameter to bdrv_create and its associated functions to
allow more specific error messages.

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agoblock: Error parameter for open functions
Max Reitz [Thu, 5 Sep 2013 12:45:29 +0000 (14:45 +0200)]
block: Error parameter for open functions

Add an Error ** parameter to bdrv_open, bdrv_file_open and associated
functions to allow more specific error messages.

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agobdrv: Use "Error" for creating images
Max Reitz [Thu, 5 Sep 2013 12:26:05 +0000 (14:26 +0200)]
bdrv: Use "Error" for creating images

Add an Error ** parameter to BlockDriver.bdrv_create to allow more
specific error messages.

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agobdrv: Use "Error" for opening images
Max Reitz [Thu, 5 Sep 2013 12:22:29 +0000 (14:22 +0200)]
bdrv: Use "Error" for opening images

Add an Error ** parameter to BlockDriver.bdrv_open and
BlockDriver.bdrv_file_open to allow more specific error messages.

Signed-off-by: Max Reitz <mreitz@redhat.com>
11 years agoqemu-iotests: add 057 internal snapshot for block device test case
Wenchao Xia [Wed, 11 Sep 2013 06:04:39 +0000 (14:04 +0800)]
qemu-iotests: add 057 internal snapshot for block device test case

Create in transaction and deletion in single command will be tested.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agohmp: add interface hmp_snapshot_delete_blkdev_internal
Wenchao Xia [Wed, 11 Sep 2013 06:04:38 +0000 (14:04 +0800)]
hmp: add interface hmp_snapshot_delete_blkdev_internal

It is hard to make both id and name optional in hmp console as qmp
interface, so this interface require user to specify name.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agohmp: add interface hmp_snapshot_blkdev_internal
Wenchao Xia [Wed, 11 Sep 2013 06:04:37 +0000 (14:04 +0800)]
hmp: add interface hmp_snapshot_blkdev_internal

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqmp: add interface blockdev-snapshot-delete-internal-sync
Wenchao Xia [Wed, 11 Sep 2013 06:04:36 +0000 (14:04 +0800)]
qmp: add interface blockdev-snapshot-delete-internal-sync

This interface use id and name as optional parameters, to handle the
case that one image contain multiple snapshots with same name which
may be '', but with different id.

Adding parameter id is for historical compatiability reason, and
that case is not possible in qemu's new interface for internal
snapshot at block device level, but still possible in qemu-img.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqmp: add interface blockdev-snapshot-internal-sync
Wenchao Xia [Wed, 11 Sep 2013 06:04:35 +0000 (14:04 +0800)]
qmp: add interface blockdev-snapshot-internal-sync

Snapshot ID can't be specified in this interface.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqmp: add internal snapshot support in qmp_transaction
Wenchao Xia [Wed, 11 Sep 2013 06:04:34 +0000 (14:04 +0800)]
qmp: add internal snapshot support in qmp_transaction

Unlike savevm, the qmp_transaction interface will not generate
snapshot name automatically, saving trouble to return information
of the new created snapshot.

Although qcow2 support storing multiple snapshots with same name
but different ID, here it will fail when an snapshot with that name
already exist before the operation. Format such as rbd do not support
ID at all, and in most case, it means trouble to user when he faces
multiple snapshots with same name, so ban that case. Request with
empty name will be rejected.

Snapshot ID can't be specified in this interface.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agosnapshot: distinguish id and name in snapshot delete
Wenchao Xia [Wed, 11 Sep 2013 06:04:33 +0000 (14:04 +0800)]
snapshot: distinguish id and name in snapshot delete

Snapshot creation actually already distinguish id and name since it take
a structured parameter *sn, but delete can't. Later an accurate delete
is needed in qmp_transaction abort and blockdev-snapshot-delete-sync,
so change its prototype. Also *errp is added to tip error, but return
value is kepted to let caller check what kind of error happens. Existing
caller for it are savevm, delvm and qemu-img, they are not impacted by
introducing a new function bdrv_snapshot_delete_by_id_or_name(), which
check the return value and do the operation again.

Before this patch:
  For qcow2, it search id first then name to find the one to delete.
  For rbd, it search name.
  For sheepdog, it does nothing.

After this patch:
  For qcow2, logic is the same by call it twice in caller.
  For rbd, it always fails in delete with id, but still search for name
in second try, no change to user.

Some code for *errp is based on Pavel's patch.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agosnapshot: new function bdrv_snapshot_find_by_id_and_name()
Wenchao Xia [Wed, 11 Sep 2013 06:04:32 +0000 (14:04 +0800)]
snapshot: new function bdrv_snapshot_find_by_id_and_name()

To make it clear about id and name in searching, add this API
to distinguish them. Caller can choose to search by id or name,
*errp will be set only for exception.

Some code are modified based on Pavel's patch.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: New test case in 061
Max Reitz [Thu, 5 Sep 2013 08:55:54 +0000 (10:55 +0200)]
qemu-iotests: New test case in 061

Add one test case for zero cluster expansion on qcow2 version downgrade
in shared L2 tables (i.e., L2 tables with a refcount > 1) and one for
zero expansion on backed clusters in shared L2 tables.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add tests for runtime fd passing via SCM rights
Wenchao Xia [Fri, 6 Sep 2013 03:24:34 +0000 (11:24 +0800)]
qemu-iotests: add tests for runtime fd passing via SCM rights

This case will test whether the monitor can receive fd at runtime.
To verify better, additional monitor is created to see if qemu
can handler two monitor instances correctly.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add infrastructure of fd passing via SCM
Wenchao Xia [Fri, 6 Sep 2013 03:24:33 +0000 (11:24 +0800)]
qemu-iotests: add infrastructure of fd passing via SCM

This patch make use of the compiled scm helper program to transfer
fd via unix socket at runtime.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add unix socket help program
Wenchao Xia [Fri, 6 Sep 2013 03:24:32 +0000 (11:24 +0800)]
qemu-iotests: add unix socket help program

This program can do a sendmsg call to transfer fd with unix
socket, which is not supported in python2.

The built binary will not be deleted in clean, but it is a
existing issue in ./tests, which should be solved in another
patch.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotest: qcow2 image option amendment
Max Reitz [Tue, 3 Sep 2013 08:09:55 +0000 (10:09 +0200)]
qemu-iotest: qcow2 image option amendment

Add tests for qemu-img amend on qcow2 image files.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: Implement bdrv_amend_options
Max Reitz [Tue, 3 Sep 2013 08:09:54 +0000 (10:09 +0200)]
qcow2: Implement bdrv_amend_options

Implement bdrv_amend_options for compat, size, backing_file, backing_fmt
and lazy_refcounts.

Downgrading images from compat=1.1 to compat=0.10 is achieved through
handling all incompatible flags accordingly, clearing all compatible and
autoclear flags and expanding all zero clusters.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: Save refcount order in BDRVQcowState
Max Reitz [Tue, 3 Sep 2013 08:09:53 +0000 (10:09 +0200)]
qcow2: Save refcount order in BDRVQcowState

Save the image refcount order in BDRVQcowState. This will be relevant
for future code supporting different refcount orders than four and also
for code that needs to verify a certain refcount order for an opened
image.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2-cluster: Expand zero clusters
Max Reitz [Tue, 3 Sep 2013 08:09:52 +0000 (10:09 +0200)]
qcow2-cluster: Expand zero clusters

Add functionality for expanding zero clusters. This is necessary for
downgrading the image version to one without zero cluster support.

For non-backed images, this function may also just discard zero clusters
instead of truly expanding them.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2-cache: Empty cache
Max Reitz [Tue, 3 Sep 2013 08:09:51 +0000 (10:09 +0200)]
qcow2-cache: Empty cache

Add a function for emptying a cache, i.e., flushing it and marking all
elements invalid.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: Image file option amendment
Max Reitz [Tue, 3 Sep 2013 08:09:50 +0000 (10:09 +0200)]
block: Image file option amendment

This patch adds the "amend" option to qemu-img which allows changing
image options on existing image files. It also adds the generic bdrv
implementation which is basically just a wrapper for the image format
specific function.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoraw-win32.c: Fix incorrect handling behaviour of small block files
Tal Kain [Mon, 9 Sep 2013 09:14:55 +0000 (11:14 +0200)]
raw-win32.c: Fix incorrect handling behaviour of small block files

It is a valid case that the read data's size is smaller than the
requested size since there could be files that are smaller than
the minimum block size (For ex. when a VMDK disk descriptor file)

Signed-off-by: Tal Kain <tal.kain@ravellosystems.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: Discard VM state in active L1 after creating snapshot
Kevin Wolf [Fri, 6 Sep 2013 10:20:08 +0000 (12:20 +0200)]
qcow2: Discard VM state in active L1 after creating snapshot

During savevm, the VM state is written to the active L1 of the image and
then a snapshot is taken. After that, the VM state isn't needed any more
in the active L1 and should be discarded. This is implemented by this
patch.

The impact of not discarding the VM state is that a snapshot can never
become smaller than any previous snapshot (because it would be padded
with old VM state), and more importantly that future savevm operations
cause unnecessary COWs (with associated flushes), which makes subsequent
snapshots much slower.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
11 years agoqcow2: Pass discard type to qcow2_discard_clusters()
Kevin Wolf [Fri, 6 Sep 2013 10:18:47 +0000 (12:18 +0200)]
qcow2: Pass discard type to qcow2_discard_clusters()

The function will be used internally instead of only being called for
guest discard requests.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
11 years agochardev: fix pty_chr_timer
Gerd Hoffmann [Thu, 22 Aug 2013 09:43:58 +0000 (11:43 +0200)]
chardev: fix pty_chr_timer

pty_chr_timer first calls pty_chr_update_read_handler(), then clears
timer_tag (because it is a one-shot timer).   This is the wrong order
though.  pty_chr_update_read_handler might re-arm time timer, and the
new timer_tag gets overwitten in that case.

This leads to crashes when unplugging a pty chardev:  pty_chr_close
thinks no timer is running -> timer isn't canceled -> pty_chr_timer gets
called with stale CharDevState -> BOOM.

This patch fixes the ordering.
Kill the pointless goto while being at it.

https://bugzilla.redhat.com/show_bug.cgi?id=994414

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoiscsi: add .bdrv_get_block_status
Peter Lieven [Fri, 19 Jul 2013 07:19:40 +0000 (09:19 +0200)]
iscsi: add .bdrv_get_block_status

this patch adds a coroutine for .bdrv_co_block_status as well as
a generic framework that can be used to build coroutines in block/iscsi.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>