OSDN Git Service

qmiga/qemu.git
8 years agospapr_pci: Allow PCI host bridge DMA window to be configured
David Gibson [Wed, 23 Sep 2015 23:56:44 +0000 (09:56 +1000)]
spapr_pci: Allow PCI host bridge DMA window to be configured

At present the PCI host bridge (PHB) for the pseries machine type has a
fixed DMA window from 0..1GB (in PCI address space) which is mapped to real
memory via the PAPR paravirtualized IOMMU.

For better support of VFIO devices, we're going to want to allow for
different configurations of the DMA window.

Eventually we'll want to allow the guest itself to reconfigure the window
via the PAPR dynamic DMA window interface, but as a preliminary this patch
allows the user to reconfigure the window with new properties on the PHB
device.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
8 years agospapr: Add "slb-size" property to CPU device tree nodes
Thomas Huth [Thu, 1 Oct 2015 13:30:07 +0000 (15:30 +0200)]
spapr: Add "slb-size" property to CPU device tree nodes

According to a commit message in the Linux kernel (see here
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=b60c31d85a2a
for example), the name of the property that carries the information
about the number of SLB entries should be called "slb-size", and
not "ibm,slb-size". The Linux kernel can deal with both names, but
to be on the safe side we should support the official name, too.

[Now that LoPAPR is public, the relevant requirement can be found in
section C.6.1.8 --dwg]

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agospapr: Abort when HTAB of requested size isn't allocated
Bharata B Rao [Thu, 24 Sep 2015 08:22:48 +0000 (13:52 +0530)]
spapr: Abort when HTAB of requested size isn't allocated

Terminate the guest when HTAB of requested size isn't allocated by
the host.

When memory hotplug is attempted on a guest that has booted with
less than requested HTAB size, the guest kernel will not be able
to gracefully fail the hotplug request. This patch will ensure that
we never end up in a situation where memory hotplug fails due to
less than requested HTAB size.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agospapr: Allocate HTAB from machine init
Bharata B Rao [Thu, 24 Sep 2015 08:22:47 +0000 (13:52 +0530)]
spapr: Allocate HTAB from machine init

Allocate HTAB from ppc_spapr_init() so that we can abort the guest
if requested HTAB size is't allocated by the host. However retain the
htab reset call in spapr_reset_htab() so that HTAB gets reset (and
not allocated) during machine reset.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging
Peter Maydell [Thu, 22 Oct 2015 17:01:53 +0000 (18:01 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging

Collected tcg backend patches

# gpg: Signature made Wed 21 Oct 2015 22:34:28 BST using RSA key ID 4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"

* remotes/rth/tags/pull-tcg-20151021:
  cpu-exec: Add "nochain" debug flag
  tcg/mips: Support r6 SEL{NE, EQ}Z instead of MOVN/MOVZ
  tcg/mips: Support r6 multiply/divide encodings
  tcg/mips: Support r6 JR encoding
  tcg/mips: Add use_mips32r6_instructions definition
  disas/mips: Add R6 jr/jr.hb to disassembler
  tcg-opc.h: Simplify insn_start def
  tcg/ppc: Prefer mask over andi.
  tcg/ppc: Revise goto_tb implementation
  tcg/ppc: Adjust exit_tb for change in prologue placement

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/afaerber/tags/qom-cpu-for-peter' into staging
Peter Maydell [Thu, 22 Oct 2015 16:33:54 +0000 (17:33 +0100)]
Merge remote-tracking branch 'remotes/afaerber/tags/qom-cpu-for-peter' into staging

QOM CPUState and X86CPU

* Adoption of CPUClass::disas_set_info() hook

# gpg: Signature made Thu 22 Oct 2015 17:11:24 BST using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/qom-cpu-for-peter:
  disas: QOMify alpha specific disas setup
  disas: QOMify mips specific disas setup
  disas: QOMify sh4 specific disas setup
  disas: QOMify lm32 specific disas setup
  disas: QOMify sparc specific disas setup
  disas: QOMify m68k specific disas setup
  disas: QOMify moxie specific disas setup
  disas: QOMify s390x specific disas setup

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agodisas: QOMify alpha specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:05 +0000 (19:00 -0700)]
disas: QOMify alpha specific disas setup

Move the target_disas() alpha specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

This also makes monitor_disas() consistent with target_disas(), as
monitor_disas() was missing a set of the BFD (This was an omission from
commit b9bec751c8c8b08d8055da32306eb105db03031b).

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify mips specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:04 +0000 (19:00 -0700)]
disas: QOMify mips specific disas setup

Move the target_disas() mips specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify sh4 specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:03 +0000 (19:00 -0700)]
disas: QOMify sh4 specific disas setup

Move the target_disas() sh4 specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify lm32 specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:02 +0000 (19:00 -0700)]
disas: QOMify lm32 specific disas setup

Move the target_disas() lm32 specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Michael Walle <michael@walle.cc>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify sparc specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:01 +0000 (19:00 -0700)]
disas: QOMify sparc specific disas setup

Move the target_disas() sparc specifics to the QOM disas_set_info hook
and delete the #ifdef specific code in disas.c.

Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify m68k specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 02:00:00 +0000 (19:00 -0700)]
disas: QOMify m68k specific disas setup

Move the target_disas() m68k specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify moxie specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 01:59:59 +0000 (18:59 -0700)]
disas: QOMify moxie specific disas setup

Move the target_disas() moxie specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Cc: Anthony Green <green@moxielogic.com>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agodisas: QOMify s390x specific disas setup
Peter Crosthwaite [Sun, 12 Jul 2015 01:59:58 +0000 (18:59 -0700)]
disas: QOMify s390x specific disas setup

Move the target_disas() s390 specifics to the CPUClass::disas_set_info()
hook and delete the #ifdef specific code in disas.c.

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Thu, 22 Oct 2015 11:41:44 +0000 (12:41 +0100)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

vhost, pc, virtio features, fixes, cleanups

New features:
    VT-d support for devices behind a bridge
    vhost-user migration support

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Thu 22 Oct 2015 12:39:19 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream: (37 commits)
  hw/isa/lpc_ich9: inject the SMI on the VCPU that is writing to APM_CNT
  i386: keep cpu_model field in MachineState uptodate
  vhost: set the correct queue index in case of migration with multiqueue
  piix: fix resource leak reported by Coverity
  seccomp: add memfd_create to whitelist
  vhost-user-test: check ownership during migration
  vhost-user-test: add live-migration test
  vhost-user-test: learn to tweak various qemu arguments
  vhost-user-test: wrap server in TestServer struct
  vhost-user-test: remove useless static check
  vhost-user-test: move wait_for_fds() out
  vhost: add migration block if memfd failed
  vhost-user: use an enum helper for features mask
  vhost user: add rarp sending after live migration for legacy guest
  vhost user: add support of live migration
  net: add trace_vhost_user_event
  vhost-user: document migration log
  vhost: use a function for each call
  vhost-user: add a migration blocker
  vhost-user: send log shm fd along with log_base
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agohw/isa/lpc_ich9: inject the SMI on the VCPU that is writing to APM_CNT
Laszlo Ersek [Tue, 20 Oct 2015 18:14:00 +0000 (20:14 +0200)]
hw/isa/lpc_ich9: inject the SMI on the VCPU that is writing to APM_CNT

Commit 4d00636e97b7 ("ich9: Add the lpc chip", Nov 14 2012) added the
ich9_apm_ctrl_changed() ioport write callback function such that it would
inject the SMI, in response to a write to the APM_CNT register, on the
first CPU, invariably.

Since this register is used by guest code to trigger an SMI synchronously,
the interrupt should be injected on the VCPU that is performing the write.

apm_ioport_writeb() is the .write callback of the "apm_ops"
MemoryRegionOps [hw/isa/apm.c]; it is parametrized to call
ich9_apm_ctrl_changed() by ich9_lpc_init() [hw/isa/lpc_ich9.c], via
apm_init(). Therefore this change affects no other board.

ich9_generate_smi() is an unrelated function that is called by the TCO
watchdog; a watchdog is likely in its right to (asynchronously) inject
interrupts on the first CPU only.

This patch allows the combined edk2/OVMF SMM driver stack to work with
multiple VCPUs on TCG, using both qemu-system-i386 and qemu-system-x86_64.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoi386: keep cpu_model field in MachineState uptodate
Zhu Guihua [Thu, 15 Oct 2015 03:12:12 +0000 (11:12 +0800)]
i386: keep cpu_model field in MachineState uptodate

Update cpu_model in MachineState for i386, so that the field can be used
for cpu hotplug, instead of using a static variable.

This patch is rebased on the latest master.

Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
8 years agovhost: set the correct queue index in case of migration with multiqueue
Thibaut Collet [Mon, 19 Oct 2015 12:59:27 +0000 (14:59 +0200)]
vhost: set the correct queue index in case of migration with multiqueue

When a live migration is started the log address to mark dirty pages is provided
to the vhost backend through the vhost_dev_set_log function.
This function is called for each queue pairs but the queue index is wrongly set:
always set to the first queue pair. Then vhost backend lost descriptor addresses
of the queue pairs greater than 1 and behaviour of the vhost backend is
unpredictable.

The queue index is computed by taking account of the vq_index (to retrieve the
queue pair index) and calling the vhost_get_vq_index method of the backend.

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Cc: qemu-stable@nongnu.org
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopiix: fix resource leak reported by Coverity
zhanghailiang [Mon, 14 Sep 2015 10:40:10 +0000 (18:40 +0800)]
piix: fix resource leak reported by Coverity

config_fd should be closed before return, or there will
be a resource leak error.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoseccomp: add memfd_create to whitelist
Eduardo Otubo [Fri, 9 Oct 2015 15:17:41 +0000 (17:17 +0200)]
seccomp: add memfd_create to whitelist

This is used by memfd code.

Signed-off-by: Eduardo Otubo <eduardo.otubo@profitbricks.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: check ownership during migration
Marc-André Lureau [Fri, 9 Oct 2015 15:17:40 +0000 (17:17 +0200)]
vhost-user-test: check ownership during migration

Check that backend source and destination do not have simultaneous
ownership during migration.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: add live-migration test
Marc-André Lureau [Fri, 9 Oct 2015 15:17:39 +0000 (17:17 +0200)]
vhost-user-test: add live-migration test

This test checks that the log fd is given to the migration source, and
mark dirty pages during migration.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: learn to tweak various qemu arguments
Marc-André Lureau [Fri, 9 Oct 2015 15:17:38 +0000 (17:17 +0200)]
vhost-user-test: learn to tweak various qemu arguments

Add a new macro to make the qemu command line with other
values of memory size, and specific chardev id.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: wrap server in TestServer struct
Marc-André Lureau [Fri, 9 Oct 2015 15:17:37 +0000 (17:17 +0200)]
vhost-user-test: wrap server in TestServer struct

In the coming patches, a test will use several servers
simultaneously. Wrap the server in a struct, out of the global scope.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: remove useless static check
Marc-André Lureau [Fri, 9 Oct 2015 15:17:36 +0000 (17:17 +0200)]
vhost-user-test: remove useless static check

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user-test: move wait_for_fds() out
Marc-André Lureau [Fri, 9 Oct 2015 15:17:35 +0000 (17:17 +0200)]
vhost-user-test: move wait_for_fds() out

This function is a precondition for most vhost-user tests.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost: add migration block if memfd failed
Marc-André Lureau [Fri, 9 Oct 2015 15:17:34 +0000 (17:17 +0200)]
vhost: add migration block if memfd failed

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user: use an enum helper for features mask
Thibaut Collet [Fri, 9 Oct 2015 15:17:33 +0000 (17:17 +0200)]
vhost-user: use an enum helper for features mask

The VHOST_USER_PROTOCOL_FEATURE_MASK will be automatically updated when
adding new features to the enum.

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
[Adapted from mailing list discussion - Marc-André]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost user: add rarp sending after live migration for legacy guest
Thibaut Collet [Fri, 9 Oct 2015 15:17:32 +0000 (17:17 +0200)]
vhost user: add rarp sending after live migration for legacy guest

A new vhost user message is added to allow QEMU to ask to vhost user backend to
broadcast a fake RARP after live migration for guest without GUEST_ANNOUNCE
capability.

This new message is sent only if the backend supports the new
VHOST_USER_PROTOCOL_F_RARP protocol feature.
The payload of this new message is the MAC address of the guest (not known by
the backend). The MAC address is copied in the first 6 bytes of a u64 to avoid
to create a new payload message type.

This new message has no equivalent ioctl so a new callback is added in the
userOps structure to send the request.

Upon reception of this new message the vhost user backend must generate and
broadcast a fake RARP request to notify the migration is terminated.

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
[Rebased and fixed checkpatch errors - Marc-André]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost user: add support of live migration
Thibaut Collet [Fri, 9 Oct 2015 15:17:31 +0000 (17:17 +0200)]
vhost user: add support of live migration

Some vhost user backends are able to support live migration.
To provide this service the following features must be added:
1. Add the VIRTIO_NET_F_GUEST_ANNOUNCE capability to vhost-net when netdev
   backend is vhost-user.
2. Provide a nop receive callback to vhost-user.
   This callback is called by:
    *  qemu_announce_self after a migration to send fake RARP to avoid network
       outage for peers talking to the migrated guest.
         - For guest with GUEST_ANNOUNCE capabilities, guest already sends GARP
           when the bit VIRTIO_NET_S_ANNOUNCE is set.
           => These packets must be discarded.
         - For guest without GUEST_ANNOUNCE capabilities, migration termination
           is notified when the guest sends packets.
           => These packets can be discarded.
    * virtio_net_tx_bh with a dummy boot to send fake bootp/dhcp request.
      BIOS guest manages virtio driver to send 4 bootp/dhcp request in case of
      dummy boot.
      => These packets must be discarded.

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agonet: add trace_vhost_user_event
Marc-André Lureau [Fri, 9 Oct 2015 15:17:30 +0000 (17:17 +0200)]
net: add trace_vhost_user_event

Replace error_report() and use tracing instead. It's not an error to get
a connection or a disconnection, so silence this and trace it instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user: document migration log
Marc-André Lureau [Fri, 9 Oct 2015 15:17:29 +0000 (17:17 +0200)]
vhost-user: document migration log

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost: use a function for each call
Marc-André Lureau [Fri, 9 Oct 2015 15:17:28 +0000 (17:17 +0200)]
vhost: use a function for each call

Replace the generic vhost_call() by specific functions for each
function call to help with type safety and changing arguments.

While doing this, I found that "unsigned long long" and "uint64_t" were
used interchangeably and causing compilation warnings, using uint64_t
instead, as the vhost & protocol specifies.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Fix enum usage and MQ - Thibaut Collet]
Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user: add a migration blocker
Marc-André Lureau [Fri, 9 Oct 2015 15:17:27 +0000 (17:17 +0200)]
vhost-user: add a migration blocker

If VHOST_USER_PROTOCOL_F_LOG_SHMFD is not announced, block vhost-user
migration. The blocker is removed in vhost_dev_cleanup().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user: send log shm fd along with log_base
Marc-André Lureau [Fri, 9 Oct 2015 15:17:26 +0000 (17:17 +0200)]
vhost-user: send log shm fd along with log_base

Send the shm for the dirty pages logging if the backend supports
VHOST_USER_PROTOCOL_F_LOG_SHMFD. Wait for a reply to make sure
the old log is no longer used.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost: alloc shareable log
Marc-André Lureau [Fri, 9 Oct 2015 15:17:25 +0000 (17:17 +0200)]
vhost: alloc shareable log

If the backend is requires it, allocate shareable memory.

vhost_log_get() now uses 2 globals "vhost_log" and "vhost_log_shm", that
way there is a common non-shareable log and a common shareable one.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost-user: add vhost_user_requires_shm_log()
Marc-André Lureau [Fri, 9 Oct 2015 15:17:24 +0000 (17:17 +0200)]
vhost-user: add vhost_user_requires_shm_log()

Check if the backend has VHOST_USER_PROTOCOL_F_LOG_SHMFD feature and
require a shared log.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost: add vhost_set_log_base op
Marc-André Lureau [Fri, 9 Oct 2015 15:17:23 +0000 (17:17 +0200)]
vhost: add vhost_set_log_base op

Split VHOST_SET_LOG_BASE call in a seperate function callback, so that
type safety works and more arguments can be added in the next patches.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovhost: document log resizing
Marc-André Lureau [Fri, 9 Oct 2015 15:17:22 +0000 (17:17 +0200)]
vhost: document log resizing

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agoutil: add fallback for qemu_memfd_alloc()
Marc-André Lureau [Fri, 9 Oct 2015 15:17:21 +0000 (17:17 +0200)]
util: add fallback for qemu_memfd_alloc()

Add an open/unlink/mmap fallback for system that do not support
memfd (only available since 3.17, ~1y ago).

This patch may require additional SELinux policies to work for enforced
systems, but should fail gracefully in this case.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agoutil: add memfd helpers
Marc-André Lureau [Fri, 9 Oct 2015 15:17:20 +0000 (17:17 +0200)]
util: add memfd helpers

Add qemu_memfd_alloc/free() helpers.

The function helps to allocate and seal shared memory.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agoutil: add linux-only memfd fallback
Marc-André Lureau [Fri, 9 Oct 2015 15:17:19 +0000 (17:17 +0200)]
util: add linux-only memfd fallback

Implement memfd_create() fallback if not available in system libc.
memfd_create() is still not included in glibc today, atlhough it's been
available since Linux 3.17 in Oct 2014.

memfd has numerous advantages over traditional shm/mmap for ipc memory
sharing with fd handler, which we are going to make use of for
vhost-user logging memory in following patches.

The next patches are going to introduce helpers to use best practices of
memfd usage and provide some compatibility fallback. memfd.c is thus
temporarily useless and eventually empty if memfd_create() is provided
by the system.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agobuild-sys: split util-obj- on multi-lines
Marc-André Lureau [Fri, 9 Oct 2015 15:17:18 +0000 (17:17 +0200)]
build-sys: split util-obj- on multi-lines

Make it easier to add new unrelated units with shorter lines.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agolinux-headers: add unistd.h
Marc-André Lureau [Fri, 9 Oct 2015 15:17:17 +0000 (17:17 +0200)]
linux-headers: add unistd.h

New syscalls are not yet widely distributed. Add them to qemu
linux-headers include directory. Update based on v4.3-rc3 kernel headers.

Exclude mips for now, which is more problematic due to extra header
inclusion and probably unnecessary here.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agoconfigure: probe for memfd
Marc-André Lureau [Fri, 9 Oct 2015 15:17:16 +0000 (17:17 +0200)]
configure: probe for memfd

Check if memfd_create() is part of system libc.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agovirtio: add some migration doc
Cornelia Huck [Thu, 17 Sep 2015 16:42:57 +0000 (18:42 +0200)]
virtio: add some migration doc

Try to cover the basics of virtio migration.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
8 years agovhost: fail backend intialization early
Igor Mammedov [Tue, 6 Oct 2015 08:37:29 +0000 (10:37 +0200)]
vhost: fail backend intialization early

Don't initialize vhost backend if memslots number exceeds the supported
limit. This prevents failures down the road when backend
is actually started.

[MST: rewrite commit log]

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc-dimm: add vhost slots limit check before commiting to hotplug
Igor Mammedov [Tue, 6 Oct 2015 08:37:28 +0000 (10:37 +0200)]
pc-dimm: add vhost slots limit check before commiting to hotplug

it allows safely cancel memory hotplug if vhost backend
doesn't support necessary amount of memory slots and prevents
QEMU crashing in vhost due to hitting vhost limit on amount
of supported memory ranges.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agovhost: add vhost_has_free_slot() interface
Igor Mammedov [Tue, 6 Oct 2015 08:37:27 +0000 (10:37 +0200)]
vhost: add vhost_has_free_slot() interface

it will allow for other parts of QEMU check if it's safe
to map memory region during hotplug/runtime.
That way hotplug path will have a chance to cancel
hotplug operation instead of crashing in vhost_commit().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/xtensa/tags/20151021-xtensa' into staging
Peter Maydell [Wed, 21 Oct 2015 20:21:29 +0000 (21:21 +0100)]
Merge remote-tracking branch 'remotes/xtensa/tags/20151021-xtensa' into staging

Xtensa updates:

- fix register window overflow with l32e/s32e instructions;
- make MMU events logging dependent on CPU_LOG_MMU;
- attach FLASH to system I/O region on XTFPGA boards;
- implement depbits and l32nb instructions.

# gpg: Signature made Wed 21 Oct 2015 19:34:02 BST using RSA key ID F83FA044
# gpg: Good signature from "Max Filippov <max.filippov@cogentembedded.com>"
# gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>"

* remotes/xtensa/tags/20151021-xtensa:
  target-xtensa: implement S32NB
  target-xtensa: implement depbits instruction
  target-xtensa: xtfpga: attach FLASH to system IO
  target-xtensa: use CPU_LOG_MMU for MMU event logging
  target-xtensa: add window overflow check to L32E/S32E

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotarget-xtensa: implement S32NB
Max Filippov [Sun, 19 Jul 2015 06:49:00 +0000 (09:49 +0300)]
target-xtensa: implement S32NB

S32NB provides the same functionality as S32I with two exceptions.
First, when its operation leaves the processor, the external transaction
is marked Non-Bufferable. Second, it may not be used to write to
Instruction RAM.
In QEMU S32NB is equivalent to S32I.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
8 years agotarget-xtensa: implement depbits instruction
Max Filippov [Sat, 11 Jul 2015 23:10:17 +0000 (02:10 +0300)]
target-xtensa: implement depbits instruction

This option provides an instruction for depositing a bit field from the
least significant position of one register to an arbitrary position in
another register.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
8 years agotarget-xtensa: xtfpga: attach FLASH to system IO
Max Filippov [Sun, 27 Sep 2015 15:21:19 +0000 (18:21 +0300)]
target-xtensa: xtfpga: attach FLASH to system IO

XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important
for systems with MMU where system IO block is visible at single
location, but it's important for noMMU systems, where system IO block is
accessible through two separate physical address ranges.

Map XTFPGA FLASH to system IO block and fix offsets used for mapping.
Create and initialize FLASH device with series of qdev_prop_set_* as
that's the preferred interface now. Keep initialization in a separate
function.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
8 years agotarget-xtensa: use CPU_LOG_MMU for MMU event logging
Max Filippov [Mon, 21 Sep 2015 17:37:07 +0000 (20:37 +0300)]
target-xtensa: use CPU_LOG_MMU for MMU event logging

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
8 years agotarget-xtensa: add window overflow check to L32E/S32E
Max Filippov [Sun, 19 Jul 2015 07:02:37 +0000 (10:02 +0300)]
target-xtensa: add window overflow check to L32E/S32E

Despite L32E and S32E primary use is for window underflow and overflow
exception handlers they are just normal instructions, and thus need to
check for window overflow.

Cc: qemu-stable@nongnu.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
8 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20151021-v2' into staging
Peter Maydell [Wed, 21 Oct 2015 14:07:42 +0000 (15:07 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20151021-v2' into staging

More s390x patches. The first ones are fixes: A regression, missed
compat and a missed part of the SIMD support. The others contain
optimizations and cleanup.

# gpg: Signature made Wed 21 Oct 2015 11:24:48 BST using RSA key ID C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"

* remotes/cohuck/tags/s390x-20151021-v2:
  s390x/cmma: clean up cmma reset
  s390x: reset crypto only on clear reset and QEMU reset
  s390x: machine reset function with new ipl cpu handling
  s390x/ipl: we always have an ipl device
  s390x: unify device reset during subsystem_reset()
  s390x: flagify mcic values
  s390x/kvm: Fix vector validity bit in device machine checks
  s390x/virtio-ccw: fix 2.4 virtio compat
  util/qemu-config: fix missing machine command line options

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agos390x/cmma: clean up cmma reset
David Hildenbrand [Tue, 21 Jul 2015 09:11:11 +0000 (11:11 +0200)]
s390x/cmma: clean up cmma reset

The cmma reset is per VM, so we don't need a cpu object. We can
directly make use of kvm_state, as it is already available when
the reset is called. By moving the cmma reset in our machine reset
function, we can avoid a manual reset handler.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: reset crypto only on clear reset and QEMU reset
David Hildenbrand [Wed, 30 Sep 2015 11:48:45 +0000 (13:48 +0200)]
s390x: reset crypto only on clear reset and QEMU reset

Initializing VM crypto in initial cpu reset has multiple problems

1. We call the exact same function #VCPU times, although one time is enough
2. On SIGP initial cpu reset, we exchange the wrapping key while
   other VCPUs are running. Bad!
3. It is simply wrong. According to the Pop, a reset happens only during a
   clear reset.

So, we have to reset the keys
- on modified clear reset
- on load clear (QEMU reset - via machine reset)
- on qemu start (via machine reset)

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: machine reset function with new ipl cpu handling
David Hildenbrand [Tue, 21 Jul 2015 11:47:32 +0000 (13:47 +0200)]
s390x: machine reset function with new ipl cpu handling

Current implementation depends on the order of resets getting triggered.

If a cpu reset is triggered after the ipl device reset, the CPU is stopped and
the VM will not run. In fact, that hinders us from converting the ipl device
into a TYPE_DEVICE. Let's change that by manually configuring the ipl cpu
during a system reset, so we have full control and can demangle that code.

Also remove the superflous cpu parameter from s390_update_iplstate on the way.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/ipl: we always have an ipl device
David Hildenbrand [Thu, 25 Jun 2015 07:55:55 +0000 (09:55 +0200)]
s390x/ipl: we always have an ipl device

Both s390 machines unconditionally create an ipl device, so no need to
handle the missing case.

Now we can also change s390_ipl_update_diag308() to return void.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x: unify device reset during subsystem_reset()
David Hildenbrand [Tue, 21 Jul 2015 08:58:38 +0000 (10:58 +0200)]
s390x: unify device reset during subsystem_reset()

We have to manually reset several devices that are not on a bus: Let's
collect them in an array.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agonet: don't set native endianness
Michael S. Tsirkin [Wed, 14 Oct 2015 09:11:27 +0000 (12:11 +0300)]
net: don't set native endianness

commit 5be7d9f1b1452613b95c6ba70b8d7ad3d0797991
    vhost-net: tell tap backend about the vnet endianness
makes vhost net always try to set LE - even if that matches the
native endian-ness.

This makes it fail on older kernels on x86 without TUNSETVNETLE support.

To fix, make qemu_set_vnet_le/qemu_set_vnet_be skip the
ioctl if it matches the host endian-ness.

Reported-by: Marcel Apfelbaum <marcel@redhat.com>
Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoexec: factor out duplicate mmap code
Michael S. Tsirkin [Thu, 24 Sep 2015 11:41:17 +0000 (14:41 +0300)]
exec: factor out duplicate mmap code

Anonymous and file-backed RAM allocation are now almost exactly the same.

Reduce code duplication by moving RAM mmap code out of oslib-posix.c and
exec.c.

Reported-by: Marc-André Lureau <mlureau@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/io-channel-3-for-upstream' into...
Peter Maydell [Tue, 20 Oct 2015 15:51:43 +0000 (16:51 +0100)]
Merge remote-tracking branch 'remotes/berrange/tags/io-channel-3-for-upstream' into staging

Merge io-channels-3 partial branch

# gpg: Signature made Tue 20 Oct 2015 16:36:10 BST using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/io-channel-3-for-upstream:
  util: pull Buffer code out of VNC module
  coroutine: move into libqemuutil.a library
  osdep: add qemu_fork() wrapper for safely handling signals
  ui: convert VNC startup code to use SocketAddress
  sockets: allow port to be NULL when listening on IP address
  sockets: move qapi_copy_SocketAddress into qemu-sockets.c
  sockets: add helpers for creating SocketAddress from a socket

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agos390x: flagify mcic values
Cornelia Huck [Thu, 8 Oct 2015 13:05:46 +0000 (15:05 +0200)]
s390x: flagify mcic values

Instead of using magic values when building the machine check
interruption code, add some defines as by chapter 11-14 in the PoP.

This should make it easier to catch problems like the missing vector
register validity bit ("s390x/kvm: Fix vector validity bit in device
machine checks"), and less hassle should we want to generate machine
checks beyond the channel reports we currently support.

Acked-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/kvm: Fix vector validity bit in device machine checks
Christian Borntraeger [Wed, 7 Oct 2015 08:29:42 +0000 (10:29 +0200)]
s390x/kvm: Fix vector validity bit in device machine checks

Device hotplugs trigger a crw machine check. All machine checks
have validity bits for certain register types. With vector support
we also have to claim that vector registers are valid.
This is a band-aid suitable for stable. Long term we should
create the full  mcic value dynamically depending on the active
features in the kernel interrupt handler.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agos390x/virtio-ccw: fix 2.4 virtio compat
Cornelia Huck [Thu, 8 Oct 2015 13:11:34 +0000 (15:11 +0200)]
s390x/virtio-ccw: fix 2.4 virtio compat

Commit 542571d5 ("virtio-ccw: enable virtio-1") missed some virtio
devices for the 2.4 compat handling. Add them.

Fixes: 542571d5 ("virtio-ccw: enable virtio-1")
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
8 years agoutil/qemu-config: fix missing machine command line options
Tony Krowiak [Mon, 12 Oct 2015 15:36:21 +0000 (11:36 -0400)]
util/qemu-config: fix missing machine command line options

Commit 0a7cf217 ("util/qemu-config: fix regression of
qmp_query_command_line_options") aimed to restore parsing of global
machine options, but missed two: "aes-key-wrap" and
"dea-key-wrap" (which were present in the initial version of that
patch). Let's add them to the machine_opts again.

Fixes: 0a7cf217 ("util/qemu-config: fix regression of
                  qmp_query_command_line_options")
CC: Marcel Apfelbaum <marcel@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <1444664181-28023-1-git-send-email-akrowiak@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agoutil: pull Buffer code out of VNC module
Daniel P. Berrange [Tue, 3 Mar 2015 17:13:42 +0000 (17:13 +0000)]
util: pull Buffer code out of VNC module

The Buffer code in the VNC server is useful for the IO channel
code, so pull it out into a shared module, QIOBuffer.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocoroutine: move into libqemuutil.a library
Daniel P. Berrange [Tue, 1 Sep 2015 13:48:02 +0000 (14:48 +0100)]
coroutine: move into libqemuutil.a library

The coroutine files are currently referenced by the block-obj-y
variable. The coroutine functionality though is already used by
more than just the block code. eg migration code uses coroutine
yield. In the future the I/O channel code will also use the
coroutine yield functionality. Since the coroutine code is nicely
self-contained it can be easily built as part of the libqemuutil.a
library, making it widely available.

The headers are also moved into include/qemu, instead of the
include/block directory, since they are now part of the util
codebase, and the impl was never in the block/ directory
either.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoosdep: add qemu_fork() wrapper for safely handling signals
Daniel P. Berrange [Fri, 28 Aug 2015 13:40:01 +0000 (14:40 +0100)]
osdep: add qemu_fork() wrapper for safely handling signals

When using regular fork() the child process of course inherits
all the parents' signal handlers. If the child then proceeds
to close() any open file descriptors, it may break some of those
registered signal handlers. The child generally does not want to
ever run any of the signal handlers that the parent may have
installed in the short time before it exec's. The parent may also
have blocked various signals which the child process will want
enabled.

This introduces a wrapper qemu_fork() that takes care to sanitize
signal handling across fork. Before forking it blocks all signals
in the parent thread. After fork returns, the parent unblocks the
signals and carries on as usual. The child, however, resets all the
signal handlers back to their defaults before it unblocks signals.
The child process can now exec the binary in a "clean" signal
environment.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoui: convert VNC startup code to use SocketAddress
Daniel P. Berrange [Fri, 14 Aug 2015 17:56:44 +0000 (18:56 +0100)]
ui: convert VNC startup code to use SocketAddress

The VNC code is currently using QemuOpts to configure the
sockets connections / listeners it needs. Convert it to
use SocketAddress to bring it in line with modern QAPI
based code elsewhere in QEMU.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agosockets: allow port to be NULL when listening on IP address
Daniel P. Berrange [Tue, 1 Sep 2015 13:46:50 +0000 (14:46 +0100)]
sockets: allow port to be NULL when listening on IP address

If the port in the SocketAddress struct is NULL, it can allow
the kernel to automatically select a free port. This is useful
in particular in unit tests to avoid a race trying to find a
free port to run a test case on.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agosockets: move qapi_copy_SocketAddress into qemu-sockets.c
Daniel P. Berrange [Fri, 14 Aug 2015 17:18:41 +0000 (18:18 +0100)]
sockets: move qapi_copy_SocketAddress into qemu-sockets.c

The qapi_copy_SocketAddress method is going to be useful
in more places than just qemu-char.c, so move it into
the qemu-sockets.c file to allow its reuse.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agosockets: add helpers for creating SocketAddress from a socket
Daniel P. Berrange [Fri, 1 May 2015 16:36:20 +0000 (17:36 +0100)]
sockets: add helpers for creating SocketAddress from a socket

Add two helper methods that, given a socket file descriptor,
can return a populated SocketAddress struct containing either
the local or remote address information.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-input-20151020-1' into staging
Peter Maydell [Tue, 20 Oct 2015 11:56:45 +0000 (12:56 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-20151020-1' into staging

virtio-input: ignore events until the guest driver is ready

# gpg: Signature made Tue 20 Oct 2015 08:10:00 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-input-20151020-1:
  virtio-input: ignore events until the guest driver is ready

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20151020-1' into staging
Peter Maydell [Tue, 20 Oct 2015 11:17:53 +0000 (12:17 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20151020-1' into staging

vga: enable virtio-vga for pseries, vmsvga cursor checks.

# gpg: Signature made Tue 20 Oct 2015 08:27:44 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-vga-20151020-1:
  vmsvga: more cursor checks
  ppc/spapr: Allow VIRTIO_VGA

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-fw_cfg-20151020-1' into staging
Peter Maydell [Tue, 20 Oct 2015 10:45:23 +0000 (11:45 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-fw_cfg-20151020-1' into staging

fw_cfg: add dma interface, add strings via cmdline.

# gpg: Signature made Tue 20 Oct 2015 07:07:34 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-fw_cfg-20151020-1:
  fw_cfg: Define a static signature to be returned on DMA port reads
  Enable fw_cfg DMA interface for x86
  Enable fw_cfg DMA interface for ARM
  Implement fw_cfg DMA interface
  fw_cfg DMA interface documentation
  fw_cfg: document fw_cfg_modify_iXX() update functions
  fw_cfg: insert string blobs via qemu cmdline

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20151020-1' into staging
Peter Maydell [Tue, 20 Oct 2015 09:52:56 +0000 (10:52 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20151020-1' into staging

usb: misc small tweaks.

# gpg: Signature made Tue 20 Oct 2015 08:24:09 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-20151020-1:
  usb-audio: increate default buffer size
  usb: print device id in "info usb" monitor command
  usb-host: add wakeup call for iso xfers

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-10-14-v4-tag' into...
Peter Maydell [Tue, 20 Oct 2015 08:04:20 +0000 (09:04 +0100)]
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-10-14-v4-tag' into staging

qemu-ga patch queue

* add unit tests for qemu-ga
* add guest-exec support for posix/w32 guests
* added 'qemu-ga' target for w32. this allows us to do full MSI build,
  without overloading 'qemu-ga.exe' target with uneeded dependencies.
* number of s/g_new/g_malloc/ conversions for qga

v2:
* commit message and qapi documentation spelling fixes
* rename 'inp-data' guest-exec param to 'input-data'

v3:
* fix OSX build errors for test-qga by using PRId64
  format in place of glib's, and dropping use of G_SPAWN_DEFAULT
  macro for glib 2.22 compat
* fix win32 build warnings for 32-bit builds by avoid int casts
  of process HANDLEs

v4:
* assert connect_qga() doesn't fail
* only enable test-qga for linux hosts
* allow get-memory-block-info* to fail if memory blocks aren't exposed in
  sysfs

# gpg: Signature made Tue 20 Oct 2015 00:33:43 BST using RSA key ID F108B584
# gpg: Good signature from "Michael Roth <flukshun@gmail.com>"
# gpg:                 aka "Michael Roth <mdroth@utexas.edu>"
# gpg:                 aka "Michael Roth <mdroth@linux.vnet.ibm.com>"

* remotes/mdroth/tags/qga-pull-2015-10-14-v4-tag:
  qga: fix uninitialized value warning for win32
  qga: guest-exec simple stdin/stdout/stderr redirection
  qga: handle G_IO_STATUS_AGAIN in ga_channel_write_all()
  qga: handle possible SIGPIPE in guest-file-write
  qga: guest exec functionality
  qga: drop guest_file_init helper and replace it with static initializers
  tests: add a local test for guest agent
  qga: guest-get-memory-blocks shouldn't fail for unexposed memory blocks
  glib-compat: add 2.38/2.40/2.46 asserts
  qtest: add a few fd-level qmp helpers
  qga: do not override configuration verbosity
  qga: add QGA_CONF environment variable
  qga: Use g_new() & friends where that makes obvious sense
  build: qemu-ga: add 'qemu-ga' build target for w32

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agovmsvga: more cursor checks
Gerd Hoffmann [Tue, 29 Sep 2015 07:58:05 +0000 (09:58 +0200)]
vmsvga: more cursor checks

Check the cursor size more carefully.  Also switch to unsigned while
being at it, so they can't be negative.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agoppc/spapr: Allow VIRTIO_VGA
Benjamin Herrenschmidt [Tue, 15 Sep 2015 05:51:29 +0000 (15:51 +1000)]
ppc/spapr: Allow VIRTIO_VGA

It works fine with the Linux driver out of the box

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agousb-audio: increate default buffer size
Gerd Hoffmann [Tue, 6 Oct 2015 13:31:56 +0000 (15:31 +0200)]
usb-audio: increate default buffer size

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agousb: print device id in "info usb" monitor command
Gerd Hoffmann [Tue, 6 Oct 2015 13:31:21 +0000 (15:31 +0200)]
usb: print device id in "info usb" monitor command

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agousb-host: add wakeup call for iso xfers
Gerd Hoffmann [Fri, 17 Jul 2015 07:12:57 +0000 (09:12 +0200)]
usb-host: add wakeup call for iso xfers

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agovirtio-input: ignore events until the guest driver is ready
Gerd Hoffmann [Fri, 16 Oct 2015 11:33:07 +0000 (13:33 +0200)]
virtio-input: ignore events until the guest driver is ready

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8 years agoqga: fix uninitialized value warning for win32
Michael Roth [Sat, 17 Oct 2015 15:31:16 +0000 (10:31 -0500)]
qga: fix uninitialized value warning for win32

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: guest-exec simple stdin/stdout/stderr redirection
Yuri Pudgorodskiy [Tue, 13 Oct 2015 15:41:23 +0000 (18:41 +0300)]
qga: guest-exec simple stdin/stdout/stderr redirection

Implemented with base64-encoded strings in qga json protocol.
Glib portable GIOChannel is used for data I/O.

Optinal stdin parameter of guest-exec command is now used as
stdin content for spawned subprocess.

If capture-output bool flag is specified, guest-exec redirects out/err
file descriptiors internally to pipes and collects subprocess
output.

Guest-exe-status is modified to return this collected data to requestor
in base64 encoding.

Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* switch from 'struct GuestIOExecData' to 'GuestIOExecData'
* s/TRUE/true/g, s/FALSE/false/g for gboolean return values
* s/inp_data/input_data/
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: handle G_IO_STATUS_AGAIN in ga_channel_write_all()
Yuri Pudgorodskiy [Tue, 13 Oct 2015 15:41:22 +0000 (18:41 +0300)]
qga: handle G_IO_STATUS_AGAIN in ga_channel_write_all()

glib may return G_IO_STATUS_AGAIN which is actually not an error.
Also fixed a bug when on incomplete write buf pointer was not adjusted.

Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: handle possible SIGPIPE in guest-file-write
Denis V. Lunev [Tue, 13 Oct 2015 15:41:21 +0000 (18:41 +0300)]
qga: handle possible SIGPIPE in guest-file-write

qemu-ga should not exit on guest-file-write to pipe without read end
but proper error code should be returned. The behavior of the
spawned process should be default thus SIGPIPE processing should be
reset to default after fork() but before exec().

Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: guest exec functionality
Yuri Pudgorodskiy [Tue, 13 Oct 2015 15:41:20 +0000 (18:41 +0300)]
qga: guest exec functionality

Guest-exec rewritten in platform-independent style with glib spawn.

Child process is spawn asynchronously and exit status can later
be picked up by guest-exec-status command.

stdin/stdout/stderr of the child now is redirected to /dev/null
Later we will add ability to specify stdin in guest-exec command
and to get collected stdout/stderr with guest-exec-status.

Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
* use g_new0 in place of g_malloc for GuestExec struct
* commit msg spelling fixes
* s/inp-data/input-data
* document capture-input mode as false by default
* use GetProcessId() for pids on w32 instead of casting HANDLE
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: drop guest_file_init helper and replace it with static initializers
Denis V. Lunev [Tue, 13 Oct 2015 15:41:19 +0000 (18:41 +0300)]
qga: drop guest_file_init helper and replace it with static initializers

This just makes code shorter and better.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agotests: add a local test for guest agent
Marc-André Lureau [Fri, 2 Oct 2015 12:58:18 +0000 (14:58 +0200)]
tests: add a local test for guest agent

Add some local guest agent tests, as it is better than nothing, only
when CONFIG_POSIX (using unix sockets).

With the QGA_TEST_SIDE_EFFECTING environment variable, it will include
tests with side effects, such as freezing/thawing the FS or changing the
time.

(a better test would involve a managed VM (or container), but it might
be better to leave that off to autotest/avocado)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* use mkdtemp() in placeof g_mkdtemp() for glib 2.22 compat
* drop redundant/conflicting compat defines for
  g_assert_{true,false}, since glib-compat has them now.
* build fixes for OSX: use PRId64 instead of glib formats, drop
  g_spawn_default usage for glib compat
* assert connect_qga() doesn't fail
* only enable test-qga for linux hosts
* allow get-memory-block-info* to fail
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: guest-get-memory-blocks shouldn't fail for unexposed memory blocks
Michael Roth [Mon, 19 Oct 2015 21:38:25 +0000 (16:38 -0500)]
qga: guest-get-memory-blocks shouldn't fail for unexposed memory blocks

Some guests don't expose memory blocks via sysfs at all. This
shouldn't be a failure, instead just return an empty list. For
other access failures we still report an error.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoglib-compat: add 2.38/2.40/2.46 asserts
Marc-André Lureau [Fri, 2 Oct 2015 12:58:17 +0000 (14:58 +0200)]
glib-compat: add 2.38/2.40/2.46 asserts

Those are mostly useful for writing tests.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqtest: add a few fd-level qmp helpers
Marc-André Lureau [Fri, 2 Oct 2015 12:58:16 +0000 (14:58 +0200)]
qtest: add a few fd-level qmp helpers

Add a few functions to interact with qmp via a simple fd.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: do not override configuration verbosity
Marc-André Lureau [Fri, 2 Oct 2015 12:58:15 +0000 (14:58 +0200)]
qga: do not override configuration verbosity

Move the default verbosity settings before loading the configuration
file, or it will overwrite it. Found thanks to writing qga tests :)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: add QGA_CONF environment variable
Marc-André Lureau [Fri, 2 Oct 2015 12:58:14 +0000 (14:58 +0200)]
qga: add QGA_CONF environment variable

Having a environment variable allows to override default configuration
path, useful for testing. Note that this can't easily be an argument,
since loading config is done before parsing the arguments.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agoqga: Use g_new() & friends where that makes obvious sense
Markus Armbruster [Mon, 14 Sep 2015 11:50:44 +0000 (13:50 +0200)]
qga: Use g_new() & friends where that makes obvious sense

g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
for two reasons.  One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.

This commit only touches allocations with size arguments of the form
sizeof(T).  Same Coccinelle semantic patch as in commit b45c03f.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
8 years agobuild: qemu-ga: add 'qemu-ga' build target for w32
Michael Roth [Mon, 7 Sep 2015 23:47:05 +0000 (18:47 -0500)]
build: qemu-ga: add 'qemu-ga' build target for w32

Currently POSIX builds rely on 'qemu-ga' target to do qga-only
distributable build. On w32, as with most standalone binary targets,
we rely on 'qemu-ga.exe' target.

Unlike with POSIX, qemu-ga for w32 has a number of related targets
such as VSS DLL and MSI package. We can do the full distributable
qga-only build on w32 with:

  make qemu-ga.exe

or:

  make msi

To make that work, we tie VSS dependencies onto qemu-ga.exe.
However, in reality the DLL isn't part of the binary, so we use a
filter to pull them out of the LINK recipe, which attempts to link
against prereqs for binary targets. Additionally, it could be argued
that VSS is a separate distributable, and shouldn't be implied by
qemu-ga.exe binary target.

To avoid this, we can tie the VSS dependencies only to the 'msi'
target, but that would make it impossible to do a qga-only build of
the w32 distributable without building the 'msi' package, which was
supported in the past.

An alternative approach is to add a new target to build the whole
distributable. w32 allows us to use the same build target we use
on POSIX, 'qemu-ga', since the current binary-only target on w32
is 'qemu-ga.exe'.

To further simplify the build, we also make 'qemu-ga' build the MSI
package if the appropriate ./configure options are set, making the
full qga-only build the same on both POSIX and w32: `make qemu-ga`

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>