net/virtio: fix re-plugging of primary device
failover_replug_primary was returning true on failure which lead to
re-plug not working when a migration failed. Fix this by returning
success when hotplug worked. This is a bug that was missed in last
round of testing but was tested succesfully with this version. Also
make sure we don't pass NULL to qdev_set_parent_bus().
This fixes CID 1407224.
Fixes: 9711cd0dfc
("net/virtio: add failover support")
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
117378bf03
commit
150ab54aa6
|
@ -2805,10 +2805,20 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
|
|||
n->primary_device_opts = qemu_opts_from_qdict(
|
||||
qemu_find_opts("device"),
|
||||
n->primary_device_dict, errp);
|
||||
if (!n->primary_device_opts) {
|
||||
error_setg(errp, "virtio_net: couldn't find primary device opts");
|
||||
goto out;
|
||||
}
|
||||
if (n->primary_device_opts) {
|
||||
if (n->primary_dev) {
|
||||
}
|
||||
if (!n->primary_dev) {
|
||||
error_setg(errp, "virtio_net: couldn't find primary device");
|
||||
goto out;
|
||||
}
|
||||
|
||||
n->primary_bus = n->primary_dev->parent_bus;
|
||||
if (!n->primary_bus) {
|
||||
error_setg(errp, "virtio_net: couldn't find primary bus");
|
||||
goto out;
|
||||
}
|
||||
qdev_set_parent_bus(n->primary_dev, n->primary_bus);
|
||||
n->primary_should_be_hidden = false;
|
||||
|
@ -2819,11 +2829,9 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
|
|||
hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, errp);
|
||||
hotplug_handler_plug(hotplug_ctrl, n->primary_dev, errp);
|
||||
}
|
||||
if (!n->primary_dev) {
|
||||
error_setg(errp, "virtio_net: couldn't find primary device");
|
||||
}
|
||||
}
|
||||
return *errp != NULL;
|
||||
|
||||
out:
|
||||
return *errp == NULL;
|
||||
}
|
||||
|
||||
static void virtio_net_handle_migration_primary(VirtIONet *n,
|
||||
|
@ -2852,7 +2860,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
|
|||
warn_report("couldn't unplug primary device");
|
||||
}
|
||||
} else if (migration_has_failed(s)) {
|
||||
/* We already unplugged the device let's plugged it back */
|
||||
/* We already unplugged the device let's plug it back */
|
||||
if (!failover_replug_primary(n, &err)) {
|
||||
if (err) {
|
||||
error_report_err(err);
|
||||
|
|
Loading…
Reference in a new issue