From nobody Mon Feb 9 11:31:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598862678; cv=none; d=zohomail.com; s=zohoarc; b=EFUVVqW9zhn6EsSekpj7WY6rIwXaD0jR4Ysd+N8jeE2x7E3P0vaA72BPaDlppdKfkaGM7hCK/lx8J5ceV2bYE8h5n9JlANGW1Ed03vNUQHJSQn8CI24EL5FJF5U0gN6R3zi3K/BgFnJD6Sh+5xgELFTTMBYWDP5fE9cAFNwdUf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598862678; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ssFNL+9qWeW2P1mJTJW0Zet2cgcckYhuIXxlrOvmdhI=; b=S/IIYUpe09b3q783fKq9UTjwVSYsEHIk2pa01GR2eISErSnx/TuCjzTiX2oW3cfmZ4gl88yQH7LkI2Y3GRAeScD38gsjJ6kHgf/9mjzMJN6mC7JXMIRBGU3hiJYw7dseKp7fZ6mv36YP1NYz6L/8N0KcwwssFGEqgFcFQXBOhuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598862678557841.5062893092777; Mon, 31 Aug 2020 01:31:18 -0700 (PDT) Received: from localhost ([::1]:52902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCfDh-00061F-7O for importer@patchew.org; Mon, 31 Aug 2020 04:31:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCfCJ-000425-0u for qemu-devel@nongnu.org; Mon, 31 Aug 2020 04:29:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCfCH-00066Y-02 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 04:29:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-wG_5OrXnM0-K52Cof_QwpQ-1; Mon, 31 Aug 2020 04:29:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA05D1019626 for ; Mon, 31 Aug 2020 08:29:45 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-12-88.pek2.redhat.com [10.72.12.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 842145D9D3; Mon, 31 Aug 2020 08:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598862588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ssFNL+9qWeW2P1mJTJW0Zet2cgcckYhuIXxlrOvmdhI=; b=EWDFC20677lvi4lSTLkKjYfV/UCe2NPB9QmZ2epULzO1yz6oYvTY8eazKivGj0N/iVczw3 vSxI/9UW6UYBWthX8n/TKd0kA02RVFKxGewL7aelLXc+QszygvF8nahkjD2GSfGmNGtjUG Jpyq5vGvoUTdqA4niy1rXdDbdMxD76o= X-MC-Unique: wG_5OrXnM0-K52Cof_QwpQ-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 7/9] vhost-vdpa: squash net_vhost_vdpa_init() into net_init_vhost_vdpa() Date: Mon, 31 Aug 2020 16:27:35 +0800 Message-Id: <20200831082737.10983-8-jasowang@redhat.com> In-Reply-To: <20200831082737.10983-1-jasowang@redhat.com> References: <20200831082737.10983-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 03:43:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch squashes net_vhost_vdpa_init() into net_init_vhost_vdpa(). This will simplify adding pre open file descriptor support. Signed-off-by: Jason Wang Reviewed-by: Laurent Vivier --- net/vhost-vdpa.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1d3ac89135..f5cc4e8326 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -172,27 +172,6 @@ static NetClientInfo net_vhost_vdpa_info =3D { .has_ufo =3D vhost_vdpa_has_ufo, }; =20 -static int net_vhost_vdpa_init(NetClientState *peer, const char *device, - const char *name, const char *vhostdev) -{ - NetClientState *nc; - VhostVDPAState *s; - int vdpa_device_fd; - int ret; - assert(name); - nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); - snprintf(nc->info_str, sizeof(nc->info_str), "vhostdev=3D%s", vhostdev= ); - s =3D DO_UPCAST(VhostVDPAState, nc, nc); - vdpa_device_fd =3D qemu_open(vhostdev, O_RDWR); - if (vdpa_device_fd =3D=3D -1) { - return -errno; - } - s->vhost_vdpa.device_fd =3D vdpa_device_fd; - ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); - - return ret; -} - static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp) { const char *name =3D opaque; @@ -215,6 +194,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; + NetClientState *nc; + VhostVDPAState *s; + int vdpa_device_fd; + int ret; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -227,5 +210,19 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, error_setg(errp, "vhost-vdpa requires vhostdev to be set"); return -1; } - return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev= ); + + assert(name); + + nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, TYPE_VHOST_VDPA= , name); + snprintf(nc->info_str, sizeof(nc->info_str), "vhostdev=3D%s", opts->vh= ostdev); + + s =3D DO_UPCAST(VhostVDPAState, nc, nc); + vdpa_device_fd =3D qemu_open(opts->vhostdev, O_RDWR); + if (vdpa_device_fd =3D=3D -1) { + return -errno; + } + s->vhost_vdpa.device_fd =3D vdpa_device_fd; + ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); + + return ret; } --=20 2.20.1