[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 26/27] failover: simplify failover_unplug_primary
From: |
Juan Quintela |
Subject: |
[PATCH v2 26/27] failover: simplify failover_unplug_primary |
Date: |
Wed, 18 Nov 2020 09:37:47 +0100 |
We can calculate device just once.
Signed-off-by: Juan Quintela <quintela@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);
}
--
2.26.2
- [PATCH v2 17/27] failover: virtio_net_connect_failover_devices() does nothing, (continued)
- [PATCH v2 17/27] failover: virtio_net_connect_failover_devices() does nothing, Juan Quintela, 2020/11/18
- [PATCH v2 18/27] failover: Rename to failover_find_primary_device(), Juan Quintela, 2020/11/18
- [PATCH v2 19/27] failover: simplify qdev_device_add() failover case, Juan Quintela, 2020/11/18
- [PATCH v2 20/27] failover: simplify qdev_device_add(), Juan Quintela, 2020/11/18
- [PATCH v2 21/27] failover: make sure that id always exist, Juan Quintela, 2020/11/18
- [PATCH v2 22/27] failover: remove failover_find_primary_device() error parameter, Juan Quintela, 2020/11/18
- [PATCH v2 23/27] failover: split failover_find_primary_device_id(), Juan Quintela, 2020/11/18
- [PATCH v2 24/27] failover: We don't need to cache primary_device_id anymore, Juan Quintela, 2020/11/18
- [PATCH v2 25/27] failover: Caller of this two functions already have primary_dev, Juan Quintela, 2020/11/18
- [PATCH v2 27/27] failover: Remove primary_dev member, Juan Quintela, 2020/11/18
- [PATCH v2 26/27] failover: simplify failover_unplug_primary,
Juan Quintela <=
- Re: [PATCH v2 00/27] Virtio net failover fixes, Michael S. Tsirkin, 2020/11/18