mirror of https://github.com/xemu-project/xemu.git
failover: Caller of this two functions already have primary_dev
Pass it as an argument. Signed-off-by: Juan Quintela <quintela@redhat.com> Message-Id: <20201118083748.1328-26-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
3abad4a221
commit
0e9a65c5b1
|
@ -3093,17 +3093,17 @@ void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
|
|||
n->netclient_type = g_strdup(type);
|
||||
}
|
||||
|
||||
static bool failover_unplug_primary(VirtIONet *n)
|
||||
static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev)
|
||||
{
|
||||
HotplugHandler *hotplug_ctrl;
|
||||
PCIDevice *pci_dev;
|
||||
Error *err = NULL;
|
||||
|
||||
hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
|
||||
hotplug_ctrl = qdev_get_hotplug_handler(dev);
|
||||
if (hotplug_ctrl) {
|
||||
pci_dev = PCI_DEVICE(n->primary_dev);
|
||||
pci_dev = PCI_DEVICE(dev);
|
||||
pci_dev->partially_hotplugged = true;
|
||||
hotplug_handler_unplug_request(hotplug_ctrl, n->primary_dev, &err);
|
||||
hotplug_handler_unplug_request(hotplug_ctrl, dev, &err);
|
||||
if (err) {
|
||||
error_report_err(err);
|
||||
return false;
|
||||
|
@ -3114,30 +3114,31 @@ static bool failover_unplug_primary(VirtIONet *n)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool failover_replug_primary(VirtIONet *n, Error **errp)
|
||||
static bool failover_replug_primary(VirtIONet *n, DeviceState *dev,
|
||||
Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
HotplugHandler *hotplug_ctrl;
|
||||
PCIDevice *pdev = PCI_DEVICE(n->primary_dev);
|
||||
PCIDevice *pdev = PCI_DEVICE(dev);
|
||||
BusState *primary_bus;
|
||||
|
||||
if (!pdev->partially_hotplugged) {
|
||||
return true;
|
||||
}
|
||||
primary_bus = n->primary_dev->parent_bus;
|
||||
primary_bus = dev->parent_bus;
|
||||
if (!primary_bus) {
|
||||
error_setg(errp, "virtio_net: couldn't find primary bus");
|
||||
return false;
|
||||
}
|
||||
qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
|
||||
qdev_set_parent_bus(dev, primary_bus, &error_abort);
|
||||
qatomic_set(&n->failover_primary_hidden, false);
|
||||
hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
|
||||
hotplug_ctrl = qdev_get_hotplug_handler(dev);
|
||||
if (hotplug_ctrl) {
|
||||
hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err);
|
||||
hotplug_handler_pre_plug(hotplug_ctrl, dev, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
hotplug_handler_plug(hotplug_ctrl, n->primary_dev, &err);
|
||||
hotplug_handler_plug(hotplug_ctrl, dev, &err);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -3161,7 +3162,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
|
|||
}
|
||||
|
||||
if (migration_in_setup(s) && !should_be_hidden) {
|
||||
if (failover_unplug_primary(n)) {
|
||||
if (failover_unplug_primary(n, n->primary_dev)) {
|
||||
vmstate_unregister(VMSTATE_IF(n->primary_dev),
|
||||
qdev_get_vmsd(n->primary_dev),
|
||||
n->primary_dev);
|
||||
|
@ -3172,7 +3173,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
|
|||
}
|
||||
} else if (migration_has_failed(s)) {
|
||||
/* We already unplugged the device let's plug it back */
|
||||
if (!failover_replug_primary(n, &err)) {
|
||||
if (!failover_replug_primary(n, n->primary_dev, &err)) {
|
||||
if (err) {
|
||||
error_report_err(err);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue