From patchwork Thu Sep 1 12:00:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Hanxiao X-Patchwork-Id: 664912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sQ1qz3rFgz9s2k for ; Thu, 1 Sep 2016 22:33:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.b=bMUjIO8e; dkim-atps=neutral Received: from localhost ([::1]:36844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfRAx-0003oY-4k for incoming@patchwork.ozlabs.org; Thu, 01 Sep 2016 08:32:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfRA9-0003RY-3c for qemu-devel@nongnu.org; Thu, 01 Sep 2016 08:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfRA2-0007lV-4y for qemu-devel@nongnu.org; Thu, 01 Sep 2016 08:32:08 -0400 Received: from m15-57.126.com ([220.181.15.57]:48951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfRA0-0007ka-SW for qemu-devel@nongnu.org; Thu, 01 Sep 2016 08:32:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=5kwdY QPjY//mPE6Ho4y0JnaGMhllBE6M3LvD8xHmwkk=; b=bMUjIO8eSDXUhuz5XQ+tt mrsTXZVMUfhSrX6Wy6MGjSKUSHQxIv7lLWag2INdIfxDSmSM7DQeL54BPE9Ei+4z B/tBCugTbTsP3jDRKKsgc0MUEoj1Zn8xEq3ronB1fFJ3u3f59mld1QgkQuIjpCrC 9tDbEmNVptQx+DzHsbeMc4= Received: from chen_han_xiao$126.com ( [58.213.111.46] ) by ajax-webmail-wmsvr57 (Coremail) ; Thu, 1 Sep 2016 20:00:13 +0800 (CST) X-Originating-IP: [58.213.111.46] Date: Thu, 1 Sep 2016 20:00:13 +0800 (CST) From: "Chen Hanxiao" To: =?GBK?Q?Marc-Andr=A8=A6_Lureau?= X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160420(83524.8626) Copyright (c) 2002-2016 www.mailtech.cn 126com In-Reply-To: References: <1472724830-15537-1-git-send-email-chen_han_xiao@126.com> MIME-Version: 1.0 Message-ID: <23505bd1.b7da.156e59eee00.Coremail.chen_han_xiao@126.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: OcqowABH991OGMhX7ZQeAA--.28435W X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi4xPXrlUw4ta6MQAEsX X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.15.57 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] vhost-user: return if no net clients found X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-devel@nongnu.org, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 在 2016-09-01 19:43:31,"Marc-André Lureau" 写道: Hi On Thu, Sep 1, 2016 at 2:15 PM Chen Hanxiao wrote: From: Chen Hanxiao If we can't find a suitable net client, return directly. Or we will got a segmentation fault. Signed-off-by: Chen Hanxiao --- net/vhost-user.c | 3 +++ 1 file changed, 3 insertions(+) qemu coding style has mandatory {} braces. I don't understand what this patch fixes. even if queues == 0, there is not reason I can think of it would crash. Could you provide a backtrace? A qemu-only reproducer would be really useful. Hi, here is the backtrace: #0 net_vhost_user_event (opaque=0x7fc2f6893be0, event=5) at net/vhost-user.c:196 #1 0x00007fc2f4ebfb2b in tcp_chr_disconnect (chr=0x7fc2f68cc400) at qemu-char.c:2837 #2 0x00007fc2f4ebfba9 in tcp_chr_sync_read (chr=0x7fc2f68cc400, buf=, len=) at qemu-char.c:2888 #3 0x00007fc2f4ec106d in qemu_chr_fe_read_all (s=0x7fc2f68cc400, buf=buf@entry=0x7fff5fda25b7 "", len=len@entry=1) at qemu-char.c:264 #4 0x00007fc2f4f9a43a in net_vhost_user_watch (chan=, cond=, opaque=) at net/vhost-user.c:190 #5 0x00007fc2f321999a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0 #6 0x00007fc2f4fd8fe8 in glib_pollfds_poll () at main-loop.c:209 #7 os_host_main_loop_wait (timeout=) at main-loop.c:254 #8 main_loop_wait (nonblocking=) at main-loop.c:503 #9 0x00007fc2f4dd7b1e in main_loop () at vl.c:1818 #10 main (argc=, argv=, envp=) at vl.c:4394 Program received signal SIGSEGV, Segmentation fault. net_vhost_user_event (opaque=0x7fc2f6893be0, event=5) at net/vhost-user.c:207 207 trace_vhost_user_event(s->chr->label, event); Regards, - Chen diff --git a/net/vhost-user.c b/net/vhost-user.c index b0595f8..fb96db7 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -210,6 +210,9 @@ static void net_vhost_user_event(void *opaque, int event) MAX_QUEUE_NUM); assert(queues < MAX_QUEUE_NUM); + if (queues < 1) + return; +