qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

vhost-user: delete net client if necessary

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 c67daf4a24442d1bb404a11a6a54dc45ea10f234)
Conflicts:
net/vhost-user.c
* drop functional dep on 4d0cf552
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

linzhecheng and committed by
Michael Roth
fb7f173c 2f2b1892

+9 -2
+9 -2
net/vhost-user.c
··· 299 299 s = DO_UPCAST(VhostUserState, nc, nc); 300 300 if (!qemu_chr_fe_init(&s->chr, chr, &err)) { 301 301 error_report_err(err); 302 - return -1; 302 + goto err; 303 303 } 304 304 } 305 305 ··· 309 309 do { 310 310 if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) { 311 311 error_report_err(err); 312 - return -1; 312 + goto err; 313 313 } 314 314 qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, 315 315 net_vhost_user_event, NULL, nc0->name, NULL, ··· 319 319 assert(s->vhost_net); 320 320 321 321 return 0; 322 + 323 + err: 324 + if (nc0) { 325 + qemu_del_net_client(nc0); 326 + } 327 + 328 + return -1; 322 329 } 323 330 324 331 static Chardev *net_vhost_claim_chardev(