OSDN Git Service

failover: really display a warning when the primary device is not found
authorLaurent Vivier <lvivier@redhat.com>
Fri, 12 Feb 2021 13:52:49 +0000 (14:52 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 23 Feb 2021 15:06:55 +0000 (10:06 -0500)
commit97ca9c5920362d5b7a9f96d4fa758e9f2ccb3301
tree1ec33248ff878487befec18d066415b1e2ebccc9
parent00e7b1299599384dfdda2a2a4570a0fb2d69eb6b
failover: really display a warning when the primary device is not found

In failover_add_primary(), we search the id of the failover device by
scanning the list of the devices in the opts list to find a device with
a failover_pair_id equals to the id of the virtio-net device.

If the failover_pair_id is not found, QEMU ignores the primary
device silently (which also means it will not be hidden and
it will be enabled directly at boot).

After that, we search the id in the opts list to do a qdev_device_add()
with it. The device will be always found as otherwise we had exited
before, and thus the warning is never displayed.

Fix that by moving the error report to the first exit condition.
Also add a g_assert() to be sure the compiler will not complain
about a possibly NULL pointer.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20210212135250.2738750-4-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/net/virtio-net.c