Skip to contentSkip to conversation

xen-platform: Cleanup network infrastructure when emulated NICs are unplugged

PATCH Superseded Ross Lagerwall 2 participants 2 messages Jun 19, 2017 – Jun 20, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-platform: Cleanup network infrastructure when emulated NICs are unplugged

When the guest unplugs the emulated NICs, call net_cleanup() to cleanup the network infrastructure in QEMU as it is not needed anymore. Most importantly, this allows the tap interfaces which QEMU holds open to be closed and removed.

---
 hw/i386/xen/xen_platform.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/xen/xen_platform.c +1 -0
index 1419fc9..180abc7 100644
@@ -105,6 +105,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 static void pci_unplug_nics(PCIBus *bus)
 {
     pci_for_each_device(bus, 0, unplug_nic, NULL);
+    net_cleanup();
 }
 
 static void unplug_disks(PCIBus *b, PCIDevice *d, void *opaque)
Signature · 1 line
2.9.4
#1 lore raw
Quoted 15 lines · Ross Lagerwall

When the guest unplugs the emulated NICs, call net_cleanup() to cleanup the network infrastructure in QEMU as it is not needed anymore. Most importantly, this allows the tap interfaces which QEMU holds open to be closed and removed.

---
 hw/i386/xen/xen_platform.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/xen/xen_platform.c +0 -0
index 1419fc9..180abc7 100644

hw/i386/xen/xen_platform.c static void unplug_nic(PCIBus *b, PCIDevice *d, void *o) · line 108

Quoted 4 lines
hw/i386/xen/xen_platform.c +1 -0
@@ -105,6 +105,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
 static void pci_unplug_nics(PCIBus *bus)
 {
     pci_for_each_device(bus, 0, unplug_nic, NULL);
+    net_cleanup();

This makes QEMU segv when QEMU is shutting down. When net_cleanup() is called a second time, qemu crash. That probably not a good sign, even if the guest continue to live after a reboot or a migration.

Signature · 1 line
Anthony PERARD