From patchwork Thu Jun 21 13:27:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 10479917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53795604D3 for ; Thu, 21 Jun 2018 13:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4246929224 for ; Thu, 21 Jun 2018 13:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 374152922F; Thu, 21 Jun 2018 13:28:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D301F29224 for ; Thu, 21 Jun 2018 13:28:16 +0000 (UTC) Received: from localhost ([::1]:55534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVzdI-0000K5-5Z for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jun 2018 09:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVzcc-0008Lh-0Q for qemu-devel@nongnu.org; Thu, 21 Jun 2018 09:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVzcX-0003lT-6h for qemu-devel@nongnu.org; Thu, 21 Jun 2018 09:27:34 -0400 Received: from mga05.intel.com ([192.55.52.43]:25660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVzcW-0003kT-Sg for qemu-devel@nongnu.org; Thu, 21 Jun 2018 09:27:29 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 06:27:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,252,1526367600"; d="scan'208";a="51131223" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.228]) by orsmga008.jf.intel.com with ESMTP; 21 Jun 2018 06:27:26 -0700 Date: Thu, 21 Jun 2018 21:27:30 +0800 From: Tiwei Bie To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <20180621132730.GA3345@debian> References: <20180618161729.334-1-marcandre.lureau@redhat.com> <20180618161729.334-5-marcandre.lureau@redhat.com> <20180621123320.GA19274@debian> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.43 Subject: Re: [Qemu-devel] [PATCH v3 04/26] vhost-user: simplify vhost_user_init/vhost_user_cleanup 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: QEMU , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Jun 21, 2018 at 02:48:08PM +0200, Marc-André Lureau wrote: > On Thu, Jun 21, 2018 at 2:33 PM, Tiwei Bie wrote: > > On Mon, Jun 18, 2018 at 06:17:07PM +0200, Marc-André Lureau wrote: > > [...] > >> diff --git a/hw/virtio/vhost-stub.c b/hw/virtio/vhost-stub.c > >> index 049089b5e2..323dfcc46a 100644 > >> --- a/hw/virtio/vhost-stub.c > >> +++ b/hw/virtio/vhost-stub.c > >> @@ -7,7 +7,7 @@ bool vhost_has_free_slot(void) > >> return true; > >> } > >> > >> -VhostUserState *vhost_user_init(void) > >> +bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) > >> { > >> return NULL; > > > > It would be better to return false. > > > > Good catch, fixed. > > Except that, would you give a reviewed-by? Sorry, I missed something previously. In below diff: It might be better to change the error message to something like: "failed to allocate vhost-user state". Except that, it looks good to me and you can add my reviewed-by. Best regards, Tiwei Bie > > > Best regards, > > Tiwei Bie > > > >> } > > [...] > > > > > > -- > Marc-André Lureau diff --git a/net/vhost-user.c b/net/vhost-user.c index a39f9c9974..5e5b8f3fc9 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -291,14 +291,14 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, { Error *err = NULL; NetClientState *nc, *nc0 = NULL; - VhostUserState *user = NULL; NetVhostUserState *s = NULL; + VhostUserState *user; int i; assert(name); assert(queues > 0); - user = vhost_user_init(); + user = g_new0(struct VhostUserState, 1); if (!user) { error_report("failed to init vhost_user"); goto err;