Skip to content

Commit

Permalink
qdev/qbus: remove failover specific code
Browse files Browse the repository at this point in the history
Commit f3a8505 ("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 <[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
  • Loading branch information
vivier authored and mstsirkin committed Oct 20, 2021
1 parent 515efff commit bcfc906
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
12 changes: 11 additions & 1 deletion hw/net/virtio-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -3299,7 +3299,17 @@ static bool failover_hide_primary_device(DeviceListener *listener,
if (!device_opts) {
return false;
}
standby_id = qdict_get_try_str(device_opts, "failover_pair_id");

if (!qdict_haskey(device_opts, "failover_pair_id")) {
return false;
}

if (!qdict_haskey(device_opts, "id")) {
error_setg(errp, "Device with failover_pair_id needs to have id");
return false;
}

standby_id = qdict_get_str(device_opts, "failover_pair_id");
if (g_strcmp0(standby_id, n->netclient_name) != 0) {
return false;
}
Expand Down
18 changes: 6 additions & 12 deletions softmmu/qdev-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,13 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
}
}

if (qdict_haskey(opts, "failover_pair_id")) {
if (!qdict_haskey(opts, "id")) {
error_setg(errp, "Device with failover_pair_id don't have id");
return NULL;
}
if (qdev_should_hide_device(opts, from_json, errp)) {
if (bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
}
return NULL;
} else if (*errp) {
return NULL;
if (qdev_should_hide_device(opts, from_json, errp)) {
if (bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
}
return NULL;
} else if (*errp) {
return NULL;
}

if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) {
Expand Down

0 comments on commit bcfc906

Please sign in to comment.