Received: from eggs.gnu.org ([2001:4830:134:3::10]:41720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTVFx-0003tA-2q for qemu-devel@nongnu.org; Fri, 07 Jul 2017 11:33:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTVFt-0003Rk-Qf for qemu-devel@nongnu.org; Fri, 07 Jul 2017 11:33:20 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:9660) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTVFt-0003Pc-KC for qemu-devel@nongnu.org; Fri, 07 Jul 2017 11:33:17 -0400 Date: Fri, 7 Jul 2017 16:33:13 +0100 From: Anthony PERARD Message-ID: <20170707153312.GB1609@perard.uk.xensource.com> References: <20170630125028.30265-1-ross.lagerwall@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170630125028.30265-1-ross.lagerwall@citrix.com> Subject: Re: [Qemu-devel] [PATCH v2] xen-platform: Cleanup network infrastructure when emulated NICs are unplugged List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ross Lagerwall Cc: qemu-devel@nongnu.org, Stefano Stabellini , "Michael S. Tsirkin" , Paolo Bonzini , Richard Henderson , Eduardo Habkost On Fri, Jun 30, 2017 at 01:50:28PM +0100, Ross Lagerwall wrote: > 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 > --- > > In v2: Don't call nic_cleanup(), just remove the peer of the NIC which > will cleanup up the tap devices. This means that QEMU doesn't segv > when shutting down. > > hw/i386/xen/xen_platform.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c > index 1419fc9..f231558 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); I don't know if it a good idee to clean every NIC (using qemu_foreach_nic) vs only clean NIC that have a PCI device (having unplug_nic cleanup the peer). But I cannot think of a scenario with xen where a nic is not also a pci device. Anyway, this patch works: Acked-by: Anthony PERARD -- Anthony PERARD