Skip to content

Commit

Permalink
vhost-user: delete net client if necessary
Browse files Browse the repository at this point in the history
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: qemu-stable@nongnu.org
Signed-off-by: linzhecheng <linzhecheng@huawei.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit c67daf4)
 Conflicts:
	net/vhost-user.c
* drop functional dep on 4d0cf55
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
cheney-lin authored and mdroth committed Jun 21, 2018
1 parent f4e93bb commit d8a919f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions net/vhost-user.c
Expand Up @@ -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;
}
}

Expand All @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit d8a919f

Please sign in to comment.