qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yunjian Wang <wangyunjian@huawei.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, jasowang@redhat.com, caihe@huawei.com,
	w00273186 <wangyunjian@huawei.com>
Subject: [Qemu-devel] [PATCH] vhost-user: fix watcher need be removed when vhost-user hotplug
Date: Tue, 9 May 2017 22:03:06 +0800	[thread overview]
Message-ID: <1494338586-13416-1-git-send-email-wangyunjian@huawei.com> (raw)

From: w00273186 <wangyunjian@huawei.com>

"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

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 net/vhost-user.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/vhost-user.c b/net/vhost-user.c
index 00a0c1c..5cc2178 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -155,6 +155,10 @@ static void vhost_user_cleanup(NetClientState *nc)
 
         qemu_chr_fe_deinit(&s->chr);
         object_unparent(OBJECT(chr));
+        if (s->watch) {
+            g_source_remove(s->watch);
+            s->watch = 0;
+        }
     }
 
     qemu_purge_queued_packets(nc);
-- 
1.8.3.1

             reply	other threads:[~2017-05-09 14:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 14:03 Yunjian Wang [this message]
2017-05-09 14:25 ` [Qemu-devel] [PATCH] vhost-user: fix watcher need be removed when vhost-user hotplug Marc-André Lureau
2017-05-10  1:54   ` wangyunjian
2017-05-25 15:32     ` Marc-André Lureau
  -- strict thread matches above, loose matches on Subject: below --
2017-07-21  5:16 w00273186
2017-07-21 11:19 ` Marc-André Lureau
2017-07-22  0:34   ` Michael S. Tsirkin
2017-07-22  9:24     ` Marc-André Lureau
2017-07-23  2:12       ` Michael S. Tsirkin
2017-07-23 10:06         ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494338586-13416-1-git-send-email-wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=caihe@huawei.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).