[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/66] failover: simplify failover_unplug_primary
From: |
Michael S. Tsirkin |
Subject: |
[PULL 41/66] failover: simplify failover_unplug_primary |
Date: |
Tue, 8 Dec 2020 14:36:00 -0500 |
From: Juan Quintela <quintela@redhat.com>
We can calculate device just once.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-27-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 | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b37e9cd1d9..9203d81780 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3146,34 +3146,29 @@ out:
return !err;
}
-static void virtio_net_handle_migration_primary(VirtIONet *n,
- MigrationState *s)
+static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState
*s)
{
bool should_be_hidden;
Error *err = NULL;
+ DeviceState *dev = failover_find_primary_device(n);
+
+ if (!dev) {
+ return;
+ }
should_be_hidden = qatomic_read(&n->failover_primary_hidden);
- if (!n->primary_dev) {
- n->primary_dev = failover_find_primary_device(n);
- if (!n->primary_dev) {
- return;
- }
- }
-
if (migration_in_setup(s) && !should_be_hidden) {
- if (failover_unplug_primary(n, n->primary_dev)) {
- vmstate_unregister(VMSTATE_IF(n->primary_dev),
- qdev_get_vmsd(n->primary_dev),
- n->primary_dev);
- qapi_event_send_unplug_primary(n->primary_dev->id);
+ if (failover_unplug_primary(n, dev)) {
+ vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+ qapi_event_send_unplug_primary(dev->id);
qatomic_set(&n->failover_primary_hidden, true);
} else {
warn_report("couldn't unplug primary device");
}
} else if (migration_has_failed(s)) {
/* We already unplugged the device let's plug it back */
- if (!failover_replug_primary(n, n->primary_dev, &err)) {
+ if (!failover_replug_primary(n, dev, &err)) {
if (err) {
error_report_err(err);
}
--
MST
- [PULL 58/66] x86: acpi: introduce AcpiPmInfo::smi_on_cpu_unplug, (continued)
- [PULL 58/66] x86: acpi: introduce AcpiPmInfo::smi_on_cpu_unplug, Michael S. Tsirkin, 2020/12/08
- [PULL 56/66] hw/i386/pc: add max combined fw size as machine configuration option, Michael S. Tsirkin, 2020/12/08
- [PULL 59/66] tests/acpi: allow expected files change, Michael S. Tsirkin, 2020/12/08
- [PULL 62/66] x86: ich9: factor out "guest_cpu_hotplug_features", Michael S. Tsirkin, 2020/12/08
- [PULL 61/66] tests/acpi: update expected files, Michael S. Tsirkin, 2020/12/08
- [PULL 63/66] x86: ich9: let firmware negotiate 'CPU hot-unplug with SMI' feature, Michael S. Tsirkin, 2020/12/08
- [PULL 64/66] pcie_aer: Fix help message of pcie_aer_inject_error command, Michael S. Tsirkin, 2020/12/08
- [PULL 65/66] hw/virtio-pci Added counter for pcie capabilities offsets., Michael S. Tsirkin, 2020/12/08
- [PULL 66/66] hw/virtio-pci Added AER capability., Michael S. Tsirkin, 2020/12/08
- [PULL 60/66] x86: acpi: let the firmware handle pending "CPU remove" events in SMM, Michael S. Tsirkin, 2020/12/08
- [PULL 41/66] failover: simplify failover_unplug_primary,
Michael S. Tsirkin <=
- [PULL 57/66] acpi: cpuhp: introduce 'firmware performs eject' status/control bits, Michael S. Tsirkin, 2020/12/08
- Re: [PULL 00/66] pc,pci,virtio: fixes, cleanups, Philippe Mathieu-Daudé, 2020/12/08
- Re: [PULL 00/66] pc,pci,virtio: fixes, cleanups, Peter Maydell, 2020/12/09