vhost-user: fix watcher need be removed when vhost-user hotplug
commit41d4e5ec9f77acaca706d00ee4baaf5324274da5
authorYunjian Wang <wangyunjian@huawei.com>
Fri, 28 Jul 2017 01:50:53 +0000 (28 09:50 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 1 Aug 2017 21:13:26 +0000 (2 00:13 +0300)
treefb022fc415cd2e212a0d91148c09a72f0970f7d7
parent91c38e08af93d7d9df5636e4d7747ce3eb7ff1fc
vhost-user: fix watcher need be removed when vhost-user hotplug

"nc" is freed after hotplug vhost-user, but the watcher is not removed.
The QEMU crash when the watcher access the "nc" when socket disconnects.

    Program received signal SIGSEGV, Segmentation fault.
    #0  object_get_class (obj=obj@entry=0x2) at qom/object.c:750
    #1  0x00007f9bb4180da1 in qemu_chr_fe_disconnect (be=<optimized out>) at chardev/char-fe.c:372
    #2  0x00007f9bb40d1100 in net_vhost_user_watch (chan=<optimized out>, cond=<optimized out>, opaque=<optimized out>) at net/vhost-user.c:188
    #3  0x00007f9baf97f99a in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
    #4  0x00007f9bb41d7ebc in glib_pollfds_poll () at util/main-loop.c:213
    #5  os_host_main_loop_wait (timeout=<optimized out>) at util/main-loop.c:261
    #6  main_loop_wait (nonblocking=nonblocking@entry=0) at util/main-loop.c:515
    #7  0x00007f9bb3e266a7 in main_loop () at vl.c:1917
    #8  main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4786

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
net/vhost-user.c