[Qemu-devel] [PATCH] xen-platform: Cleanup network infrastructure when emulated NICs are unplugged

Ross Lagerwall posted 1 patch 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170619081945.30001-1-ross.lagerwall@citrix.com
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
There is a newer version of this series
hw/i386/xen/xen_platform.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] xen-platform: Cleanup network infrastructure when emulated NICs are unplugged
Posted by Ross Lagerwall 6 years, 10 months ago
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.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 hw/i386/xen/xen_platform.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 1419fc9..180abc7 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -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)
-- 
2.9.4


Re: [Qemu-devel] [PATCH] xen-platform: Cleanup network infrastructure when emulated NICs are unplugged
Posted by Anthony PERARD 6 years, 10 months ago
On Mon, Jun 19, 2017 at 09:19:45AM +0100, Ross Lagerwall wrote:
> 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.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  hw/i386/xen/xen_platform.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
> index 1419fc9..180abc7 100644
> --- a/hw/i386/xen/xen_platform.c
> +++ b/hw/i386/xen/xen_platform.c
> @@ -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.

-- 
Anthony PERARD