virtio-net: fix removal of failover device

If you have a networking device and its virtio failover device, and
you remove them in this order:
- virtio device
- the real device

You get qemu crash.
See bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1820120

Bug exist on qemu 4.2 and 5.0.
But in 5.0 don't shows because commit
77b06bba62

somehow papers over it.

CC: Jason Wang <jasowang@redhat.com>
CC: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
Juan Quintela 2020-07-03 13:48:13 +02:00 committed by Jason Wang
parent 673205379f
commit 650181007a

View File

@ -3416,6 +3416,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)
g_free(n->vlans); g_free(n->vlans);
if (n->failover) { if (n->failover) {
device_listener_unregister(&n->primary_listener);
g_free(n->primary_device_id); g_free(n->primary_device_id);
g_free(n->standby_id); g_free(n->standby_id);
qobject_unref(n->primary_device_dict); qobject_unref(n->primary_device_dict);