]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
xen-platform: Cleanup network infrastructure when emulated NICs are unplugged
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Fri, 30 Jun 2017 12:50:28 +0000 (13:50 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 7 Jul 2017 18:11:12 +0000 (11:11 -0700)
When the guest unplugs the emulated NICs, cleanup the peer for each NIC
as it is not needed anymore. Most importantly, this allows the tap
interfaces which QEMU holds open to be closed and removed.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
hw/i386/xen/xen_platform.c

index 1419fc96d2f2aaed9c8cd23231ebb997c4189053..f23155832b645656b4438508064a95ae04a78875 100644 (file)
@@ -102,8 +102,19 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
     }
 }
 
+/* Remove the peer of the NIC device. Normally, this would be a tap device. */
+static void del_nic_peer(NICState *nic, void *opaque)
+{
+    NetClientState *nc;
+
+    nc = qemu_get_queue(nic);
+    if (nc->peer)
+        qemu_del_net_client(nc->peer);
+}
+
 static void pci_unplug_nics(PCIBus *bus)
 {
+    qemu_foreach_nic(del_nic_peer, NULL);
     pci_for_each_device(bus, 0, unplug_nic, NULL);
 }