mirror of https://github.com/xemu-project/xemu.git
failover: simplify qdev_device_add()
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>
This commit is contained in:
parent
5f2ef3b0d0
commit
2e28095369
|
@ -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)
|
DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
DeviceClass *dc;
|
DeviceClass *dc;
|
||||||
|
@ -634,11 +612,13 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_hide_device(opts)) {
|
if (qemu_opt_get(opts, "failover_pair_id")) {
|
||||||
if (bus && !qbus_is_hotpluggable(bus)) {
|
if (qdev_should_hide_device(opts)) {
|
||||||
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
|
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)) {
|
if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
|
||||||
|
|
Loading…
Reference in New Issue