qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-stable] [PATCH 110/113] vhost-user: delete net client if necessary


From: Michael Roth
Subject: [Qemu-stable] [PATCH 110/113] vhost-user: delete net client if necessary
Date: Mon, 18 Jun 2018 20:43:16 -0500

From: linzhecheng <address@hidden>

As qemu_new_net_client create new ncs but error happens later,
ncs will be left in global net_clients list and we can't use them any
more, so we need to cleanup them.

Cc: address@hidden
Signed-off-by: linzhecheng <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
(cherry picked from commit c67daf4a24442d1bb404a11a6a54dc45ea10f234)
 Conflicts:
        net/vhost-user.c
* drop functional dep on 4d0cf552
Signed-off-by: Michael Roth <address@hidden>
---
 net/vhost-user.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index c23927c912..d2015e30b6 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -296,7 +296,7 @@ static int net_vhost_user_init(NetClientState *peer, const 
char *device,
             s = DO_UPCAST(VhostUserState, nc, nc);
             if (!qemu_chr_fe_init(&s->chr, chr, &err)) {
                 error_report_err(err);
-                return -1;
+                goto err;
             }
         }
 
@@ -306,7 +306,7 @@ static int net_vhost_user_init(NetClientState *peer, const 
char *device,
     do {
         if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) {
             error_report_err(err);
-            return -1;
+            goto err;
         }
         qemu_chr_fe_set_handlers(&s->chr, NULL, NULL,
                                  net_vhost_user_event, NULL, nc0->name, NULL,
@@ -316,6 +316,13 @@ static int net_vhost_user_init(NetClientState *peer, const 
char *device,
     assert(s->vhost_net);
 
     return 0;
+
+err:
+    if (nc0) {
+        qemu_del_net_client(nc0);
+    }
+
+    return -1;
 }
 
 static Chardev *net_vhost_claim_chardev(
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]