[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/66] failover: simplify virtio_net_find_primary()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 29/66] failover: simplify virtio_net_find_primary() |
Date: |
Tue, 8 Dec 2020 14:35:11 -0500 |
From: Juan Quintela <quintela@redhat.com>
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>
---
hw/net/virtio-net.c | 18 +++---------------
1 file 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)
--
MST
- [PULL 22/66] failover: qdev_device_add() returns err or dev set, (continued)
- [PULL 22/66] failover: qdev_device_add() returns err or dev set, Michael S. Tsirkin, 2020/12/08
- [PULL 24/66] failover: g_strcmp0() knows how to handle NULL, Michael S. Tsirkin, 2020/12/08
- [PULL 25/66] failover: Remove primary_device_opts, Michael S. Tsirkin, 2020/12/08
- [PULL 16/66] unit-test: Add the binary file and clear diff.h, Michael S. Tsirkin, 2020/12/08
- [PULL 19/66] failover: primary bus is only used once, and where it is set, Michael S. Tsirkin, 2020/12/08
- [PULL 21/66] failover: Remove external partially_hotplugged property, Michael S. Tsirkin, 2020/12/08
- [PULL 20/66] failover: Remove unused parameter, Michael S. Tsirkin, 2020/12/08
- [PULL 26/66] failover: remove standby_id variable, Michael S. Tsirkin, 2020/12/08
- [PULL 27/66] failover: Remove primary_device_dict, Michael S. Tsirkin, 2020/12/08
- [PULL 23/66] failover: Rename bool to failover_primary_hidden, Michael S. Tsirkin, 2020/12/08
- [PULL 29/66] failover: simplify virtio_net_find_primary(),
Michael S. Tsirkin <=
- [PULL 28/66] failover: Remove memory leak, Michael S. Tsirkin, 2020/12/08
- [PULL 30/66] failover: should_be_hidden() should take a bool, Michael S. Tsirkin, 2020/12/08
- [PULL 32/66] failover: virtio_net_connect_failover_devices() does nothing, Michael S. Tsirkin, 2020/12/08
- [PULL 31/66] failover: Rename function to hide_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 33/66] failover: Rename to failover_find_primary_device(), Michael S. Tsirkin, 2020/12/08
- [PULL 34/66] failover: simplify qdev_device_add() failover case, Michael S. Tsirkin, 2020/12/08
- [PULL 37/66] failover: remove failover_find_primary_device() error parameter, Michael S. Tsirkin, 2020/12/08
- [PULL 36/66] failover: make sure that id always exist, Michael S. Tsirkin, 2020/12/08
- [PULL 35/66] failover: simplify qdev_device_add(), Michael S. Tsirkin, 2020/12/08
- [PULL 38/66] failover: split failover_find_primary_device_id(), Michael S. Tsirkin, 2020/12/08