[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 41/65] failover: simplify failover_unplug_primary
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 41/65] failover: simplify failover_unplug_primary |
Date: |
Wed, 9 Dec 2020 13:09:44 -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 v2 31/65] failover: Rename function to hide_device(), (continued)
- [PULL v2 31/65] failover: Rename function to hide_device(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 32/65] failover: virtio_net_connect_failover_devices() does nothing, Michael S. Tsirkin, 2020/12/09
- [PULL v2 33/65] failover: Rename to failover_find_primary_device(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 34/65] failover: simplify qdev_device_add() failover case, Michael S. Tsirkin, 2020/12/09
- [PULL v2 35/65] failover: simplify qdev_device_add(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 36/65] failover: make sure that id always exist, Michael S. Tsirkin, 2020/12/09
- [PULL v2 38/65] failover: split failover_find_primary_device_id(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 39/65] failover: We don't need to cache primary_device_id anymore, Michael S. Tsirkin, 2020/12/09
- [PULL v2 40/65] failover: Caller of this two functions already have primary_dev, Michael S. Tsirkin, 2020/12/09
- [PULL v2 42/65] failover: Remove primary_dev member, Michael S. Tsirkin, 2020/12/09
- [PULL v2 41/65] failover: simplify failover_unplug_primary,
Michael S. Tsirkin <=
- [PULL v2 43/65] hw: add compat machines for 6.0, Michael S. Tsirkin, 2020/12/09
- [PULL v2 44/65] libvhost-user: replace qemu/bswap.h with glibc endian.h, Michael S. Tsirkin, 2020/12/09
- [PULL v2 45/65] libvhost-user: replace qemu/memfd.h usage, Michael S. Tsirkin, 2020/12/09
- [PULL v2 46/65] libvhost-user: remove qemu/compiler.h usage, Michael S. Tsirkin, 2020/12/09
- [PULL v2 47/65] libvhost-user: drop qemu/osdep.h dependency, Michael S. Tsirkin, 2020/12/09
- [PULL v2 48/65] libvhost-user: make it a meson subproject, Michael S. Tsirkin, 2020/12/09
- [PULL v2 49/65] libvhost-user: add a simple link test without glib, Michael S. Tsirkin, 2020/12/09