[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 40/66] failover: Caller of this two functions already have primary
From: |
Michael S. Tsirkin |
Subject: |
[PULL 40/66] failover: Caller of this two functions already have primary_dev |
Date: |
Tue, 8 Dec 2020 14:35:55 -0500 |
From: Juan Quintela <quintela@redhat.com>
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>
---
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);
}
--
MST
- [PULL 30/66] failover: should_be_hidden() should take a bool, (continued)
- [PULL 30/66] failover: should_be_hidden() should take a bool, Michael S. Tsirkin, 2020/12/08
- [PULL 32/66] failover: virtio_net_connect_failover_devices() does nothing, Michael S. Tsirkin, 2020/12/08
- [PULL 31/66] failover: Rename function to hide_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 33/66] failover: Rename to failover_find_primary_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 34/66] failover: simplify qdev_device_add() failover case, Michael S. Tsirkin, 2020/12/08
- [PULL 37/66] failover: remove failover_find_primary_device() error parameter, Michael S. Tsirkin, 2020/12/08
- [PULL 36/66] failover: make sure that id always exist, Michael S. Tsirkin, 2020/12/08
- [PULL 35/66] failover: simplify qdev_device_add(), Michael S. Tsirkin, 2020/12/08
- [PULL 38/66] failover: split failover_find_primary_device_id(), Michael S. Tsirkin, 2020/12/08
- [PULL 39/66] failover: We don't need to cache primary_device_id anymore, Michael S. Tsirkin, 2020/12/08
- [PULL 40/66] failover: Caller of this two functions already have primary_dev,
Michael S. Tsirkin <=
- [PULL 42/66] failover: Remove primary_dev member, Michael S. Tsirkin, 2020/12/08
- [PULL 43/66] hw: add compat machines for 6.0, Michael S. Tsirkin, 2020/12/08
- [PULL 44/66] libvhost-user: replace qemu/bswap.h with glibc endian.h, Michael S. Tsirkin, 2020/12/08
- [PULL 47/66] libvhost-user: drop qemu/osdep.h dependency, Michael S. Tsirkin, 2020/12/08
- [PULL 45/66] libvhost-user: replace qemu/memfd.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 46/66] libvhost-user: remove qemu/compiler.h usage, Michael S. Tsirkin, 2020/12/08
- [PULL 48/66] libvhost-user: make it a meson subproject, Michael S. Tsirkin, 2020/12/08
- [PULL 50/66] libvhost-user: add a simple link test without glib, Michael S. Tsirkin, 2020/12/08
- [PULL 51/66] .gitlab-ci: add build-libvhost-user, Michael S. Tsirkin, 2020/12/08
- [PULL 52/66] contrib/vhost-user-blk: avoid g_return_val_if() input validation, Michael S. Tsirkin, 2020/12/08