qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] f3a850: qdev/qbus: add hidden device support


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] f3a850: qdev/qbus: add hidden device support
Date: Wed, 30 Oct 2019 04:10:14 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: f3a8505656935cde32e28c1c6317f725084da1e0
      
https://github.com/qemu/qemu/commit/f3a8505656935cde32e28c1c6317f725084da1e0
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/core/qdev.c
    M include/hw/qdev-core.h
    M qdev-monitor.c
    M vl.c

  Log Message:
  -----------
  qdev/qbus: add hidden device support

This adds support for hiding a device to the qbus and qdev APIs.  The
first user of this will be the virtio-net failover feature but the API
introduced with this patch could be used to implement other features as
well, for example hiding pci devices when a pci bus is powered off.

qdev_device_add() is modified to check for a failover_pair_id
argument in the option string. A DeviceListener callback
should_be_hidden() is added. It can be used by a standby device to
inform qdev that this device should not be added now. The standby device
handler can store the device options to plug the device in at a later
point in time.

One reason for hiding the device is that we don't want to expose both
devices to the guest kernel until the respective virtio feature bit
VIRTIO_NET_F_STANDBY was negotiated and we know that the devices will be
handled correctly by the guest.

More information on the kernel feature this is using:
 https://www.kernel.org/doc/html/latest/networking/net_failover.html

An example where the primary device is a vfio-pci device and the standby
device is a virtio-net device:

A device is hidden when it has an "failover_pair_id" option, e.g.

 -device virtio-net-pci,...,failover=on,...
 -device vfio-pci,...,failover_pair_id=net1,...

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: 4f5b6a05a4e76892d8d03838a36aca735e9bcefb
      
https://github.com/qemu/qemu/commit/4f5b6a05a4e76892d8d03838a36aca735e9bcefb
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/pci/pci.c
    M include/hw/pci/pci.h

  Log Message:
  -----------
  pci: add option for net failover

This patch adds a failover_pair_id property to PCIDev which is
used to link the primary device in a failover pair (the PCI dev) to
a standby (a virtio-net-pci) device.

It only supports ethernet devices. Also currently it only supports
PCIe devices. The requirement for PCIe is because it doesn't support
other hotplug controllers at the moment. The failover functionality can
be added to other hotplug controllers like ACPI, SHCP,... later on.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: a99c4da9fc2a39847cfebbc0c6802ee122dcca39
      
https://github.com/qemu/qemu/commit/a99c4da9fc2a39847cfebbc0c6802ee122dcca39
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/pci/pcie.c
    M include/hw/pci/pci.h

  Log Message:
  -----------
  pci: mark devices partially unplugged

Only the guest unplug request was triggered. This is needed for
the failover feature. In case of a failed migration we need to
plug the device back to the guest.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: c000a9bd06ea79ea5c2c1f894a47410be48c0cc1
      
https://github.com/qemu/qemu/commit/c000a9bd06ea79ea5c2c1f894a47410be48c0cc1
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/pci/pcie.c

  Log Message:
  -----------
  pci: mark device having guest unplug request pending

Set pending_deleted_event in DeviceState for failover
primary devices that were successfully unplugged by the Guest OS.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: d328e6f37229e86a5e0059a98c4acfa9be9c8783
      
https://github.com/qemu/qemu/commit/d328e6f37229e86a5e0059a98c4acfa9be9c8783
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M qapi/migration.json

  Log Message:
  -----------
  qapi: add unplug primary event

This event is emitted when we sent a request to unplug a
failover primary device from the Guest OS and it includes the
device id of the primary device.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Acked-by: Markus Armbruster <address@hidden>


  Commit: 70d04971f1ec71ba01c3dc5d4c760fa2c87e2612
      
https://github.com/qemu/qemu/commit/70d04971f1ec71ba01c3dc5d4c760fa2c87e2612
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M qapi/net.json

  Log Message:
  -----------
  qapi: add failover negotiated event

This event is sent to let libvirt know that VIRTIO_NET_F_STANDBY feature
is enabled. The primary device this virtio-net (standby) device is
associated with, is now hotplugged by the virtio-net device.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Acked-by: Markus Armbruster <address@hidden>


  Commit: a1190ab628c0e2816eae42786cd7396d6638aa48
      
https://github.com/qemu/qemu/commit/a1190ab628c0e2816eae42786cd7396d6638aa48
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/core/qdev.c
    M hw/pci/pci.c
    M include/hw/qdev-core.h
    M qdev-monitor.c

  Log Message:
  -----------
  migration: allow unplug during migration for failover devices

In "b06424de62 migration: Disable hotplug/unplug during migration" we
added a check to disable unplug for all devices until we have figured
out what works. For failover primary devices qdev_unplug() is called
from the migration handler, i.e. during migration.

This patch adds a flag to DeviceState which is set to false for all
devices and makes an exception for PCI devices that are also
primary devices in a failover pair.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: c7e0acd5a3f87d4aabb7a702aff87f83fc3ce151
      
https://github.com/qemu/qemu/commit/c7e0acd5a3f87d4aabb7a702aff87f83fc3ce151
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M include/migration/vmstate.h
    M migration/migration.c
    M migration/migration.h
    M migration/savevm.c
    M migration/savevm.h
    M qapi/migration.json

  Log Message:
  -----------
  migration: add new migration state wait-unplug

This patch adds a new migration state called wait-unplug.  It is entered
after the SETUP state if failover devices are present. It will transition
into ACTIVE once all devices were succesfully unplugged from the guest.

So if a guest doesn't respond or takes long to honor the unplug request
the user will see the migration state 'wait-unplug'.

In the migration thread we query failover devices if they're are still
pending the guest unplug. When all are unplugged the migration
continues. If one device won't unplug migration will stay in wait_unplug
state.

Signed-off-by: Jens Freimann <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: ea45cb8d84d25c3a3103932def12558de1bbe208
      
https://github.com/qemu/qemu/commit/ea45cb8d84d25c3a3103932def12558de1bbe208
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M tests/libqos/libqos.c

  Log Message:
  -----------
  libqos: tolerate wait-unplug migration state

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: 9711cd0dfc3fa414f7f64935713c07134ae67971
      
https://github.com/qemu/qemu/commit/9711cd0dfc3fa414f7f64935713c07134ae67971
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M MAINTAINERS
    A docs/virtio-net-failover.rst
    M hw/net/virtio-net.c
    M include/hw/virtio/virtio-net.h
    M include/hw/virtio/virtio.h

  Log Message:
  -----------
  net/virtio: add failover support

This patch adds support to handle failover device pairs of a virtio-net
device and a (vfio-)pci device, where the virtio-net acts as the standby
device and the (vfio-)pci device as the primary.

The general idea is that we have a pair of devices, a (vfio-)pci and a
emulated (virtio-net) device. Before migration the vfio device is
unplugged and data flows to the emulated device, on the target side
another (vfio-)pci device is plugged in to take over the data-path. In the
guest the net_failover module will pair net devices with the same MAC
address.

To achieve this we need:

1. Provide a callback function for the should_be_hidden DeviceListener.
   It is called when the primary device is plugged in. Evaluate the QOpt
   passed in to check if it is the matching primary device. It returns
   if the device should be hidden or not.
   When it should be hidden it stores the device options in the VirtioNet
   struct and the device is added once the VIRTIO_NET_F_STANDBY feature is
   negotiated during virtio feature negotiation.

   If the virtio-net devices are not realized at the time the (vfio-)pci
   devices are realized, we need to connect the devices later. This way
   we make sure primary and standby devices can be specified in any
   order.

2. Register a callback for migration status notifier. When called it
   will unplug its primary device before the migration happens.

3. Register a callback for the migration code that checks if a device
   needs to be unplugged from the guest.

Signed-off-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: f045a0104c8ce38da7f42141a6b3ebf3d74b474b
      
https://github.com/qemu/qemu/commit/f045a0104c8ce38da7f42141a6b3ebf3d74b474b
  Author: Jens Freimann <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/vfio/pci.c
    M hw/vfio/pci.h

  Log Message:
  -----------
  vfio: unplug failover primary device before migration

As usual block all vfio-pci devices from being migrated, but make an
exception for failover primary devices. This is achieved by setting
unmigratable to 0 but also add a migration blocker for all vfio-pci
devices except failover primary devices. These will be unplugged before
migration happens by the migration handler of the corresponding
virtio-net standby device.

Signed-off-by: Jens Freimann <address@hidden>
Acked-by: Alex Williamson <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: 7a064bcc6699151311c2067eea6546da6498ebe7
      
https://github.com/qemu/qemu/commit/7a064bcc6699151311c2067eea6546da6498ebe7
  Author: Dr. David Alan Gilbert <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/virtio/vhost.c

  Log Message:
  -----------
  virtio/vhost: Use auto_rcu_read macros

Use RCU_READ_LOCK_GUARD instead of manual rcu_read_(un)lock

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: 068ddfa970063730c5a61b06bae336d68de114e1
      
https://github.com/qemu/qemu/commit/068ddfa970063730c5a61b06bae336d68de114e1
  Author: Dr. David Alan Gilbert <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/net/virtio-net.c

  Log Message:
  -----------
  virtio_net: use RCU_READ_LOCK_GUARD

Use RCU_READ_LOCK_GUARD rather than the manual rcu_read_(un)lock call.

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: b5f53d04a5a567ac70d33ec95628d35583eba600
      
https://github.com/qemu/qemu/commit/b5f53d04a5a567ac70d33ec95628d35583eba600
  Author: Dr. David Alan Gilbert <address@hidden>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M hw/virtio/virtio.c

  Log Message:
  -----------
  virtio: Use auto rcu_read macros

Use RCU_READ_LOCK_GUARD and WITH_RCU_READ_LOCK_GUARD
to replace the manual rcu_read_(un)lock calls.

I think the only change is virtio_load which was missing unlocks
in error paths; those end up being fatal errors so it's not
that important anyway.

Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>


  Commit: 63df86b26418baac9fe3a6ab09b3b7aa0807f11b
      
https://github.com/qemu/qemu/commit/63df86b26418baac9fe3a6ab09b3b7aa0807f11b
  Author: Peter Maydell <address@hidden>
  Date:   2019-10-30 (Wed, 30 Oct 2019)

  Changed paths:
    M MAINTAINERS
    A docs/virtio-net-failover.rst
    M hw/core/qdev.c
    M hw/net/virtio-net.c
    M hw/pci/pci.c
    M hw/pci/pcie.c
    M hw/vfio/pci.c
    M hw/vfio/pci.h
    M hw/virtio/vhost.c
    M hw/virtio/virtio.c
    M include/hw/pci/pci.h
    M include/hw/qdev-core.h
    M include/hw/virtio/virtio-net.h
    M include/hw/virtio/virtio.h
    M include/migration/vmstate.h
    M migration/migration.c
    M migration/migration.h
    M migration/savevm.c
    M migration/savevm.h
    M qapi/migration.json
    M qapi/net.json
    M qdev-monitor.c
    M tests/libqos/libqos.c
    M vl.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio: features, cleanups

virtio net failover
rcu cleanup

Signed-off-by: Michael S. Tsirkin <address@hidden>

# gpg: Signature made Tue 29 Oct 2019 22:58:14 GMT
# gpg:                using RSA key 281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <address@hidden>" [full]
# gpg:                 aka "Michael S. Tsirkin <address@hidden>" [full]
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
  virtio: Use auto rcu_read macros
  virtio_net: use RCU_READ_LOCK_GUARD
  virtio/vhost: Use auto_rcu_read macros
  vfio: unplug failover primary device before migration
  net/virtio: add failover support
  libqos: tolerate wait-unplug migration state
  migration: add new migration state wait-unplug
  migration: allow unplug during migration for failover devices
  qapi: add failover negotiated event
  qapi: add unplug primary event
  pci: mark device having guest unplug request pending
  pci: mark devices partially unplugged
  pci: add option for net failover
  qdev/qbus: add hidden device support

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/16884391c750...63df86b26418



reply via email to

[Prev in Thread] Current Thread [Next in Thread]