From: Cornelia Huck <cohuck@redhat.com>
To: Jens Freimann <jfreimann@redhat.com>
Cc: pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com,
mst@redhat.com, aadam@redhat.com, qemu-devel@nongnu.org,
dgilbert@redhat.com, alex.williamson@redhat.com,
laine@redhat.com, ailan@redhat.com, parav@mellanox.com
Subject: Re: [PATCH 01/11] qdev/qbus: add hidden device support
Date: Mon, 21 Oct 2019 14:44:08 +0200 [thread overview]
Message-ID: <20191021144408.413b3fca.cohuck@redhat.com> (raw)
In-Reply-To: <20191018202040.30349-2-jfreimann@redhat.com>
On Fri, 18 Oct 2019 22:20:30 +0200
Jens Freimann <jfreimann@redhat.com> wrote:
> 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 net_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 "net_failover_pair_id" option, e.g.
>
> -device virtio-net-pci,...,failover=on,...
> -device vfio-pci,...,net_failover_pair_id=net1,...
>
> Signed-off-by: Jens Freimann <jfreimann@redhat.com>
> ---
> hw/core/qdev.c | 23 +++++++++++++++++++++++
> include/hw/qdev-core.h | 8 ++++++++
> qdev-monitor.c | 36 +++++++++++++++++++++++++++++++++---
> vl.c | 6 ++++--
> 4 files changed, 68 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index cbad6c1d55..89c134ec53 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -212,6 +212,29 @@ void device_listener_unregister(DeviceListener *listener)
> QTAILQ_REMOVE(&device_listeners, listener, link);
> }
>
> +bool qdev_should_hide_device(QemuOpts *opts)
> +{
> + int rc;
Initialize to 0?
> + DeviceListener *listener;
> +
> + QTAILQ_FOREACH(listener, &device_listeners, link) {
> + if (listener->should_be_hidden) {
> + /* should_be_hidden_will return
> + * 1 if device matches opts and it should be hidden
> + * 0 if device matches opts and should not be hidden
> + * -1 if device doesn't match ops
> + */
> + rc = listener->should_be_hidden(listener, opts);
> + }
> +
> + if (rc > 0) {
> + break;
> + }
> + }
> +
> + return rc > 0;
> +}
> +
> void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
> int required_for_version)
> {
(...)
> +static bool should_hide_device(QemuOpts *opts)
> +{
> + if (qemu_opt_foreach(opts, is_failover_device, opts, NULL) == 0) {
> + return false;
> + }
> + return true;
> +}
I still think you should turn the check around to make it easier to
extend in the future, but this is fine as well.
(...)
With the rc thing changed,
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
next prev parent reply other threads:[~2019-10-21 12:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 20:20 [PATCH v4 0/11] add failover feature for assigned network devices Jens Freimann
2019-10-18 20:20 ` [PATCH 01/11] qdev/qbus: add hidden device support Jens Freimann
2019-10-21 12:44 ` Cornelia Huck [this message]
2019-10-21 12:52 ` Jens Freimann
2019-10-21 12:53 ` Peter Maydell
2019-10-21 13:00 ` Jens Freimann
2019-10-18 20:20 ` [PATCH 02/11] pci: add option for net failover Jens Freimann
2019-10-21 14:58 ` Alex Williamson
2019-10-21 18:45 ` Jens Freimann
2019-10-21 19:01 ` Alex Williamson
2019-10-21 20:28 ` Jens Freimann
2019-10-21 20:48 ` Alex Williamson
2019-10-18 20:20 ` [PATCH 03/11] pci: mark devices partially unplugged Jens Freimann
2019-10-18 20:20 ` [PATCH 04/11] pci: mark device having guest unplug request pending Jens Freimann
2019-10-18 20:20 ` [PATCH 05/11] qapi: add unplug primary event Jens Freimann
2019-10-18 20:28 ` Eric Blake
2019-10-21 7:23 ` Jens Freimann
2019-10-18 20:20 ` [PATCH 06/11] qapi: add failover negotiated event Jens Freimann
2019-10-18 20:20 ` [PATCH 07/11] migration: allow unplug during migration for failover devices Jens Freimann
2019-10-18 20:20 ` [PATCH 08/11] migration: add new migration state wait-unplug Jens Freimann
2019-10-18 20:20 ` [PATCH 09/11] libqos: tolerate wait-unplug migration state Jens Freimann
2019-10-18 20:20 ` [PATCH 10/11] net/virtio: add failover support Jens Freimann
2019-10-18 20:20 ` [PATCH 11/11] vfio: unplug failover primary device before migration Jens Freimann
2019-10-21 13:45 ` Cornelia Huck
2019-10-21 14:09 ` Jens Freimann
2019-10-21 15:19 ` Alex Williamson
2019-10-21 19:16 ` Jens Freimann
2019-10-19 15:12 ` [PATCH v4 0/11] add failover feature for assigned network devices no-reply
2019-10-21 7:30 ` Jens Freimann
2019-10-19 15:15 ` no-reply
2019-10-21 14:18 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191021144408.413b3fca.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=aadam@redhat.com \
--cc=ailan@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jfreimann@redhat.com \
--cc=laine@redhat.com \
--cc=mst@redhat.com \
--cc=parav@mellanox.com \
--cc=pkrempa@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.