From: Stefano Stabellini <sstabellini@kernel.org>
To: peter.maydell@linaro.org, stefanha@gmail.com
Cc: sstabellini@kernel.org, qemu-devel@nongnu.org,
Ross Lagerwall <ross.lagerwall@citrix.com>,
stefanha@redhat.com, anthony.perard@citrix.com,
xen-devel@lists.xenproject.org
Subject: [PULL 2/3] xen-platform: Cleanup network infrastructure when emulated NICs are unplugged
Date: Fri, 7 Jul 2017 11:30:03 -0700 [thread overview]
Message-ID: <1499452204-20769-2-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <1499452204-20769-1-git-send-email-sstabellini@kernel.org>
From: Ross Lagerwall <ross.lagerwall@citrix.com>
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 | 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);
}
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-07 18:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 18:29 [PULL 0/3] please pull xen-20170707-tag Stefano Stabellini
2017-07-07 18:30 ` [PULL 1/3] xenfb: remove xen_init_display "temporary" hack Stefano Stabellini
2017-07-07 18:30 ` Stefano Stabellini [this message]
2017-07-07 18:30 ` [PULL 3/3] xen/pt: Fixup addr validation in xen_pt_pci_config_access_check Stefano Stabellini
2017-07-10 11:11 ` [PULL 0/3] please pull xen-20170707-tag Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499452204-20769-2-git-send-email-sstabellini@kernel.org \
--to=sstabellini@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=ross.lagerwall@citrix.com \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).