Received: from eggs.gnu.org ([2001:4830:134:3::10]:42964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeN-00012f-7x for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIaeM-00005b-A6 for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:23 -0400 Received: from [59.151.112.132] (port=27135 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeL-0008U7-3V for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:22 -0400 From: Yang Hongyang Date: Fri, 24 Jul 2015 18:55:53 +0800 Message-ID: <1437735359-17415-4-git-send-email-yanghy@cn.fujitsu.com> In-Reply-To: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> References: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 3/9] filter: remove plugins when remove filter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mrhines@linux.vnet.ibm.com, thuth@redhat.com, stefanha@redhat.com, Yang Hongyang Signed-off-by: Yang Hongyang --- net/filter.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/filter.c b/net/filter.c index 89ee830..7ef7bee 100644 --- a/net/filter.c +++ b/net/filter.c @@ -11,6 +11,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" #include "net/filter.h" +#include "qemu/config-file.h" typedef struct FilterPlugin FilterPlugin; struct FilterPlugin { @@ -81,6 +82,19 @@ out: static void filter_cleanup(NetClientState *nc) { FILTERState *s = DO_UPCAST(FILTERState, nc, nc); + NetClientState *plugin = NULL; + FilterPlugin *plug = NULL, *next = NULL; + QemuOpts *opts; + + QLIST_FOREACH_SAFE(plug, &s->plugins, next, next) { + plugin = plug->plugin; + opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), + plugin->name); + assert(opts); + + qemu_del_net_client(plugin); + qemu_opts_del(opts); + } if (s->backend && nc->peer) { qemu_flush_queued_packets(nc); -- 1.9.1