From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Jens Freimann" <jfreimann@redhat.com>
Subject: [RFC PATCH v2 2/8] qdev/qbus: remove failover specific code
Date: Fri, 20 Aug 2021 16:19:56 +0200 [thread overview]
Message-ID: <20210820142002.152994-3-lvivier@redhat.com> (raw)
In-Reply-To: <20210820142002.152994-1-lvivier@redhat.com>
Commit f3a850565693 ("qdev/qbus: add hidden device support") has
introduced a generic way to hide a device but it has modified
qdev_device_add() to check a specific option of the failover device,
"failover_pair_id", before calling the generic mechanism.
It's not needed (and not generic) to do that in qdev_device_add() because
this is also checked by the failover_hide_primary_device() function that
uses the generic mechanism to hide the device.
Cc: Jens Freimann <jfreimann@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
hw/net/virtio-net.c | 7 +++++++
softmmu/qdev-monitor.c | 14 ++++----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 542f9e167eb4..0c5ec930356b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3288,6 +3288,13 @@ static bool failover_hide_primary_device(DeviceListener *listener,
return false;
}
standby_id = qemu_opt_get(device_opts, "failover_pair_id");
+ if (standby_id == NULL) {
+ return false;
+ }
+ if (device_opts->id == NULL) {
+ error_setg(errp, "Device with failover_pair_id don't have id");
+ return true;
+ }
if (g_strcmp0(standby_id, n->netclient_name) != 0) {
return false;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 7adf0d22beb1..5c92dbed3139 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -622,17 +622,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
}
}
- if (qemu_opt_get(opts, "failover_pair_id")) {
- if (!opts->id) {
- error_setg(errp, "Device with failover_pair_id don't have id");
- return NULL;
- }
- if (qdev_should_hide_device(opts, errp)) {
- if (errp && !*errp && bus && !qbus_is_hotpluggable(bus)) {
- error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
- }
- return NULL;
+ if (qdev_should_hide_device(opts, errp)) {
+ if (errp && !*errp && bus && !qbus_is_hotpluggable(bus)) {
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
}
+ return NULL;
}
if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) {
--
2.31.1
next prev parent reply other threads:[~2021-08-20 14:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 14:19 [RFC PATCH v2 0/8] virtio-net failover cleanup and new features Laurent Vivier
2021-08-20 14:19 ` [RFC PATCH v2 1/8] qdev: add an Error parameter to the DeviceListener hide_device() function Laurent Vivier
2021-08-25 15:05 ` Juan Quintela
2021-08-20 14:19 ` Laurent Vivier [this message]
2021-08-25 15:07 ` [RFC PATCH v2 2/8] qdev/qbus: remove failover specific code Juan Quintela
2021-08-20 14:19 ` [RFC PATCH v2 3/8] failover: virtio-net: remove failover_primary_hidden flag Laurent Vivier
2021-08-25 15:09 ` Juan Quintela
2021-08-20 14:19 ` [RFC PATCH v2 4/8] failover: pci: move failover hotplug/unplug code into pci subsystem Laurent Vivier
2021-08-20 14:19 ` [RFC PATCH v2 5/8] failover: hide the PCI device if the virtio-net device is not present Laurent Vivier
2021-08-20 14:20 ` [RFC PATCH v2 6/8] failover: pci: unregister ROM on unplug Laurent Vivier
2021-08-25 15:12 ` Juan Quintela
2021-08-20 14:20 ` [RFC PATCH v2 7/8] pci: automatically unplug a PCI card before migration Laurent Vivier
2021-08-20 14:20 ` [RFC PATCH v2 8/8] failover: qemu-opts: manage hidden device list Laurent Vivier
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=20210820142002.152994-3-lvivier@redhat.com \
--to=lvivier@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jasowang@redhat.com \
--cc=jfreimann@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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.