diff options
author | Juan Quintela | 2020-11-18 09:37:35 +0100 |
---|---|---|
committer | Michael S. Tsirkin | 2020-12-08 19:48:57 +0100 |
commit | 7cf05b7ed8e84e89b873701e3dfcd56aa81b2d13 (patch) | |
tree | 74ec70be84747fe92260942e9be730bacc34f296 /hw | |
parent | failover: Remove memory leak (diff) | |
download | qemu-7cf05b7ed8e84e89b873701e3dfcd56aa81b2d13.tar.gz qemu-7cf05b7ed8e84e89b873701e3dfcd56aa81b2d13.tar.xz qemu-7cf05b7ed8e84e89b873701e3dfcd56aa81b2d13.zip |
failover: simplify virtio_net_find_primary()
a - is_my_primary() never sets one error
b - If we return 1, primary_device_id is always set
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-15-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/net/virtio-net.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 70fa372c08..881907d1bd 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -828,24 +828,12 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp) static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp) { - DeviceState *dev = NULL; Error *err = NULL; - if (qemu_opts_foreach(qemu_find_opts("device"), - is_my_primary, n, &err)) { - if (err) { - error_propagate(errp, err); - return NULL; - } - if (n->primary_device_id) { - dev = qdev_find_recursive(sysbus_get_default(), - n->primary_device_id); - } else { - error_setg(errp, "Primary device id not found"); - return NULL; - } + if (!qemu_opts_foreach(qemu_find_opts("device"), is_my_primary, n, &err)) { + return NULL; } - return dev; + return qdev_find_recursive(sysbus_get_default(), n->primary_device_id); } static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp) |