From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db2kS-0007ck-Jh for qemu-devel@nongnu.org; Fri, 28 Jul 2017 06:44:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1db2kP-000716-Tw for qemu-devel@nongnu.org; Fri, 28 Jul 2017 06:44:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1db2kP-0006yY-Kb for qemu-devel@nongnu.org; Fri, 28 Jul 2017 06:43:57 -0400 Date: Fri, 28 Jul 2017 06:38:04 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <141699272.61445461.1501238284350.JavaMail.zimbra@redhat.com> In-Reply-To: <1501206653-10704-1-git-send-email-wangyunjian@huawei.com> References: <1501206653-10704-1-git-send-email-wangyunjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3] vhost-user: fix watcher need be removed when vhost-user hotplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: w00273186 Cc: qemu-devel@nongnu.org, jasowang@redhat.com, mst@redhat.com, caihe@huawei.com ----- Original Message ----- > From: Yunjian Wang >=20 > "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. >=20 > Program received signal SIGSEGV, Segmentation fault. > #0 object_get_class (obj=3Dobj@entry=3D0x2) at qom/object.c:750 > #1 0x00007f9bb4180da1 in qemu_chr_fe_disconnect (be=3D) at > chardev/char-fe.c:372 > #2 0x00007f9bb40d1100 in net_vhost_user_watch (chan=3D, > cond=3D, opaque=3D) 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:21= 3 > #5 os_host_main_loop_wait (timeout=3D) at > util/main-loop.c:261 > #6 main_loop_wait (nonblocking=3Dnonblocking@entry=3D0) at > util/main-loop.c:515 > #7 0x00007f9bb3e266a7 in main_loop () at vl.c:1917 > #8 main (argc=3D, argv=3D, envp=3D out>) at vl.c:4786 >=20 > Signed-off-by: Yunjian Wang Reviewed-by: Marc-Andr=C3=A9 Lureau > --- > v3: > -fix conflicts with current master. >=20 > v2: > -move the chunk before deinit. >=20 > ps: > reproduce steps: > 1. virsh attach-device vm0 vhost-user.xml > 2. virsh detach-device vm0 vhost-user.xml > 3. virsh attach-device vm0 vhost-user.xml > 4. service openvswitch restart > 5. repeat step 2~4 >=20 > the vhost-user xml: > > > > > > > --- > net/vhost-user.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/net/vhost-user.c b/net/vhost-user.c > index 36f32a2..c23927c 100644 > --- a/net/vhost-user.c > +++ b/net/vhost-user.c > @@ -151,6 +151,10 @@ static void vhost_user_cleanup(NetClientState *nc) > s->vhost_net =3D NULL; > } > if (nc->queue_index =3D=3D 0) { > + if (s->watch) { > + g_source_remove(s->watch); > + s->watch =3D 0; > + } > qemu_chr_fe_deinit(&s->chr, true); > } > =20 > -- > 1.8.3.1 >=20 >=20 >=20