[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/27] failover: remove standby_id variable
From: |
Juan Quintela |
Subject: |
[PATCH v2 11/27] failover: remove standby_id variable |
Date: |
Wed, 18 Nov 2020 09:37:32 +0100 |
We can calculate it, and we only use it once anyways.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
include/hw/virtio/virtio-net.h | 1 -
hw/net/virtio-net.c | 11 +++--------
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 7159e6c0a0..a055f39dd6 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -205,7 +205,6 @@ struct VirtIONet {
QDict *primary_device_dict;
DeviceState *primary_dev;
char *primary_device_id;
- char *standby_id;
/* primary failover device is hidden*/
bool failover_primary_hidden;
bool failover;
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2a99b0e0f6..953d5c2bc8 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3181,23 +3181,19 @@ static int
virtio_net_primary_should_be_hidden(DeviceListener *listener,
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
bool match_found = false;
bool hide = false;
+ const char *standby_id;
if (!device_opts) {
return -1;
}
n->primary_device_dict = qemu_opts_to_qdict(device_opts,
n->primary_device_dict);
- if (n->primary_device_dict) {
- g_free(n->standby_id);
- n->standby_id = g_strdup(qdict_get_try_str(n->primary_device_dict,
- "failover_pair_id"));
- }
- if (g_strcmp0(n->standby_id, n->netclient_name) == 0) {
+ standby_id = qemu_opt_get(device_opts, "failover_pair_id");
+ if (g_strcmp0(standby_id, n->netclient_name) == 0) {
match_found = true;
} else {
match_found = false;
hide = false;
- g_free(n->standby_id);
n->primary_device_dict = NULL;
goto out;
}
@@ -3400,7 +3396,6 @@ static void virtio_net_device_unrealize(DeviceState *dev)
if (n->failover) {
device_listener_unregister(&n->primary_listener);
g_free(n->primary_device_id);
- g_free(n->standby_id);
qobject_unref(n->primary_device_dict);
n->primary_device_dict = NULL;
}
--
2.26.2
- [PATCH v2 01/27] migration: Network Failover can't work with a paused guest, (continued)
- [PATCH v2 01/27] migration: Network Failover can't work with a paused guest, Juan Quintela, 2020/11/18
- [PATCH v2 02/27] failover: fix indentantion, Juan Quintela, 2020/11/18
- [PATCH v2 04/27] failover: primary bus is only used once, and where it is set, Juan Quintela, 2020/11/18
- [PATCH v2 03/27] failover: Use always atomics for primary_should_be_hidden, Juan Quintela, 2020/11/18
- [PATCH v2 05/27] failover: Remove unused parameter, Juan Quintela, 2020/11/18
- [PATCH v2 06/27] failover: Remove external partially_hotplugged property, Juan Quintela, 2020/11/18
- [PATCH v2 08/27] failover: Rename bool to failover_primary_hidden, Juan Quintela, 2020/11/18
- [PATCH v2 09/27] failover: g_strcmp0() knows how to handle NULL, Juan Quintela, 2020/11/18
- [PATCH v2 07/27] failover: qdev_device_add() returns err or dev set, Juan Quintela, 2020/11/18
- [PATCH v2 10/27] failover: Remove primary_device_opts, Juan Quintela, 2020/11/18
- [PATCH v2 11/27] failover: remove standby_id variable,
Juan Quintela <=
- [PATCH v2 13/27] failover: Remove memory leak, Juan Quintela, 2020/11/18
- [PATCH v2 12/27] failover: Remove primary_device_dict, Juan Quintela, 2020/11/18
- [PATCH v2 14/27] failover: simplify virtio_net_find_primary(), Juan Quintela, 2020/11/18
- [PATCH v2 15/27] failover: should_be_hidden() should take a bool, Juan Quintela, 2020/11/18
- [PATCH v2 16/27] failover: Rename function to hide_device(), Juan Quintela, 2020/11/18
- [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