qemu-kvm/kvm-failover-Caller-of-this-two-functions-already-have-p.patch
2021-03-08 12:30:40 +01:00

122 lines
4.4 KiB
Diff

From 4f94bc7cc479dba60fba841608b3da74b940a26d Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:44 -0500
Subject: [PATCH 47/54] failover: Caller of this two functions already have
primary_dev
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-25-lvivier@redhat.com>
Patchwork-id: 101246
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 24/27] failover: Caller of this two functions already have primary_dev
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
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>
(cherry picked from commit 0e9a65c5b168b993b845ec2acb2568328c2353da)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 746ed3fb71..b37e9cd1d9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -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);
}
--
2.27.0