From 4f0303aed87f83715055e558176046a8a3d9b987 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 18 Nov 2020 09:37:32 +0100 Subject: failover: remove standby_id variable We can calculate it, and we only use it once anyways. Signed-off-by: Juan Quintela Message-Id: <20201118083748.1328-12-quintela@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'hw') diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2a99b0e..953d5c2 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; } -- cgit v1.1