aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorRoss Lagerwall <ross.lagerwall@citrix.com>2017-06-30 13:50:28 +0100
committerStefano Stabellini <sstabellini@kernel.org>2017-07-07 11:11:12 -0700
commit6c808651e327388c22845700e14fe103da9b37cd (patch)
tree852dbfbe6c1738a666f12f00603772181c691edb /hw
parent9f2130f58d5dd4e1fcb435cca08bf77e7c32e6c6 (diff)
xen-platform: Cleanup network infrastructure when emulated NICs are unplugged
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/i386/xen/xen_platform.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 1419fc96d2..f23155832b 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -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);
}