[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/66] failover: simplify qdev_device_add()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 35/66] failover: simplify qdev_device_add() |
Date: |
Tue, 8 Dec 2020 14:35:38 -0500 |
From: Juan Quintela <quintela@redhat.com>
We don't need to walk the opts by hand. qmp_opt_get() already does
that. And then we can remove the functions that did that walk.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-21-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
softmmu/qdev-monitor.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 12b7540f17..0e10f0466f 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -572,28 +572,6 @@ void qdev_set_id(DeviceState *dev, const char *id)
}
}
-static int is_failover_device(void *opaque, const char *name, const char
*value,
- Error **errp)
-{
- if (strcmp(name, "failover_pair_id") == 0) {
- QemuOpts *opts = opaque;
-
- if (qdev_should_hide_device(opts)) {
- return 1;
- }
- }
-
- return 0;
-}
-
-static bool should_hide_device(QemuOpts *opts)
-{
- if (qemu_opt_foreach(opts, is_failover_device, opts, NULL) == 0) {
- return false;
- }
- return true;
-}
-
DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
{
DeviceClass *dc;
@@ -634,11 +612,13 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
}
}
- if (should_hide_device(opts)) {
- if (bus && !qbus_is_hotpluggable(bus)) {
- error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ if (qemu_opt_get(opts, "failover_pair_id")) {
+ if (qdev_should_hide_device(opts)) {
+ if (bus && !qbus_is_hotpluggable(bus)) {
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ }
+ return NULL;
}
- return NULL;
}
if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
--
MST
- [PULL 23/66] failover: Rename bool to failover_primary_hidden, (continued)
- [PULL 23/66] failover: Rename bool to failover_primary_hidden, Michael S. Tsirkin, 2020/12/08
- [PULL 29/66] failover: simplify virtio_net_find_primary(), Michael S. Tsirkin, 2020/12/08
- [PULL 28/66] failover: Remove memory leak, Michael S. Tsirkin, 2020/12/08
- [PULL 30/66] failover: should_be_hidden() should take a bool, Michael S. Tsirkin, 2020/12/08
- [PULL 32/66] failover: virtio_net_connect_failover_devices() does nothing, Michael S. Tsirkin, 2020/12/08
- [PULL 31/66] failover: Rename function to hide_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 33/66] failover: Rename to failover_find_primary_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 34/66] failover: simplify qdev_device_add() failover case, Michael S. Tsirkin, 2020/12/08
- [PULL 37/66] failover: remove failover_find_primary_device() error parameter, Michael S. Tsirkin, 2020/12/08
- [PULL 36/66] failover: make sure that id always exist, Michael S. Tsirkin, 2020/12/08
- [PULL 35/66] failover: simplify qdev_device_add(),
Michael S. Tsirkin <=
- [PULL 38/66] failover: split failover_find_primary_device_id(), Michael S. Tsirkin, 2020/12/08
- [PULL 39/66] failover: We don't need to cache primary_device_id anymore, Michael S. Tsirkin, 2020/12/08
- [PULL 40/66] failover: Caller of this two functions already have primary_dev, Michael S. Tsirkin, 2020/12/08
- [PULL 42/66] failover: Remove primary_dev member, Michael S. Tsirkin, 2020/12/08
- [PULL 43/66] hw: add compat machines for 6.0, Michael S. Tsirkin, 2020/12/08
- [PULL 44/66] libvhost-user: replace qemu/bswap.h with glibc endian.h, Michael S. Tsirkin, 2020/12/08
- [PULL 47/66] libvhost-user: drop qemu/osdep.h dependency, Michael S. Tsirkin, 2020/12/08
- [PULL 45/66] libvhost-user: replace qemu/memfd.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 46/66] libvhost-user: remove qemu/compiler.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 48/66] libvhost-user: make it a meson subproject, Michael S. Tsirkin, 2020/12/08