diff mbox

[4/9] filter: remove filter before remove network backend

Message ID 1437735359-17415-5-git-send-email-yanghy@cn.fujitsu.com
State New
Headers show

Commit Message

Yang Hongyang July 24, 2015, 10:55 a.m. UTC
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
---
 net/net.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/net/net.c b/net/net.c
index c273981..321362f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -385,9 +385,20 @@  void qemu_del_net_client(NetClientState *nc)
 {
     NetClientState *ncs[MAX_QUEUE_NUM];
     int queues, i;
+    QemuOpts *opts;
 
     assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
 
+    if (nc->peer &&
+        nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_FILTER) {
+        opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL),
+                              nc->peer->name);
+        assert(opts);
+
+        qemu_del_net_client(nc->peer);
+        qemu_opts_del(opts);
+    }
+
     /* If the NetClientState belongs to a multiqueue backend, we will change all
      * other NetClientStates also.
      */