Skip to contentSkip to conversation

vhost-user: fix watcher need be removed when vhost-user hotplug

PATCH Superseded Yunjian Wang 2 participants 2 messages May 31, 2017 Networking

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vhost-user: fix watcher need be removed when vhost-user hotplug

From: w00273186 <[email protected]>

"nc" is freed after hotplug vhost-user, but the watcher don't be removed. The QEMU crash when the watcher access the "nc" on socket disconnect.

Call Trace:
    #0  object_get_class (obj=obj@entry=0x2) at qom/object.c:751
    #1  0x00007fc031c79f41 in qemu_chr_fe_disconnect (be=<optimized out>) at chardev/char.c:1048
    #2  0x00007fc031bd62e0 in net_vhost_user_watch (chan=<optimized out>, cond=<optimized out>, opaque=<optimized out>) at net/vhost-user.c:191
    #3  0x00007fc02c23e99a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
    #4  0x00007fc031ccfc0c 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:517
    #7  0x00007fc03193bc87 in main_loop () at vl.c:1899
    #8  main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4719
---
 net/vhost-user.c | 4 ++++
 1 file changed, 4 insertions(+)
net/vhost-user.c +4 -0
index 00a0c1c..8da314d 100644
@@ -153,6 +153,10 @@ static void vhost_user_cleanup(NetClientState *nc)
     if (nc->queue_index == 0) {
         Chardev *chr = qemu_chr_fe_get_driver(&s->chr);
 
+        if (s->watch) {
+            g_source_remove(s->watch);
+            s->watch = 0;
+        }
         qemu_chr_fe_deinit(&s->chr);
         object_unparent(OBJECT(chr));
     }
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 22 lines · Yunjian Wang

From: w00273186 <[email protected]>

"nc" is freed after hotplug vhost-user, but the watcher don't be removed. The QEMU crash when the watcher access the "nc" on socket disconnect.

Call Trace:
    #0  object_get_class (obj=obj@entry=0x2) at qom/object.c:751
    #1  0x00007fc031c79f41 in qemu_chr_fe_disconnect (be=<optimized out>)
at chardev/char.c:1048
    #2  0x00007fc031bd62e0 in net_vhost_user_watch (chan=<optimized out>,
cond=<optimized out>, opaque=<optimized out>) at net/vhost-user.c:191
    #3  0x00007fc02c23e99a in g_main_context_dispatch () from

/lib64/libglib-2.0.so.0
#4 0x00007fc031ccfc0c 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:517
#7 0x00007fc03193bc87 in main_loop () at vl.c:1899
#8 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized
out>) at vl.c:4719

Quoted 2 lines
Quoted 24 lines
---
 net/vhost-user.c | 4 ++++
 1 file changed, 4 insertions(+)
net/vhost-user.c +4 -1
index 00a0c1c..8da314d 100644
@@ -153,6 +153,10 @@ static void vhost_user_cleanup(NetClientState *nc)
     if (nc->queue_index == 0) {
         Chardev *chr = qemu_chr_fe_get_driver(&s->chr);
 
+        if (s->watch) {
+            g_source_remove(s->watch);
+            s->watch = 0;
+        }
         qemu_chr_fe_deinit(&s->chr);
         object_unparent(OBJECT(chr));
     }
--

1.8.3.1

Quoted 1 line

--

Marc-André Lureau