From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903870; cv=none; d=zohomail.com; s=zohoarc; b=KnSM6/6LQgA7zOPcpmAQRD/n9F4zmP91RBJKNIVQ7OcUMMyByVFwsDQKYG7kkp0L7y8DFakaMyjX5H1iq1+MoZ0oKYXx/L+DO7erkHcqEvB7+GnhjfhmQKfIakSCkXDz1CdR/j0qD9iiCd9b6TvVzi/GINBKpXG492fBRtycdkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903870; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JBEuKPIFGUuJUV939QSbdXyh7RXiG0DMIQMNx76sU+Q=; b=NiS8WjcAuX6dHbHUaqItvdT17DsI/2q3G2yBP732eTCqR0jC8YPnW9Fnnz5+OLSVT5MW5E1czYxufNH0+jHrOS55AkjSuardp+Q3fEuN9q8abF6U2bCVP2j1Mf5HheAYzlC/+GQWTqaSdaKXYrJbrxGZDdBxd6gqCvGPT6CT59c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903870193367.3515111147873; Wed, 3 Sep 2025 05:51:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw1-0005yJ-Fz; Wed, 03 Sep 2025 08:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvt-0005ut-Fy for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvp-0000ks-8Z for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:49 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 1541EC016B; Wed, 03 Sep 2025 15:49:38 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-aGP1hrIK; Wed, 03 Sep 2025 15:49:37 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903777; bh=JBEuKPIFGUuJUV939QSbdXyh7RXiG0DMIQMNx76sU+Q=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=vJXpCEkWpMZd8OP5rSWSE6sc5cvRY7P50aO7mEUY8MOesNgwZ6lxihdPNurkV+YOy LHUVtSGgRXnqOUCphj3regLabdlDc/HZMeIZcoAdhNT0a5nwKXN+b0tRJesSts0BtU jB3JFgYIG8PFvl4ttgYshKThD2E0Ac7xNVDThF1w= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 01/19] net/tap: net_init_tap_one(): add return value Date: Wed, 3 Sep 2025 15:49:15 +0300 Message-ID: <20250903124934.1169899-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903872029116600 Content-Type: text/plain; charset="utf-8" To avoid error propagation, let's follow common recommendation to use return value together with errp. Probably, it would also be good to use bool as a return type (switching to true/false as success/failure instead of 0/-1). But seems almost all functions (including a lot of them with errp argument) have 0/-1 semantics in net/, so making exclusions doesn't seem good. If we want such a switch, we should update the whole net/ directory. Why do we prefer errp-based functions with return value? In short with additional return value we get: - less code to handle error - don't create and set Error object when it's not required (when passed errp=3DNULL) More details in commit message of e3fe3988d7851cac3 "error: Document Error API usage rules" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/net/tap.c b/net/tap.c index f37133e301..89feb01756 100644 --- a/net/tap.c +++ b/net/tap.c @@ -679,11 +679,11 @@ static int net_tap_init(const NetdevTapOptions *tap, = int *vnet_hdr, =20 #define MAX_TAP_QUEUES 1024 =20 -static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, - const char *model, const char *name, - const char *ifname, const char *script, - const char *downscript, const char *vhostfdna= me, - int vnet_hdr, int fd, Error **errp) +static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *p= eer, + const char *model, const char *name, + const char *ifname, const char *script, + const char *downscript, const char *vhostfdnam= e, + int vnet_hdr, int fd, Error **errp) { Error *err =3D NULL; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); @@ -761,10 +761,11 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, goto failed; } =20 - return; + return 0; =20 failed: qemu_del_net_client(&s->nc); + return -1; } =20 static int get_fds(char *str, char *fds[], int max) @@ -801,7 +802,6 @@ int net_init_tap(const Netdev *netdev, const char *name, /* for the no-fd, no-helper case */ const char *script; const char *downscript; - Error *err =3D NULL; const char *vhostfdname; char ifname[128]; int ret =3D 0; @@ -846,12 +846,10 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } =20 - net_init_tap_one(tap, peer, "tap", name, NULL, - script, downscript, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); - close(fd); + ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, + script, downscript, + vhostfdname, vnet_hdr, fd, errp); + if (ret < 0) { return -1; } } else if (tap->fds) { @@ -907,12 +905,11 @@ int net_init_tap(const Netdev *netdev, const char *na= me, goto free_fail; } =20 - net_init_tap_one(tap, peer, "tap", name, ifname, - script, downscript, - tap->vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, + script, downscript, + tap->vhostfds ? vhost_fds[i] : NULL, + vnet_hdr, fd, errp); + if (ret < 0) { ret =3D -1; goto free_fail; } @@ -952,11 +949,10 @@ free_fail: return -1; } =20 - net_init_tap_one(tap, peer, "bridge", name, ifname, - script, downscript, vhostfdname, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + ret =3D net_init_tap_one(tap, peer, "bridge", name, ifname, + script, downscript, vhostfdname, + vnet_hdr, fd, errp); + if (ret < 0) { close(fd); return -1; } @@ -997,12 +993,11 @@ free_fail: } } =20 - net_init_tap_one(tap, peer, "tap", name, ifname, - i >=3D 1 ? "no" : script, - i >=3D 1 ? "no" : downscript, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, + i >=3D 1 ? "no" : script, + i >=3D 1 ? "no" : downscript, + vhostfdname, vnet_hdr, fd, errp); + if (ret < 0) { close(fd); return -1; } --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904029; cv=none; d=zohomail.com; s=zohoarc; b=K73aG7xnPKot6QxYnaN9HAyPule01NQkl2hWt+2n0dCTqyDH3SsL0RuXdUR4SZ5/VY6D1C2xHHkcx7K9JRjZjYCtPfnGZAX0bwKjg9u998XoCq2JvkKH4GJQP+2uHni5P8esOeb7h00wUk0vcqUkYiEzUHgbiMqx/FDeO3dTdr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904029; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oaAMDYoEY3wbm+P8EcFlCSd8u0m46lgHnNHKmZfL5XI=; b=bGu3+2GvqEqR1Y9yA/WWEOdIe9BgGz16J+b/d8aLYNzTJ7BsYH7CzdnWThsW6vN2T92XPV6ESfnyM/CnAf9wJ4Qc5c+frsHbrdCvYyZ2K32eoJXhOBNAfvzdFah5a7lBQvX5F34aRelDrVzXV/rR83KOt7hSY/NXbKlaGe7LWxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756904029256421.34291780828846; Wed, 3 Sep 2025 05:53:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw4-00062c-Jl; Wed, 03 Sep 2025 08:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvt-0005uo-8X for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:49 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvp-0000ku-8a for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:48 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 9CC88C0179; Wed, 03 Sep 2025 15:49:38 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-JQb28WGv; Wed, 03 Sep 2025 15:49:38 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903778; bh=oaAMDYoEY3wbm+P8EcFlCSd8u0m46lgHnNHKmZfL5XI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=KP3G2hbFPOjFkBRVSU2GLbW1UMvj7pHy/PNBIGWvNFRykGsBOxWaCRRZR+DPlFZ1L 4Q6NzoRp9VerYj7PRqLUfLHM5bLPoIMLVfuqPfgsU1hWIlef0nrCs90HbVfjh6fJP8 w5vf6N+64bkwfr79CVeFkOJyS+eTyO9/I57bn9u8= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 02/19] net/tap: tap_set_sndbuf(): add return value Date: Wed, 3 Sep 2025 15:49:16 +0300 Message-ID: <20250903124934.1169899-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904030910124100 Content-Type: text/plain; charset="utf-8" Follow common recommendations to avoid error propagation. Probably, it would also be good to use bool as a return type (switching to true/false as success/failure instead of 0/-1). But seems almost all functions (including a lot of them with errp argument) have 0/-1 semantics in net/, so making exclusions doesn't seem good. If we want such a switch, we should update the whole net/ directory. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap-linux.c | 5 ++++- net/tap.c | 4 +--- net/tap_int.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/net/tap-linux.c b/net/tap-linux.c index 786f339c13..ce09d2816b 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -146,7 +146,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_h= dr, */ #define TAP_DEFAULT_SNDBUF 0 =20 -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +int tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { int sndbuf; =20 @@ -160,7 +160,10 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *ta= p, Error **errp) =20 if (ioctl(fd, TUNSETSNDBUF, &sndbuf) =3D=3D -1 && tap->has_sndbuf) { error_setg_errno(errp, errno, "TUNSETSNDBUF ioctl failed"); + return -1; } + + return 0; } =20 int tap_probe_vnet_hdr(int fd, Error **errp) diff --git a/net/tap.c b/net/tap.c index 89feb01756..9793c7ab40 100644 --- a/net/tap.c +++ b/net/tap.c @@ -689,9 +689,7 @@ static int net_init_tap_one(const NetdevTapOptions *tap= , NetClientState *peer, TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; =20 - tap_set_sndbuf(s->fd, tap, &err); - if (err) { - error_propagate(errp, err); + if (tap_set_sndbuf(s->fd, tap, errp) < 0) { goto failed; } =20 diff --git a/net/tap_int.h b/net/tap_int.h index 8857ff299d..d21acf8486 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -33,7 +33,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, =20 ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen); =20 -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); +int tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903867; cv=none; d=zohomail.com; s=zohoarc; b=LqnpWZ9GvK5rFg5L9e3XXbQQcHiQKDp86EXj2s0An0+IunPd/kR/uW4cIhXfgv8QH6xkknbpVfXMqoSqI8xKm//1E/ZKYK+hRhWWq40nvf/xSXTBOiwtZQHmhkWigDbRNopDMl4hUuqpoiLwVA6tDhz2R80vKgPJ0Vx8Lxb000k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903867; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DXiTub6n46qqRlyBIU99aj/5sFkwYYFFft1ze3TubgU=; b=iMX9e/J62z1Sry8dscFYjQV0FH/vq/v/imLkbkwiGp7BzLjp8mnliHsSRaPk+8/yppy8E40uIM0RSoyOUCkdYt5QVpE7rVaKL31hFrkPlHp9oFXqf1NG0NfNNir8YvSEmjjS74dxwP2wxDUBWd/wv/nB3sN3ZxuVJWSFauiBUA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903867882835.9251027765166; Wed, 3 Sep 2025 05:51:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmwH-000690-AS; Wed, 03 Sep 2025 08:50:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0005v9-Us for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvr-0000l0-5z for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 236CEC017A; Wed, 03 Sep 2025 15:49:39 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-hRIIFvm5; Wed, 03 Sep 2025 15:49:38 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903778; bh=DXiTub6n46qqRlyBIU99aj/5sFkwYYFFft1ze3TubgU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=jy2ZU4OHG2Ke4hzP/DmU+VbfW0D0QLhbZXsipntkumGN3P8ynpopn+euYSpKeZrkp S6Tm/y6Kvrhmev8pv/kYB/YUVkCXsRVeipncUU1ytzSr8G6ZhYzYXo+eA8scqvn6vt 0uVa+PaihUqa1HnT5qWhihvj7dd35S5Y4Pf2/v5U= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 03/19] net/tap: net_init_tap_one(): drop extra error propagation Date: Wed, 3 Sep 2025 15:49:17 +0300 Message-ID: <20250903124934.1169899-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903869004124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/tap.c b/net/tap.c index 9793c7ab40..78ddd3d0cd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -685,7 +685,6 @@ static int net_init_tap_one(const NetdevTapOptions *tap= , NetClientState *peer, const char *downscript, const char *vhostfdnam= e, int vnet_hdr, int fd, Error **errp) { - Error *err =3D NULL; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; =20 @@ -721,9 +720,8 @@ static int net_init_tap_one(const NetdevTapOptions *tap= , NetClientState *peer, } =20 if (vhostfdname) { - vhostfd =3D monitor_fd_param(monitor_cur(), vhostfdname, &err); + vhostfd =3D monitor_fd_param(monitor_cur(), vhostfdname, errp); if (vhostfd =3D=3D -1) { - error_propagate(errp, err); goto failed; } if (!qemu_set_blocking(vhostfd, false, errp)) { --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903799; cv=none; d=zohomail.com; s=zohoarc; b=NCJ/ef2w3qv95YN8OSgmKXPZBy7jX63GxzD+M27DvPZPPxVglCkssMnNCW7xUW/OtcaO3F5rIJVDXwRb3bxJf3EqWyTk0NBw5p6Ju29Yr58XxLXdB9t3zOqAhWoupBO3F9EcOIml0c1T+rIbgTG+613BsgUPkZPOYa9UInlhvOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903799; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pim9jEV5RJXIQwkBMZ3k8ymlI9GkwaTkX5syYeHG8Nk=; b=WGv2jmT8U7C1x6sAGCMZTW4qlPzLL6WegGOApnXg3U/iUkbQAsWu5teXpM8znNr68yPi1UEmCQB/ELEFzO4xcZLCvp4R5dHNRVeXKBkSefI0kF8SY6HVULQf9mdTAcGqnwx1zmoVDz1sWOEzPhJ0Xn+fIF6cE3QJER3M30MEzWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903799536564.826883419773; Wed, 3 Sep 2025 05:49:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmvz-0005wz-GQ; Wed, 03 Sep 2025 08:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0005v6-Ri for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvq-0000l7-HA for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id A6C74C017C; Wed, 03 Sep 2025 15:49:39 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-BFVZ1DXw; Wed, 03 Sep 2025 15:49:39 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903779; bh=Pim9jEV5RJXIQwkBMZ3k8ymlI9GkwaTkX5syYeHG8Nk=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=JVIpZFGFuLw3JQZIjETOKNnV9csqGP3Jy7wevdDTQGt/WYVhxzMo58bEBLk6qF2ki kpMaWepfsccliiLRY8XpEwyswf3AYKt4ENanHXNW5wHWlHYyZKBbf7F70DhG28Zj5N AyTae24sQ4BIEFhhcONAzUWeFTFYYP0IYrJ9qLVI= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 04/19] net/tap: net_init_tap_one(): move parameter checking earlier Date: Wed, 3 Sep 2025 15:49:18 +0300 Message-ID: <20250903124934.1169899-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903803149124100 Content-Type: text/plain; charset="utf-8" Let's keep all similar argument checking in net_init_tap() function. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/tap.c b/net/tap.c index 78ddd3d0cd..40ee48e91c 100644 --- a/net/tap.c +++ b/net/tap.c @@ -752,9 +752,6 @@ static int net_init_tap_one(const NetdevTapOptions *tap= , NetClientState *peer, "vhost-net requested but could not be initialized"); goto failed; } - } else if (vhostfdname) { - error_setg(errp, "vhostfd(s)=3D is not valid without vhost"); - goto failed; } =20 return 0; @@ -816,6 +813,11 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 + if (tap->has_vhost && !tap->vhost && (tap->vhostfds || tap->vhostfd)) { + error_setg(errp, "vhostfd(s)=3D is not valid without vhost"); + return -1; + } + if (tap->fd) { if (tap->ifname || tap->script || tap->downscript || tap->has_vnet_hdr || tap->helper || tap->has_queues || --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903899; cv=none; d=zohomail.com; s=zohoarc; b=kGHOYVmsC2Hkc3kaZMg7tsNA9vGv6U1dheED05TwDCEv9z6dOmgHq2cvLq+JTQm0wVxRv/EtdL1zxiIE1TX2O1X7UpkOpSFnC3NyqRX/CkFT5B/EPqAB+X9TfwAmJhVhLnkwZTq9M2YqR5Sq9kSKk9lG5xmdc8iF9hfO4bteAxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903899; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iYnvmsD0znUvKSOUR3h//hIfuHZT8Nt6OwOzdG4Ee+A=; b=BEdNEGaM4asMJogxacIJya4aEHCjrSuj0V9XLegVCNb1YUnJjy5n9AOt9VGNaruOq3XUnP6EdUEC27eCUI0VDcs114x1pFth1YuMXAf5DcniSrwj4ggik+QuXon43x2trGAE45FBEFzWUMG5N//ZMvYSkedxRNxSqpVGVXvP+ho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903899166918.1975086722309; Wed, 3 Sep 2025 05:51:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw3-00061R-LE; Wed, 03 Sep 2025 08:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvt-0005ur-D0 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvq-0000lJ-HC for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:49 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 3B493C0165; Wed, 03 Sep 2025 15:49:40 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-polneB1x; Wed, 03 Sep 2025 15:49:39 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903779; bh=iYnvmsD0znUvKSOUR3h//hIfuHZT8Nt6OwOzdG4Ee+A=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=z2w+ARtR0Mst6Rr5GdSfaIWUXC1i7Bh7C4VLydgb1UG5QcOyizlbHLXb0i1OKll22 xrL78rWujn4cqjVF3yWj3bT4WdBIzTgSrgAM4zfJGFX3cU5rLXq6zi4d4AAcHmp+fZ e1OEOsS2/Ot/aQJ/S977VrOcStOlfK8soI/GAWzc= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 05/19] net/tap: net_init_tap(): refactor parameter checking Date: Wed, 3 Sep 2025 15:49:19 +0300 Message-ID: <20250903124934.1169899-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903900069116600 Content-Type: text/plain; charset="utf-8" Unite duplicated checks of different code paths. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/net/tap.c b/net/tap.c index 40ee48e91c..23ea57d6d9 100644 --- a/net/tap.c +++ b/net/tap.c @@ -818,12 +818,17 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } =20 + if ((tap->fd || tap->fds || tap->helper) && + (tap->ifname || tap->script || tap->downscript || + tap->has_vnet_hdr || tap->has_queues)) { + error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hdr=3D= , " + "queues=3D, are invalid with fd=3D/fds=3D/helper=3D"); + return -1; + } + if (tap->fd) { - if (tap->ifname || tap->script || tap->downscript || - tap->has_vnet_hdr || tap->helper || tap->has_queues || - tap->fds || tap->vhostfds) { - error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " - "helper=3D, queues=3D, fds=3D, and vhostfds=3D " + if (tap->helper || tap->fds || tap->vhostfds) { + error_setg(errp, "helper=3D, fds=3D, and vhostfds=3D " "are invalid with fd=3D"); return -1; } @@ -855,12 +860,8 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, char **vhost_fds; int nfds =3D 0, nvhosts =3D 0; =20 - if (tap->ifname || tap->script || tap->downscript || - tap->has_vnet_hdr || tap->helper || tap->has_queues || - tap->vhostfd) { - error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " - "helper=3D, queues=3D, and vhostfd=3D " - "are invalid with fds=3D"); + if (tap->helper || tap->vhostfd) { + error_setg(errp, "helper=3D and vhostfd=3D are invalid with fd= s=3D"); return -1; } =20 @@ -924,10 +925,8 @@ free_fail: g_free(vhost_fds); return ret; } else if (tap->helper) { - if (tap->ifname || tap->script || tap->downscript || - tap->has_vnet_hdr || tap->has_queues || tap->vhostfds) { - error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hd= r=3D, " - "queues=3D, and vhostfds=3D are invalid with helper= =3D"); + if (tap->vhostfds) { + error_setg(errp, "vhostfds=3D is invalid with helper=3D"); return -1; } =20 --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904033; cv=none; d=zohomail.com; s=zohoarc; b=U7y8vlEoW6TRLC8GkTZdpJMQL/zYZmGgIYFbcVLkg6dMtL8djXMyqv8zawPWYPqI/y1Fq6euJpzTyHh+suRz8k+fTwvTsU56m4l5KY8xWTALLdelPN1afm1NYCCrfh75WON4ZP2eUXO5YLroWs+yZmckFOPxd5psXpzdvqZhDJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904033; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NnzofHuEacNUQzhe3IlBSzP81JoN8oFO+l7H6mikaOs=; b=RsMPnApKHyMHc8Y6Uj5WApj0tTDcCKiX9l5w7k0xYvzuUeV8mQzqJ42CLsVc12C9iEa80aL+j5yRhdyHdsNv4O1l79pFy4HVORa67xStmN/B0iFIxcrzY6fUOpET+I1CCT45AD16GLys43OsSYzKU8LNGa1ryj426z0jRYHnfgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175690403326447.0544605742391; Wed, 3 Sep 2025 05:53:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw5-000631-LA; Wed, 03 Sep 2025 08:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0005vv-5G for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:51 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvq-0000lU-HE for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id C4E23C0183; Wed, 03 Sep 2025 15:49:40 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-sAVMNNfX; Wed, 03 Sep 2025 15:49:40 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903780; bh=NnzofHuEacNUQzhe3IlBSzP81JoN8oFO+l7H6mikaOs=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Ub2qmVpPbF9yWFXIcEJKcPMSrh1LBZF8m+sVlJetPStr4XFoSg4sQyExYBoTvIcII kCkgPDOsMr0EsULNgUMmPqGsPBqSf5DfAzeqGKfoLWP2SWfnBZKWIyTI8leimFffok Sgt6+PxRmQUw4Evmh0NcUFhyBblyU0PlMw+XX5og= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 06/19] net/tap: net_init_tap(): drop extra variable vhostfdname Date: Wed, 3 Sep 2025 15:49:20 +0300 Message-ID: <20250903124934.1169899-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904033678116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/tap.c b/net/tap.c index 23ea57d6d9..8e6a276e4b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -795,14 +795,12 @@ int net_init_tap(const Netdev *netdev, const char *na= me, /* for the no-fd, no-helper case */ const char *script; const char *downscript; - const char *vhostfdname; char ifname[128]; int ret =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; queues =3D tap->has_queues ? tap->queues : 1; - vhostfdname =3D tap->vhostfd; script =3D tap->script; downscript =3D tap->downscript; =20 @@ -851,7 +849,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, script, downscript, - vhostfdname, vnet_hdr, fd, errp); + tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { return -1; } @@ -947,7 +945,7 @@ free_fail: } =20 ret =3D net_init_tap_one(tap, peer, "bridge", name, ifname, - script, downscript, vhostfdname, + script, downscript, tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { close(fd); @@ -993,7 +991,7 @@ free_fail: ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, - vhostfdname, vnet_hdr, fd, errp); + tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { close(fd); return -1; --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903823; cv=none; d=zohomail.com; s=zohoarc; b=UiBclB/QzQy25q/Zs0F1n2QbZrN60hFzPc2Ja7GTjt3uRTmpLFuvQn2SKqVxf/CNpYp3QvCHVzB9iNUulmeEDJPjYH+fpsUVEKuAh25qV0Itofn3hO9hqVBxuUpvsAE2K/gYXquxRU9K3ns9pBFPfQoGwT7FaKM9WyPFJg52xyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903823; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4PJCnEyWGkfTAqF7UdeAVKuZQl5YlHcPZXor1iy/2ag=; b=XysVAaaFFLH+Ok7FV/W2U2S9Cbn9qcAfq/xbmbiMoyjiWsQTcb6C9JK4+OEdHJQPTQOrO6BQlbjze+2Xu5P8g53FKbZvGphiITixYQKrXs7RnUCihrA1RotFglf4woHVwPNiXu/3vrZb3CaOE5cR5Zm/7XF9shFn8noZU8LGjGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903823599134.0096558439443; Wed, 3 Sep 2025 05:50:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw0-0005xm-KP; Wed, 03 Sep 2025 08:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0005vz-6Y for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:51 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvr-0000lh-5u for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 4ECA2C0185; Wed, 03 Sep 2025 15:49:41 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-V6NBRckk; Wed, 03 Sep 2025 15:49:40 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903780; bh=4PJCnEyWGkfTAqF7UdeAVKuZQl5YlHcPZXor1iy/2ag=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=JtwdaOb3kfFntE1aWOvOqs6ICV0vHNNPfF0UEJraUDZKz037dGN8mcdqSd56Z0jwG isMSKve9mKzwx7KvVINTEQTcZIscJLSZeHYTqkiRfLRuFJmkdHTsdG7wMuMR82noQb Wzy4tZuyGuZaYN14Cia31f12D4+6CGQ7+Xh6WUpg= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 07/19] net/tap: move local variables related to the latter case to else branch Date: Wed, 3 Sep 2025 15:49:21 +0300 Message-ID: <20250903124934.1169899-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903826751124100 Content-Type: text/plain; charset="utf-8" This makes more obvious, where the variables make sense. Note that ifname, script and downscript variables are not used in net_init_tap_one() for fd/fds/helper cases. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/net/tap.c b/net/tap.c index 8e6a276e4b..a1a315a9f0 100644 --- a/net/tap.c +++ b/net/tap.c @@ -790,19 +790,11 @@ static int get_fds(char *str, char *fds[], int max) int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - const NetdevTapOptions *tap; - int fd, vnet_hdr =3D 0, i =3D 0, queues; - /* for the no-fd, no-helper case */ - const char *script; - const char *downscript; - char ifname[128]; + const NetdevTapOptions *tap =3D &netdev->u.tap; + int fd, vnet_hdr =3D 0, i =3D 0; int ret =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); - tap =3D &netdev->u.tap; - queues =3D tap->has_queues ? tap->queues : 1; - script =3D tap->script; - downscript =3D tap->downscript; =20 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ @@ -848,7 +840,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, - script, downscript, + NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { return -1; @@ -902,8 +894,8 @@ int net_init_tap(const Netdev *netdev, const char *name, goto free_fail; } =20 - ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, - script, downscript, + ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, + NULL, NULL, tap->vhostfds ? vhost_fds[i] : NULL, vnet_hdr, fd, errp); if (ret < 0) { @@ -944,16 +936,21 @@ free_fail: return -1; } =20 - ret =3D net_init_tap_one(tap, peer, "bridge", name, ifname, - script, downscript, tap->vhostfd, + ret =3D net_init_tap_one(tap, peer, "bridge", name, NULL, + NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { close(fd); return -1; } } else { + const char *script =3D tap->script; + const char *downscript =3D tap->downscript; + int queues =3D tap->has_queues ? tap->queues : 1; g_autofree char *default_script =3D NULL; g_autofree char *default_downscript =3D NULL; + char ifname[128]; + if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); return -1; --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904007; cv=none; d=zohomail.com; s=zohoarc; b=FrJnxAPrhxNB013O5dvMtZgGoF4Z8PPJmoqZfgV7acZ5jbAYNE27WQRol7k8b5C26L8F/+hQivJopPuQI0EstZ039UAF4ok0e4Q8AZm9Uv2z9gTn7pJHe5EE1vBK3T1GssI+j3dcmWxiZRhrRUQo44EHRL6sPSTgbeVMB0LN2xI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904007; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FZvAZvYWMrzkrgCQAZGPX1Zwn7CYwj80wz3CxZgDdzM=; b=Z8cpleHIdUQY6U2mZg7HLSQDIIdGGqiRCqmejKyJG2GoDrIXVQYWHuPCMjLH8nNizUEArNTxHS1XKsC6dBlW33wmIyY4fUo0jeDspjscw2YsVQim3avDKucgkSV2GZ1/9jXHDREEzDOzvOAUgzwEpcS7P/7lefT80rFhRhckTts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756904007088165.0195038927294; Wed, 3 Sep 2025 05:53:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw3-00061Q-LJ; Wed, 03 Sep 2025 08:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvt-0005us-Df for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvq-0000lp-H9 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:49 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id CE202C018E; Wed, 03 Sep 2025 15:49:41 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-IQx8gFWS; Wed, 03 Sep 2025 15:49:41 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903781; bh=FZvAZvYWMrzkrgCQAZGPX1Zwn7CYwj80wz3CxZgDdzM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=KCUsfGpilWKtqL2L3Kt10RVh+iSGZR7d0puiX+zAGUicvOIkjEaKRbPozsvTJ/DPO 3llvBy0rusS/OPMXEbDw30/DmM1QXAtd9pAPYhq7mh9XFW3l25M1Mn5NnfkeINEwKg vmUly+cYLP/5rWr999Y7SfWfLBzJ1II3XuQ3g2jQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 08/19] net/tap: use glib strings vector and g_strsplit for fds case Date: Wed, 3 Sep 2025 15:49:22 +0300 Message-ID: <20250903124934.1169899-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904009072124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 72 +++++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 58 deletions(-) diff --git a/net/tap.c b/net/tap.c index a1a315a9f0..cfa4ccc651 100644 --- a/net/tap.c +++ b/net/tap.c @@ -761,32 +761,6 @@ failed: return -1; } =20 -static int get_fds(char *str, char *fds[], int max) -{ - char *ptr =3D str, *this; - size_t len =3D strlen(str); - int i =3D 0; - - while (i < max && ptr < str + len) { - this =3D strchr(ptr, ':'); - - if (this =3D=3D NULL) { - fds[i] =3D g_strdup(ptr); - } else { - fds[i] =3D g_strndup(ptr, this - ptr); - } - - i++; - if (this =3D=3D NULL) { - break; - } else { - ptr =3D this + 1; - } - } - - return i; -} - int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -846,74 +820,56 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } } else if (tap->fds) { - char **fds; - char **vhost_fds; - int nfds =3D 0, nvhosts =3D 0; + g_auto(GStrv) fds =3D NULL; + g_auto(GStrv) vhost_fds =3D NULL; + int nfds; =20 if (tap->helper || tap->vhostfd) { error_setg(errp, "helper=3D and vhostfd=3D are invalid with fd= s=3D"); return -1; } =20 - fds =3D g_new0(char *, MAX_TAP_QUEUES); - vhost_fds =3D g_new0(char *, MAX_TAP_QUEUES); + fds =3D g_strsplit(tap->fds, ":", MAX_TAP_QUEUES); + nfds =3D g_strv_length(fds); =20 - nfds =3D get_fds(tap->fds, fds, MAX_TAP_QUEUES); if (tap->vhostfds) { - nvhosts =3D get_fds(tap->vhostfds, vhost_fds, MAX_TAP_QUEUES); - if (nfds !=3D nvhosts) { + vhost_fds =3D g_strsplit(tap->vhostfds, ":", MAX_TAP_QUEUES); + if (nfds !=3D g_strv_length(vhost_fds)) { error_setg(errp, "The number of fds passed does not match " "the number of vhostfds passed"); - ret =3D -1; - goto free_fail; + return -1; } } =20 for (i =3D 0; i < nfds; i++) { fd =3D monitor_fd_param(monitor_cur(), fds[i], errp); if (fd =3D=3D -1) { - ret =3D -1; - goto free_fail; + return -1; } =20 if (!qemu_set_blocking(fd, false, errp)) { - ret =3D -1; - goto free_fail; + return -1; } =20 if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { - ret =3D -1; - goto free_fail; + return -1; } } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd, NULL)) { error_setg(errp, "vnet_hdr not consistent across given tap fds"); - ret =3D -1; - goto free_fail; + return -1; } =20 ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, NULL, NULL, - tap->vhostfds ? vhost_fds[i] : NULL, + vhost_fds ? vhost_fds[i] : NULL, vnet_hdr, fd, errp); if (ret < 0) { - ret =3D -1; - goto free_fail; + return -1; } } - -free_fail: - for (i =3D 0; i < nvhosts; i++) { - g_free(vhost_fds[i]); - } - for (i =3D 0; i < nfds; i++) { - g_free(fds[i]); - } - g_free(fds); - g_free(vhost_fds); - return ret; } else if (tap->helper) { if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid with helper=3D"); --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903996; cv=none; d=zohomail.com; s=zohoarc; b=AN0PlBAaKoNmxL2P+5GRps8FiLdAqM8qFNZ5gULRcRzlmgKH1S4bHQXdwj3tGO+MXAx4qJABfIGlD3WuHF/lIS7WaZsaDzzNzP5UCkC+8ePwatjcEN2VOQXBdkOShQBrfJ3vHpHFtogWaSuFP1a7kZLN5F8N+qcgcBRxP/xESHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903996; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KLbs8RyNjizHaxX5jDH2xXLE6IMpI0rDJXUkJQfOEbQ=; b=dS1aKxLoMScBA++tUdW+4Py0kyMHoUHKgf6MT0x5VciNfJHInluf4MU9Zjsf5zpcKcF7ea3euuxBb27wFXQXgwWBw6tfM9HDF93Oeqxcwhspob/Kyk0kKw4BNmHZnQgvirUaP1tbR1+9FxP4J25JD3Hmb/ZfsJxH3e9NmBel7TE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903996986215.32134811732135; Wed, 3 Sep 2025 05:53:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw6-00063V-Jf; Wed, 03 Sep 2025 08:50:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0005vo-59 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:51 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvr-0000ly-5t for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:50 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 5117FC018F; Wed, 03 Sep 2025 15:49:42 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-28RIoyo6; Wed, 03 Sep 2025 15:49:41 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903781; bh=KLbs8RyNjizHaxX5jDH2xXLE6IMpI0rDJXUkJQfOEbQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=eyNsyr58kc8Zxu7qghMG8RgU4WF0fu9z2iNx/e2LEbcioqnwEvcCzSw4P68TT+myR cPKmLQn07yAwJI4mWxwar2tY2ElV2R9puZ6qMqGDokzVUfVi8wFIncln/LaED5RewR lbfopeqM5pALy9ZYUGqGfbPJ1IdUOOM778I4W3QQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 09/19] net/tap: drop extra tap_fd_get_ifname() call Date: Wed, 3 Sep 2025 15:49:23 +0300 Message-ID: <20250903124934.1169899-10-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903997336116600 Content-Type: text/plain; charset="utf-8" tap_open() cares to update ifname, no reason to call extra ioctl. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/net/tap.c b/net/tap.c index cfa4ccc651..c007cd272a 100644 --- a/net/tap.c +++ b/net/tap.c @@ -933,14 +933,6 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - if (queues > 1 && i =3D=3D 0 && !tap->ifname) { - if (tap_fd_get_ifname(fd, ifname)) { - error_setg(errp, "Fail to get ifname"); - close(fd); - return -1; - } - } - ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903851; cv=none; d=zohomail.com; s=zohoarc; b=JXlBoLBUzSlNejunt1y1gd9YvHABUWjXeponsMQKuhs1c2N/Fz03+NBcxWCte9bYL8UeVCniDyAm3WKVrFApyCwdRqrOvx2yQow5AI5O2JrW16co9O66kHpSFq+NPHeXQPsgmKhfAGT2fysseevd8VxOOvq3ry6Jp/SZ+qR6iYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903851; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AWe/NvzEYfuBKOxLSJ1su4BUutR6kWpN1uG/Rl7YzJ0=; b=gUfRVlbLsKHwNO7BxVAu1lJXH/JoQlcUZL5vCP+O5V9vr+5cV/g4t15cshcUl8DxEgCoRRr1aqrGnqIsByJMKliWUgVhkos8vAME7IUcjm9MjFgwzOIAAPftSQXKyCUgAG++1sIcsGk4xfa/pEbrgGr+XYJcUs8DnEkXMJhDipQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903851189225.130786429983; Wed, 3 Sep 2025 05:50:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmwI-0006Ce-KV; Wed, 03 Sep 2025 08:50:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvw-0005wZ-SU for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:52 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0000nU-MS for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:52 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id D033BC0192; Wed, 03 Sep 2025 15:49:42 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-EmxUYIwi; Wed, 03 Sep 2025 15:49:42 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903782; bh=AWe/NvzEYfuBKOxLSJ1su4BUutR6kWpN1uG/Rl7YzJ0=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=hWkmBEiTFcW3+kOu729uQ1/Is6GRbEXEfMfoCbMYVoebx2mtzEZs8VQfA3RF+gXJq LyAqZIlCW4v7Tj6oHLFu9VpwvZu8DAlmwooXMe+rhYW8zfQSvRAjxgooY6D36Ygt8X 3ji63GOiYpnnvvEB0sb8oopmlLZwDfnBkhbN6QkY= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 10/19] net/tap: net_init_tap_one(): refactor to use netdev as first arg Date: Wed, 3 Sep 2025 15:49:24 +0300 Message-ID: <20250903124934.1169899-11-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903854961124100 Content-Type: text/plain; charset="utf-8" This is needed for further unification of bridge initialization in net_init_tap() and net_init_bridge(). Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/tap.c b/net/tap.c index c007cd272a..7dc8f52831 100644 --- a/net/tap.c +++ b/net/tap.c @@ -679,15 +679,18 @@ static int net_tap_init(const NetdevTapOptions *tap, = int *vnet_hdr, =20 #define MAX_TAP_QUEUES 1024 =20 -static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *p= eer, +static int net_init_tap_one(const Netdev *netdev, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdnam= e, int vnet_hdr, int fd, Error **errp) { + const NetdevTapOptions *tap =3D &netdev->u.tap; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; =20 + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); + if (tap_set_sndbuf(s->fd, tap, errp) < 0) { goto failed; } @@ -813,7 +816,7 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } =20 - ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, + ret =3D net_init_tap_one(netdev, peer, "tap", name, NULL, NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { @@ -862,7 +865,7 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } =20 - ret =3D net_init_tap_one(tap, peer, "tap", name, NULL, + ret =3D net_init_tap_one(netdev, peer, "tap", name, NULL, NULL, NULL, vhost_fds ? vhost_fds[i] : NULL, vnet_hdr, fd, errp); @@ -892,7 +895,7 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } =20 - ret =3D net_init_tap_one(tap, peer, "bridge", name, NULL, + ret =3D net_init_tap_one(netdev, peer, "bridge", name, NULL, NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { @@ -933,7 +936,7 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } =20 - ret =3D net_init_tap_one(tap, peer, "tap", name, ifname, + ret =3D net_init_tap_one(netdev, peer, "tap", name, ifname, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, tap->vhostfd, vnet_hdr, fd, errp); --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903865; cv=none; d=zohomail.com; s=zohoarc; b=MWVS+gKt+hGclGC85CJQ90+kEFC8Wr10uU/PxsdYVPI0i+X3JSauaK5JC+MuECRCJ9rkjR9rxqnoeEKb27z/P//R2wHK1/8x/W70zIOURwDLxSc6/bUB+3f8iRiXj8QLGFepGMdXq41Y/tC7rqp2qMrdgnAD9Xg+fIaIVyZgoSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903865; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V09EVXB3RmUezu8R1HKszNv0Wmt33AxVwbk6HH4OJwY=; b=gqQb5ebX1D4flvEh98agPiUpIhI62n2ibufcx6NOrY5I6CBJ6k1MottEITQJpUsQLtetDD2vN9cxZrxPcX2TcEfAX7zJvzuVQHbXY/RE77AZd/UaQw7hBLAaEECgMj4ZgGDl+QPTIUy7rroTX+YBW89v+ppKiWrJRnsppqs3EKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903865282481.92935277784613; Wed, 3 Sep 2025 05:51:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw1-0005yH-Dy; Wed, 03 Sep 2025 08:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvw-0005wK-Fp for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:52 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0000nT-ML for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:52 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 65FDBC01B7; Wed, 03 Sep 2025 15:49:43 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-HhgGUC9M; Wed, 03 Sep 2025 15:49:42 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903782; bh=V09EVXB3RmUezu8R1HKszNv0Wmt33AxVwbk6HH4OJwY=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Z5fW5uKUvTo5Lp0oyH5H8wh5gtJjOLsHaHAkqRroUsCMb0sCqIqeiYssrR1n3wVoC Ml8TjnSxYu2rZ6/s6/5jsrk5wLRUJedK7Ux0QNYKCvfYt55zf8sAniuQ5vydZIDcr1 jMtsfp4wyQ+9P5yKMHg5KSPfLCZL8dkED/JePS0E= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 11/19] net/tap: net_init_tap_one(): support bridge Date: Wed, 3 Sep 2025 15:49:25 +0300 Message-ID: <20250903124934.1169899-12-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903865690116600 Content-Type: text/plain; charset="utf-8" Use net_init_tap_one() in net_init_bridge() to be able in further commits use net_init_bridge for "bridge" case of init_tap, as it has the same first part, but requires tap-related things in net_init_tap_one. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/net/tap.c b/net/tap.c index 7dc8f52831..01f9277211 100644 --- a/net/tap.c +++ b/net/tap.c @@ -88,6 +88,12 @@ static void launch_script(const char *setup_script, cons= t char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 +static int net_init_tap_one(const Netdev *netdev, NetClientState *peer, + const char *model, const char *name, + const char *ifname, const char *script, + const char *downscript, const char *vhostfdnam= e, + int vnet_hdr, int fd, Error **errp); + static void tap_update_fd_handler(TAPState *s) { qemu_set_fd_handler(s->fd, @@ -614,8 +620,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, { const NetdevBridgeOptions *bridge; const char *helper, *br; - TAPState *s; - int fd, vnet_hdr; + int fd, vnet_hdr, ret; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); bridge =3D &netdev->u.bridge; @@ -635,9 +640,14 @@ int net_init_bridge(const Netdev *netdev, const char *= name, close(fd); return -1; } - s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); =20 - qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", helper, br); + ret =3D net_init_tap_one(netdev, peer, "bridge", name, + NULL, NULL, NULL, + NULL, vnet_hdr, fd, errp); + if (ret < 0) { + close(fd); + return -1; + } =20 return 0; } @@ -685,11 +695,19 @@ static int net_init_tap_one(const Netdev *netdev, Net= ClientState *peer, const char *downscript, const char *vhostfdnam= e, int vnet_hdr, int fd, Error **errp) { - const NetdevTapOptions *tap =3D &netdev->u.tap; + const NetdevTapOptions *tap; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; =20 + if (netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE) { + const NetdevBridgeOptions *bridge =3D &netdev->u.bridge; + qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", + bridge->helper, bridge->br); + return 0; + } + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); + tap =3D &netdev->u.tap; =20 if (tap_set_sndbuf(s->fd, tap, errp) < 0) { goto failed; --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904023; cv=none; d=zohomail.com; s=zohoarc; b=iWVqD1m6wEg1iIhQUeDmxTQJtYOST/5zNFCRcYYaUMHsJzRsT4vX37tlMRxpxlaWG2I55BJdnrKdXMu88HQw2tzXWOIR4CbpZ4+SSA1eRKhvwXhCa5o95ynrOrpidvXCk0RpsJ8GcxArryH8D46FhtWRdAmq+blp5ZT/no6afMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904023; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FhJML9Otr3dUT6ZxMqz6k3sNazn9e3KFCnS6Z7ENET4=; b=EcVCkUBl3rDNFsW3DOhD9EUUDiRl+fVEqV6SvqT0GJ65DjBTsQoXmJwb0Vl5zNFGv+1brycr9BksT+h5G+j66FDtZYr8eBh2T7BptfbDX99MeyXgTNuwvI9KqgOgWTk5wGVVyf7xVGPjoYBhXUAILKJ3Bj5hX/zjIvAJmTr3B7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756904023593237.20851521363738; Wed, 3 Sep 2025 05:53:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw6-00063P-CQ; Wed, 03 Sep 2025 08:50:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvy-0005x5-SH for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:54 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0000ns-TN for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:53 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id D8C56C0196; Wed, 03 Sep 2025 15:49:43 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-sQeIegh0; Wed, 03 Sep 2025 15:49:43 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903783; bh=FhJML9Otr3dUT6ZxMqz6k3sNazn9e3KFCnS6Z7ENET4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=RWtyCfuoFSF5lHJC64OVQyWEjy1MLSSx5PI/r7qFXjyn8My9j4zL2/EX0wmbd7a51 HcC1D/bBWj5mOeo0V7qCUJw8DphHujkjNwVrtHLn1BcdAMRdKRU/ry/4rYxzxT1893 KdEBD7FDhjRWR+g6KmuMsXgp+byZHYIpxbCa2KN0= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 12/19] net/tap: net_init_bridge(): support tap Date: Wed, 3 Sep 2025 15:49:26 +0300 Message-ID: <20250903124934.1169899-13-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904024975124100 Content-Type: text/plain; charset="utf-8" Support tap in net_init_bridge() and reuse it for corresponding case in net_init_tap(). Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/net/tap.c b/net/tap.c index 01f9277211..79225fb233 100644 --- a/net/tap.c +++ b/net/tap.c @@ -618,16 +618,24 @@ static int net_bridge_run_helper(const char *helper, = const char *bridge, int net_init_bridge(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - const NetdevBridgeOptions *bridge; + const NetdevTapOptions *tap =3D NULL; + const NetdevBridgeOptions *bridge =3D NULL; const char *helper, *br; int fd, vnet_hdr, ret; =20 - assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); - bridge =3D &netdev->u.bridge; - helper =3D bridge->helper; - br =3D bridge->br ?: DEFAULT_BRIDGE_INTERFACE; + if (netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE) { + bridge =3D &netdev->u.bridge; + helper =3D bridge->helper; + br =3D bridge->br; + } else { + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); + + tap =3D &netdev->u.tap; + helper =3D tap->helper; + br =3D tap->br; + } =20 - fd =3D net_bridge_run_helper(helper, br, errp); + fd =3D net_bridge_run_helper(helper, br ?: DEFAULT_BRIDGE_INTERFACE, e= rrp); if (fd =3D=3D -1) { return -1; } @@ -643,7 +651,8 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, =20 ret =3D net_init_tap_one(netdev, peer, "bridge", name, NULL, NULL, NULL, - NULL, vnet_hdr, fd, errp); + tap ? tap->vhostfd : NULL, + vnet_hdr, fd, errp); if (ret < 0) { close(fd); return -1; @@ -897,29 +906,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - fd =3D net_bridge_run_helper(tap->helper, - tap->br ?: DEFAULT_BRIDGE_INTERFACE, - errp); - if (fd =3D=3D -1) { - return -1; - } - - if (!qemu_set_blocking(fd, false, errp)) { - return -1; - } - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); - if (vnet_hdr < 0) { - close(fd); - return -1; - } - - ret =3D net_init_tap_one(netdev, peer, "bridge", name, NULL, - NULL, NULL, tap->vhostfd, - vnet_hdr, fd, errp); - if (ret < 0) { - close(fd); - return -1; - } + return net_init_bridge(netdev, name, peer, errp); } else { const char *script =3D tap->script; const char *downscript =3D tap->downscript; --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903993; cv=none; d=zohomail.com; s=zohoarc; b=n2agSOu3A5soeAFeDAiQ2tDRgBsYfw4KbuU4m2Em6XOdcOsQDQzlU6QoL/DBmb3ZHTHkuJ5tGgLKMqgY4ycBLAOmpib0gu55/mONtfJOPnykhiOI88oIr1ZFfr2q1hGAft+PPhgAyk6aYxaxg/hORl8L7NX6uwByYhtQv7Au4eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903993; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FNpEu0vgeT5SARb41mWNwZDzd2rQBSI7dV4BBhJS5lk=; b=VE9F/kLToMcWVIGCFoQLyDBQ6pRvNIw4bdvjRVykm6lU5i4OIctf4r+wq9hdpxgSePUuRyI28lHj49MWgdQjG+B+omCo0rTFKafUjsj2XNtupBbFuRmZ+PHZ486qZ2aItmNYyysHurYL+gzve9N5ka/Vm9CUVIyUnY9ARmz792I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903993566785.3034986897302; Wed, 3 Sep 2025 05:53:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw6-00063n-R1; Wed, 03 Sep 2025 08:50:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw0-0005xr-Pf for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:56 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0000nr-2h for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 66B81C0198; Wed, 03 Sep 2025 15:49:44 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-WTyicmc4; Wed, 03 Sep 2025 15:49:43 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903783; bh=FNpEu0vgeT5SARb41mWNwZDzd2rQBSI7dV4BBhJS5lk=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Q+QZBCmXtnmeUux2CoIe/HQLcXKws8ND6UbwbuUBRfFJgCHmTF/Uqb8Pz/vtlvZQT bM+On/zknyqcc4vU1BFc3SIYc2M3EIrfuS+xip37oliASgIF3TJDAPueKAZUTZl9ZQ cMCHYm2S86xbish4dIiCtNvNI4sE+SEqyEdx7XVI= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 13/19] net/tap: refactor net_tap_init() into net_tap_open_one() Date: Wed, 3 Sep 2025 15:49:27 +0300 Message-ID: <20250903124934.1169899-14-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903995472116600 Content-Type: text/plain; charset="utf-8" net_tap_init() is used in one place. Let's move net_init_tap_one() call to it and simplify outer loop code. Note: "setup_script" variable renamed to just "script", as it's "script" in all other places in the file, and moreover, the original option is "script=3D" as well. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/net/tap.c b/net/tap.c index 79225fb233..d2f84586ed 100644 --- a/net/tap.c +++ b/net/tap.c @@ -661,31 +661,37 @@ int net_init_bridge(const Netdev *netdev, const char = *name, return 0; } =20 -static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr, - const char *setup_script, char *ifname, - size_t ifname_sz, int mq_required, Error **errp) +static int net_tap_open_one(const Netdev *netdev, + const char *name, NetClientState *peer, + const char *script, const char *downscript, + char *ifname, size_t ifname_sz, + int mq_required, Error **errp) { + const NetdevTapOptions *tap =3D &netdev->u.tap; Error *err =3D NULL; - int fd, vnet_hdr_required; + int fd, vnet_hdr_required, vnet_hdr; + int ret; + + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 if (tap->has_vnet_hdr) { - *vnet_hdr =3D tap->vnet_hdr; - vnet_hdr_required =3D *vnet_hdr; + vnet_hdr =3D tap->vnet_hdr; + vnet_hdr_required =3D vnet_hdr; } else { - *vnet_hdr =3D 1; + vnet_hdr =3D 1; vnet_hdr_required =3D 0; } =20 - fd =3D RETRY_ON_EINTR(tap_open(ifname, ifname_sz, vnet_hdr, vnet_hdr_r= equired, - mq_required, errp)); + fd =3D RETRY_ON_EINTR(tap_open(ifname, ifname_sz, &vnet_hdr, + vnet_hdr_required, mq_required, errp)); if (fd < 0) { return -1; } =20 - if (setup_script && - setup_script[0] !=3D '\0' && - strcmp(setup_script, "no") !=3D 0) { - launch_script(setup_script, ifname, fd, &err); + if (script && + script[0] !=3D '\0' && + strcmp(script, "no") !=3D 0) { + launch_script(script, ifname, fd, &err); if (err) { error_propagate(errp, err); close(fd); @@ -693,7 +699,15 @@ static int net_tap_init(const NetdevTapOptions *tap, i= nt *vnet_hdr, } } =20 - return fd; + ret =3D net_init_tap_one(netdev, peer, "tap", name, ifname, + script, downscript, + tap->vhostfd, vnet_hdr, fd, errp); + if (ret < 0) { + close(fd); + return -1; + } + + return 0; } =20 #define MAX_TAP_QUEUES 1024 @@ -935,20 +949,14 @@ int net_init_tap(const Netdev *netdev, const char *na= me, } =20 for (i =3D 0; i < queues; i++) { - fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? "no" : script, - ifname, sizeof ifname, queues > 1, errp); - if (fd =3D=3D -1) { - return -1; - } - - ret =3D net_init_tap_one(netdev, peer, "tap", name, ifname, + ret =3D net_tap_open_one(netdev, name, peer, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, - tap->vhostfd, vnet_hdr, fd, errp); + ifname, sizeof ifname, queues > 1, errp= ); if (ret < 0) { - close(fd); return -1; } + } } =20 --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904022; cv=none; d=zohomail.com; s=zohoarc; b=EVvV93fUCn36Z0PcGDRMjsNevjisFhC5aMUvzFNhJXr1lOY/3XEI5iR1q0zDtXUy+g1kVQfxxd6/QtyASeKQdJm0zw9JwzsKWHyO18xlZK7kuKPYsuMxIlDS+JpRdQ3iqc+iY1YcWRSsy7BQeBp3UYjUNR1qEaSW7B3/R/rOSAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904022; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z3yUM0FMk3Vlu3RWBhLTmIiC1wl5j4itBKMOFqDUSyM=; b=H5OgEodfKLs+DDgWo0/ghvGvs0ZZ0UOEoTzzSMEz0s5bUw9TdCVODTcJJTFq87g4jkzqnzPhk7EnNLapbKSDpF9/nc8/byzIWWyrBallpaEZ/BX7w5mZwceFohukIzMCzKKxohmNQ6dp8lI9VKapKmN2ijvwsVYfxsWNec+GIkk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756904022120168.867300046609; Wed, 3 Sep 2025 05:53:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw4-00062i-Lo; Wed, 03 Sep 2025 08:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvy-0005x3-R8 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:54 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0000np-Vj for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:53 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id E97ECC019D; Wed, 03 Sep 2025 15:49:44 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-cX2qhtHD; Wed, 03 Sep 2025 15:49:44 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903784; bh=Z3yUM0FMk3Vlu3RWBhLTmIiC1wl5j4itBKMOFqDUSyM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=RzCH4qZfEJS2PZv2eCCtKd0Zc/j+14ep4qYSdk/YAWJPGBmWXPWycIkupsxbsgR9U aPYl6DKwFhRTCi7Ym85eLgES55xeazboHrVZJpLLY7nYbYuNntkgx0Sv88WqraNzNL 0D9oTPaXK9hdDbP+zwVfDEA+qlPj4PKTziodLzJU= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 14/19] net/tap: introduce net_tap_open() Date: Wed, 3 Sep 2025 15:49:28 +0300 Message-ID: <20250903124934.1169899-15-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904024893124100 Content-Type: text/plain; charset="utf-8" Move the latter case of net_init_tap() to a separate function. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 96 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/net/tap.c b/net/tap.c index d2f84586ed..faee5cbeb3 100644 --- a/net/tap.c +++ b/net/tap.c @@ -805,6 +805,49 @@ failed: return -1; } =20 +static int net_tap_open(const Netdev *netdev, + const char *name, + NetClientState *peer, + Error **errp) +{ + const NetdevTapOptions *tap =3D &netdev->u.tap; + const char *script =3D tap->script; + const char *downscript =3D tap->downscript; + int queues =3D tap->has_queues ? tap->queues : 1; + g_autofree char *default_script =3D NULL; + g_autofree char *default_downscript =3D NULL; + char ifname[128]; + int i, ret; + + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); + + if (!script) { + script =3D default_script =3D get_relocated_path(DEFAULT_NETWORK_S= CRIPT); + } + if (!downscript) { + downscript =3D default_downscript =3D + get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIP= T); + } + + if (tap->ifname) { + pstrcpy(ifname, sizeof ifname, tap->ifname); + } else { + ifname[0] =3D '\0'; + } + + for (i =3D 0; i < queues; i++) { + ret =3D net_tap_open_one(netdev, name, peer, + i >=3D 1 ? "no" : script, + i >=3D 1 ? "no" : downscript, + ifname, sizeof ifname, queues > 1, errp); + if (ret < 0) { + return -1; + } + } + + return 0; +} + int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -857,12 +900,9 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - ret =3D net_init_tap_one(netdev, peer, "tap", name, NULL, - NULL, NULL, - tap->vhostfd, vnet_hdr, fd, errp); - if (ret < 0) { - return -1; - } + return net_init_tap_one(netdev, peer, "tap", name, NULL, + NULL, NULL, + tap->vhostfd, vnet_hdr, fd, errp); } else if (tap->fds) { g_auto(GStrv) fds =3D NULL; g_auto(GStrv) vhost_fds =3D NULL; @@ -914,6 +954,8 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } } + + return 0; } else if (tap->helper) { if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid with helper=3D"); @@ -921,46 +963,14 @@ int net_init_tap(const Netdev *netdev, const char *na= me, } =20 return net_init_bridge(netdev, name, peer, errp); - } else { - const char *script =3D tap->script; - const char *downscript =3D tap->downscript; - int queues =3D tap->has_queues ? tap->queues : 1; - g_autofree char *default_script =3D NULL; - g_autofree char *default_downscript =3D NULL; - char ifname[128]; - - if (tap->vhostfds) { - error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); - return -1; - } - - if (!script) { - script =3D default_script =3D get_relocated_path(DEFAULT_NETWO= RK_SCRIPT); - } - if (!downscript) { - downscript =3D default_downscript =3D - get_relocated_path(DEFAULT_NETWORK_DOWN_S= CRIPT); - } - - if (tap->ifname) { - pstrcpy(ifname, sizeof ifname, tap->ifname); - } else { - ifname[0] =3D '\0'; - } - - for (i =3D 0; i < queues; i++) { - ret =3D net_tap_open_one(netdev, name, peer, - i >=3D 1 ? "no" : script, - i >=3D 1 ? "no" : downscript, - ifname, sizeof ifname, queues > 1, errp= ); - if (ret < 0) { - return -1; - } + } =20 - } + if (tap->vhostfds) { + error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't specifie= d"); + return -1; } =20 - return 0; + return net_tap_open(netdev, name, peer, errp); } =20 int tap_enable(NetClientState *nc) --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904023; cv=none; d=zohomail.com; s=zohoarc; b=MNC/BT7Jg0cuyJnt5P63IG/J72IsD++nnRLtKdSwJ4orbtEKpAEVZ9mltBHWtkC4xQ4eckYytfRBVrNWafehJfTgUn6w7E/K1OgvG1Kxf2CgKjnzBx+Krqz2NlvO3aasP6oHR7aQ9eYw415Jkj2wYT6cC6yaZEa7BkMMJliyhFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904023; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5tatC7ljYxtyqmoxHP3w6VyCrJ5BNS7hYtJhdLBq7P4=; b=V9wiC/1xa4hAJkbGj16wzU2ENEG4JPku+gncXe3sorTHfCNRd57UGa76FrJu+cIyuiUa8bwdODVEtsk7bHTixswZRyk/8oRgusEdWpEKw8Efq+WnnKYC4mM1H+HzeNTdyA49biuLplBmsXATESrS8eMA/0NmRuk4IAe1zWbWy2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17569040226831012.817191702927; Wed, 3 Sep 2025 05:53:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmwA-000656-Mc; Wed, 03 Sep 2025 08:50:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvz-0005xT-3m for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:55 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0000nq-0A for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:53 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 8631FC01BB; Wed, 03 Sep 2025 15:49:45 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-0zA2hjBK; Wed, 03 Sep 2025 15:49:45 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903785; bh=5tatC7ljYxtyqmoxHP3w6VyCrJ5BNS7hYtJhdLBq7P4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=oH1YGUEiv67JxeU9VC9ECVETe0gpIjVz/SAkRX/Ht8Msubq5y91pCp38hSiOF9hZz Vl0icL/IZheLG/7WPWnHQjspkhIGfr+BZe1oqHxFtNvrsDHl8jqQyZNxTMVV8fuSQZ rExDbE+XPJ2kxDqXYk33MMEegLo23XEo8EAjsoUY= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 15/19] net/tap: introduce net_tap_fd_init_external() Date: Wed, 3 Sep 2025 15:49:29 +0300 Message-ID: <20250903124934.1169899-16-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904023798116600 Content-Type: text/plain; charset="utf-8" Add helper that covers logic for initializing fds, given from monitor or helper. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 89 ++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/net/tap.c b/net/tap.c index faee5cbeb3..4da3f36b31 100644 --- a/net/tap.c +++ b/net/tap.c @@ -615,13 +615,40 @@ static int net_bridge_run_helper(const char *helper, = const char *bridge, } } =20 +static int net_tap_fd_init_external(const Netdev *netdev, NetClientState *= peer, + const char *model, const char *name, + const char *vhostfdname, + int *pvnet_hdr, int fd, Error **errp) +{ + int vnet_hdr; + + if (!qemu_set_blocking(fd, false, errp)) { + return -1; + } + + vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + if (pvnet_hdr) { + if (*pvnet_hdr < 0) { + *pvnet_hdr =3D vnet_hdr; + } else if (vnet_hdr !=3D *pvnet_hdr) { + error_setg(errp, + "vnet_hdr not consistent across given tap fds"); + return -1; + } + } + + return net_init_tap_one(netdev, peer, model, name, + NULL, NULL, NULL, + vhostfdname, vnet_hdr, fd, errp); +} + int net_init_bridge(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap =3D NULL; const NetdevBridgeOptions *bridge =3D NULL; const char *helper, *br; - int fd, vnet_hdr, ret; + int fd; =20 if (netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE) { bridge =3D &netdev->u.bridge; @@ -640,25 +667,8 @@ int net_init_bridge(const Netdev *netdev, const char *= name, return -1; } =20 - if (!qemu_set_blocking(fd, false, errp)) { - return -1; - } - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); - if (vnet_hdr < 0) { - close(fd); - return -1; - } - - ret =3D net_init_tap_one(netdev, peer, "bridge", name, - NULL, NULL, NULL, - tap ? tap->vhostfd : NULL, - vnet_hdr, fd, errp); - if (ret < 0) { - close(fd); - return -1; - } - - return 0; + return net_tap_fd_init_external(netdev, peer, "bridge", name, + tap ? tap->vhostfd : NULL, NULL, fd, e= rrp); } =20 static int net_tap_open_one(const Netdev *netdev, @@ -889,20 +899,8 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - if (!qemu_set_blocking(fd, false, errp)) { - close(fd); - return -1; - } - - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); - if (vnet_hdr < 0) { - close(fd); - return -1; - } - - return net_init_tap_one(netdev, peer, "tap", name, NULL, - NULL, NULL, - tap->vhostfd, vnet_hdr, fd, errp); + return net_tap_fd_init_external(netdev, peer, "tap", name, + tap->vhostfd, NULL, fd, errp); } else if (tap->fds) { g_auto(GStrv) fds =3D NULL; g_auto(GStrv) vhost_fds =3D NULL; @@ -925,31 +923,16 @@ int net_init_tap(const Netdev *netdev, const char *na= me, } } =20 + vnet_hdr =3D -1; for (i =3D 0; i < nfds; i++) { fd =3D monitor_fd_param(monitor_cur(), fds[i], errp); if (fd =3D=3D -1) { return -1; } =20 - if (!qemu_set_blocking(fd, false, errp)) { - return -1; - } - - if (i =3D=3D 0) { - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); - if (vnet_hdr < 0) { - return -1; - } - } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd, NULL)) { - error_setg(errp, - "vnet_hdr not consistent across given tap fds"); - return -1; - } - - ret =3D net_init_tap_one(netdev, peer, "tap", name, NULL, - NULL, NULL, - vhost_fds ? vhost_fds[i] : NULL, - vnet_hdr, fd, errp); + ret =3D net_tap_fd_init_external(netdev, peer, "tap", name, + vhost_fds ? vhost_fds[i] : NULL, + &vnet_hdr, fd, errp); if (ret < 0) { return -1; } --=20 2.48.1 From nobody Sat Sep 6 14:41:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756904033; cv=none; d=zohomail.com; s=zohoarc; b=JQ3M49fJKrlZKudZVaHPq/6eGLi7woeB8QUVcFK8m7txunA68XO6rkqj/3fq2cZZezFC5LkMJhq1QhcPYcmW4rowVN2Hm9W0+wI1hM4hYqze5yVB5coUzbz0F2xvEEJ+HpHCXnW1Xk1qyb1/MkVHe9udOJK4PCvI92eJnrqpgyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756904033; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ij82BMCypSjIMbT/HzIhCBD8q/fXCD0qoLK28qqYVDQ=; b=kAtqpo9p8m7AHLnVnGVym8JG8B4Ua13XEeSs0HPZ5V9QSxSHc/Jk12W1GoZncvA8OtYS/Su7L/e1e8g/4sRj4SZrLakfrX6jWfr93bC2aPPrMsjyhx/+9Fw5S7ZznrFHWrFQ62sRb8N0CfdH1H9yFIT1JlCuGUYGBB7O3sfUvOw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756904033250264.79641778211885; Wed, 3 Sep 2025 05:53:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw5-000638-Og; Wed, 03 Sep 2025 08:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw0-0005xt-Pt for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:56 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvv-0000nx-1q for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 054F1C01BC; Wed, 03 Sep 2025 15:49:46 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-sSI9gNus; Wed, 03 Sep 2025 15:49:45 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903785; bh=Ij82BMCypSjIMbT/HzIhCBD8q/fXCD0qoLK28qqYVDQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=iJ/vv6h28jD3Qslc0XD6kDy9s98be9zjUaXF25hbkqY3s3eOg5E8B96vj1x8gucRB 84FAIuTjIl+O56bExc6Mvw7M1J+x1+1veKvJToRUQWjev0nxDfMkwKLH0mxGdD//gz 5jHugKDWDkcDr67o/IyHzfTlK6uY8nk8JV688QPY= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 16/19] net/tap: introduce net_tap_from_monitor_fd() helper Date: Wed, 3 Sep 2025 15:49:30 +0300 Message-ID: <20250903124934.1169899-17-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756904034920124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/net/tap.c b/net/tap.c index 4da3f36b31..0802da7d58 100644 --- a/net/tap.c +++ b/net/tap.c @@ -815,6 +815,20 @@ failed: return -1; } =20 +static int net_tap_from_monitor_fd(const Netdev *netdev, NetClientState *p= eer, + const char *name, const char *vhostfdna= me, + int *pvnet_hdr, const char *fdname, + Error **errp) +{ + int fd =3D monitor_fd_param(monitor_cur(), fdname, errp); + if (fd =3D=3D -1) { + return -1; + } + + return net_tap_fd_init_external(netdev, peer, "tap", name, + vhostfdname, pvnet_hdr, fd, errp); +} + static int net_tap_open(const Netdev *netdev, const char *name, NetClientState *peer, @@ -862,7 +876,7 @@ int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap =3D &netdev->u.tap; - int fd, vnet_hdr =3D 0, i =3D 0; + int vnet_hdr =3D 0, i =3D 0; int ret =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); @@ -894,13 +908,8 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); - if (fd =3D=3D -1) { - return -1; - } - - return net_tap_fd_init_external(netdev, peer, "tap", name, - tap->vhostfd, NULL, fd, errp); + return net_tap_from_monitor_fd(netdev, peer, name, tap->vhostfd, + NULL, tap->fd, errp); } else if (tap->fds) { g_auto(GStrv) fds =3D NULL; g_auto(GStrv) vhost_fds =3D NULL; @@ -925,14 +934,9 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, =20 vnet_hdr =3D -1; for (i =3D 0; i < nfds; i++) { - fd =3D monitor_fd_param(monitor_cur(), fds[i], errp); - if (fd =3D=3D -1) { - return -1; - } - - ret =3D net_tap_fd_init_external(netdev, peer, "tap", name, + ret =3D net_tap_from_monitor_fd(netdev, peer, name, vhost_fds ? vhost_fds[i] : NULL, - &vnet_hdr, fd, errp); + &vnet_hdr, fds[i], errp); if (ret < 0) { return -1; } --=20 2.48.1 From nobody Sat Sep 6 14:41:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903847; cv=none; d=zohomail.com; s=zohoarc; b=i7pLJhXp/zdAZZAYNzfDMAoyAJIlaiAOzW5gLFVv4a536pGBdPOS/tf4U0ExbZD1FymDuEtEA4S+/wiURLNy+R4p0KmoLHpVqWgxwWl0k+7coM9fIMi3lsfoTO3q7rB8UV7ZPNyBJ6Jm6Fnk6Vk8ngJWu5pjasQCxkONP9cgx4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903847; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ch4+tq/Yb8WQR2RXOcDXz2HjNbPLNzY4cDu2k8VkayM=; b=LRdhv/a99H0+5uIgukrKQptmZos+Ay+nGG6z3XltnDKhyaZn+X+kfZE6NaqNirLQVJ87Gb2bp/sctkT89a2/wXWbKcuWICNO2PRu4HnVuQ41N4dzsjKBMOhXCR+zN1G+dofEd/JMEPqZBeul2wOwvg2ek3k8uSp2MHVfkttt5kM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175690384779494.01075968258624; Wed, 3 Sep 2025 05:50:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmw2-0005zM-IZ; Wed, 03 Sep 2025 08:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvy-0005x4-Rs for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:54 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmvu-0000nt-Ta for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:49:53 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 9DE31C01BF; Wed, 03 Sep 2025 15:49:46 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-4TZATJdV; Wed, 03 Sep 2025 15:49:46 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903786; bh=Ch4+tq/Yb8WQR2RXOcDXz2HjNbPLNzY4cDu2k8VkayM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=skIhtBVDfbv86TwbyH9cekVRs7rXekNkiF/VOI4uaVUMJKQGcdisi4h3aTOfXrNWj 4Jf4sEEniZOO37Z/J5K/+6+PxLNbKrx5Gqot2daTLEtZAT33oz3yDazH+nkV94Q6JK izs22QpkI2gWrNuDTlW58CrwWSohSAc/6mWggIHs= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 17/19] net/tap: split net_tap_setup_vhost() separate function Date: Wed, 3 Sep 2025 15:49:31 +0300 Message-ID: <20250903124934.1169899-18-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903850863124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/net/tap.c b/net/tap.c index 0802da7d58..bc46839584 100644 --- a/net/tap.c +++ b/net/tap.c @@ -93,6 +93,8 @@ static int net_init_tap_one(const Netdev *netdev, NetClie= ntState *peer, const char *ifname, const char *script, const char *downscript, const char *vhostfdnam= e, int vnet_hdr, int fd, Error **errp); +static int net_tap_setup_vhost(TAPState *s, const NetdevTapOptions *tap, + const char *vhostfdname, Error **errp); =20 static void tap_update_fd_handler(TAPState *s) { @@ -730,7 +732,7 @@ static int net_init_tap_one(const Netdev *netdev, NetCl= ientState *peer, { const NetdevTapOptions *tap; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); - int vhostfd; + int ret; =20 if (netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE) { const NetdevBridgeOptions *bridge =3D &netdev->u.bridge; @@ -761,9 +763,25 @@ static int net_init_tap_one(const Netdev *netdev, NetC= lientState *peer, } } =20 + ret =3D net_tap_setup_vhost(s, tap, vhostfdname, errp); + if (ret < 0) { + goto failed; + } + + return 0; + +failed: + qemu_del_net_client(&s->nc); + return -1; +} + +static int net_tap_setup_vhost(TAPState *s, const NetdevTapOptions *tap, + const char *vhostfdname, Error **errp) +{ if (tap->has_vhost ? tap->vhost : vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; + int vhostfd; =20 options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; options.net_backend =3D &s->nc; @@ -776,20 +794,20 @@ static int net_init_tap_one(const Netdev *netdev, Net= ClientState *peer, if (vhostfdname) { vhostfd =3D monitor_fd_param(monitor_cur(), vhostfdname, errp); if (vhostfd =3D=3D -1) { - goto failed; + return -1; } if (!qemu_set_blocking(vhostfd, false, errp)) { - goto failed; + return -1; } } else { vhostfd =3D open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); - goto failed; + return -1; } if (!qemu_set_blocking(vhostfd, false, errp)) { - goto failed; + return -1; } } options.opaque =3D (void *)(uintptr_t)vhostfd; @@ -804,15 +822,11 @@ static int net_init_tap_one(const Netdev *netdev, Net= ClientState *peer, if (!s->vhost_net) { error_setg(errp, "vhost-net requested but could not be initialized"); - goto failed; + return -1; } } =20 return 0; - -failed: - qemu_del_net_client(&s->nc); - return -1; } =20 static int net_tap_from_monitor_fd(const Netdev *netdev, NetClientState *p= eer, --=20 2.48.1 From nobody Sat Sep 6 14:41:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903860; cv=none; d=zohomail.com; s=zohoarc; b=GGhyRDfzbJoo2/qgaw+IIAcp6EFR7s5mrDn7VAGf6An/zPrdKNhoHpnGMx5aQhLWt7u/tfl57KIakkqETH9+190y9k2X4QDtZmB23Ewd+tTXy0LWMIuma9X0RwnnARGcZWTcIc3EwPJIkKj9cIJFuqXpp2mf0zgRFYEd6RHBcqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903860; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xAz54pULPRmewXD08HRWd/JDx6s3s5TRWhqg3FoWG2k=; b=GGq5uGJqsRpU83APghLB4bthlb2ryc85Mn4NVQQzfNbOrf4/VKK1/s13FXflKmAMYL+/qkUdyuUGrFfmpMc1ayryH9zzZ+1vCr+vVfAjf8qUU2ehrUVvDBx+abcd4kL2w/8U87e9vyMrE4T7iWhKJERAzjjQn1JjT9ZUJXsQuSg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17569038603401017.729238230406; Wed, 3 Sep 2025 05:51:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmwS-0006Ig-Bo; Wed, 03 Sep 2025 08:50:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw7-000644-0G for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:50:03 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw5-0000o4-48 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:50:02 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id AC4EBC01C0; Wed, 03 Sep 2025 15:49:48 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-lzESOB5n; Wed, 03 Sep 2025 15:49:48 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903788; bh=xAz54pULPRmewXD08HRWd/JDx6s3s5TRWhqg3FoWG2k=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=vVpjDSfAqu2ufMLrDcBdhDiKkcx7rPK50hHU5L9nxpTUpUr/k1HiLpa6COJww/B5I cscCIgr4nVYBCPQ6427bFV4lZdAPrQRtnpCFreOyq27c42bjpQtUv20PB/k05v0RMe TtUldnEIr/8bdOsdo/1RzXiOoOeEvFt2WmGOzLS4= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 18/19] net/tap: drop net_tap_fd_init() Date: Wed, 3 Sep 2025 15:49:32 +0300 Message-ID: <20250903124934.1169899-19-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903862001116600 Content-Type: text/plain; charset="utf-8" It's called only from net_init_tap_one(), and there is no semantic reason, why we do part of initialization in one function and continue in another. Let's combine them into one net_tap_fd_init_common(). Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 97 +++++++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/net/tap.c b/net/tap.c index bc46839584..5ad6f6af85 100644 --- a/net/tap.c +++ b/net/tap.c @@ -88,11 +88,12 @@ static void launch_script(const char *setup_script, con= st char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 -static int net_init_tap_one(const Netdev *netdev, NetClientState *peer, - const char *model, const char *name, - const char *ifname, const char *script, - const char *downscript, const char *vhostfdnam= e, - int vnet_hdr, int fd, Error **errp); +static int net_tap_fd_init_common(const Netdev *netdev, NetClientState *pe= er, + const char *model, const char *name, + const char *ifname, const char *script, + const char *downscript, + const char *vhostfdname, + int vnet_hdr, int fd, Error **errp); static int net_tap_setup_vhost(TAPState *s, const NetdevTapOptions *tap, const char *vhostfdname, Error **errp); =20 @@ -393,42 +394,6 @@ static NetClientInfo net_tap_info =3D { .get_vhost_net =3D tap_get_vhost_net, }; =20 -static TAPState *net_tap_fd_init(NetClientState *peer, - const char *model, - const char *name, - int fd, - int vnet_hdr) -{ - NetClientState *nc; - TAPState *s; - - nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); - - s =3D DO_UPCAST(TAPState, nc, nc); - - s->fd =3D fd; - s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; - s->using_vnet_hdr =3D false; - s->has_ufo =3D tap_probe_has_ufo(s->fd); - s->has_uso =3D tap_probe_has_uso(s->fd); - s->enabled =3D true; - tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); - /* - * Make sure host header length is set correctly in tap: - * it might have been modified by another instance of qemu. - */ - if (vnet_hdr) { - tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len); - } - tap_read_poll(s, true); - s->vhost_net =3D NULL; - - s->exit.notify =3D tap_exit_notify; - qemu_add_exit_notifier(&s->exit); - - return s; -} - static void close_all_fds_after_fork(int excluded_fd) { const int skip_fd[] =3D {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, @@ -639,9 +604,9 @@ static int net_tap_fd_init_external(const Netdev *netde= v, NetClientState *peer, } } =20 - return net_init_tap_one(netdev, peer, model, name, - NULL, NULL, NULL, - vhostfdname, vnet_hdr, fd, errp); + return net_tap_fd_init_common(netdev, peer, model, name, + NULL, NULL, NULL, + vhostfdname, vnet_hdr, fd, errp); } =20 int net_init_bridge(const Netdev *netdev, const char *name, @@ -711,9 +676,9 @@ static int net_tap_open_one(const Netdev *netdev, } } =20 - ret =3D net_init_tap_one(netdev, peer, "tap", name, ifname, - script, downscript, - tap->vhostfd, vnet_hdr, fd, errp); + ret =3D net_tap_fd_init_common(netdev, peer, "tap", name, ifname, + script, downscript, + tap->vhostfd, vnet_hdr, fd, errp); if (ret < 0) { close(fd); return -1; @@ -724,15 +689,41 @@ static int net_tap_open_one(const Netdev *netdev, =20 #define MAX_TAP_QUEUES 1024 =20 -static int net_init_tap_one(const Netdev *netdev, NetClientState *peer, - const char *model, const char *name, - const char *ifname, const char *script, - const char *downscript, const char *vhostfdnam= e, - int vnet_hdr, int fd, Error **errp) +static int net_tap_fd_init_common(const Netdev *netdev, NetClientState *pe= er, + const char *model, const char *name, + const char *ifname, const char *script, + const char *downscript, + const char *vhostfdname, + int vnet_hdr, int fd, Error **errp) { const NetdevTapOptions *tap; - TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int ret; + NetClientState *nc; + TAPState *s; + + nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); + + s =3D DO_UPCAST(TAPState, nc, nc); + + s->fd =3D fd; + s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; + s->using_vnet_hdr =3D false; + s->has_ufo =3D tap_probe_has_ufo(s->fd); + s->has_uso =3D tap_probe_has_uso(s->fd); + s->enabled =3D true; + tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); + /* + * Make sure host header length is set correctly in tap: + * it might have been modified by another instance of qemu. + */ + if (vnet_hdr) { + tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len); + } + tap_read_poll(s, true); + s->vhost_net =3D NULL; + + s->exit.notify =3D tap_exit_notify; + qemu_add_exit_notifier(&s->exit); =20 if (netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE) { const NetdevBridgeOptions *bridge =3D &netdev->u.bridge; --=20 2.48.1 From nobody Sat Sep 6 14:41:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1756903899; cv=none; d=zohomail.com; s=zohoarc; b=MMdYAWRzt6gwfllzrbNcpmDkfEkGP59zhteS7sonnLTFJr/gZTrXBBeEuMjzrqcKQil+Z99ZOSgdIm6FR8Cyg2G2MgMUWeisM2eEOr4FLTeiooA1k4uitM1PHX9zF3GZLy1yOGv2XC8NwwUsLVmocBt/Z3JcgNbOoT12miACmFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756903899; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m/hFLQMDX/lCZxfgHLZhE6GJfd+gtZ+BLeDe492dlkM=; b=XI9l9ucM2dPBVe+LQiNCeyYYfcuFTTdNSETb6QFmpcgN1uXtI1ONGZ75MZUHKSvKUA6qJGLYzz71OIbmdMoEdc2qFsyjJnqDAStwr166u4dl3vx6gkGSWzzxym2YHLJe4/CUmMUKZpEbChsja2Ezcc8UlkQcg7hTAk1tgsSFEL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756903898202341.8475477349807; Wed, 3 Sep 2025 05:51:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utmwK-0006D8-PP; Wed, 03 Sep 2025 08:50:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw6-00063r-Tl for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:50:03 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utmw5-0000o6-37 for qemu-devel@nongnu.org; Wed, 03 Sep 2025 08:50:02 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 3FED8C0162; Wed, 03 Sep 2025 15:49:49 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:b8f::1:11]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id anf8gZ3GnW20-4jtuwM2G; Wed, 03 Sep 2025 15:49:48 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1756903788; bh=m/hFLQMDX/lCZxfgHLZhE6GJfd+gtZ+BLeDe492dlkM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=HrN3koCUAIhNDJ9ll8pRGM+WiLDFo+RDKSupUyzD575dio4khLFlu5qNntIyMPr/g 0JbVr68pUrJDO/35trAQXhe+Tie1oA5KyozNp77ZFn+7q9biGoF6Us7DUDcNphFjwB FZ7JH2PQXGNEiOrp51Q2qqvcHo5g5UdmapTQF4N8= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, vsementsov@yandex-team.ru, leiyang@redhat.com, steven.sistare@oracle.com, yc-core@yandex-team.ru Subject: [PATCH v3 19/19] net/tap: introduce net_init_tap_fds() Date: Wed, 3 Sep 2025 15:49:33 +0300 Message-ID: <20250903124934.1169899-20-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250903124934.1169899-1-vsementsov@yandex-team.ru> References: <20250903124934.1169899-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1756903900162116600 Content-Type: text/plain; charset="utf-8" Final refactoring step for net_init_tap: move fds case to separate function, so that net_init_tap() becomes straightforward top-level entry point to tap initialization. Signed-off-by: Vladimir Sementsov-Ogievskiy Tested-by: Lei Yang --- net/tap.c | 68 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/net/tap.c b/net/tap.c index 5ad6f6af85..2530627a9a 100644 --- a/net/tap.c +++ b/net/tap.c @@ -877,12 +877,48 @@ static int net_tap_open(const Netdev *netdev, return 0; } =20 +static int net_init_tap_fds(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) +{ + const NetdevTapOptions *tap =3D &netdev->u.tap; + g_auto(GStrv) fds =3D NULL; + g_auto(GStrv) vhost_fds =3D NULL; + int nfds; + int vnet_hdr =3D 0, i =3D 0; + int ret; + + assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); + + fds =3D g_strsplit(tap->fds, ":", MAX_TAP_QUEUES); + nfds =3D g_strv_length(fds); + + if (tap->vhostfds) { + vhost_fds =3D g_strsplit(tap->vhostfds, ":", MAX_TAP_QUEUES); + if (nfds !=3D g_strv_length(vhost_fds)) { + error_setg(errp, "The number of fds passed does not match " + "the number of vhostfds passed"); + return -1; + } + } + + vnet_hdr =3D -1; + for (i =3D 0; i < nfds; i++) { + ret =3D net_tap_from_monitor_fd(netdev, peer, name, + vhost_fds ? vhost_fds[i] : NULL, + &vnet_hdr, fds[i], errp); + if (ret < 0) { + return -1; + } + } + + return 0; +} + + int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap =3D &netdev->u.tap; - int vnet_hdr =3D 0, i =3D 0; - int ret =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -916,38 +952,12 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return net_tap_from_monitor_fd(netdev, peer, name, tap->vhostfd, NULL, tap->fd, errp); } else if (tap->fds) { - g_auto(GStrv) fds =3D NULL; - g_auto(GStrv) vhost_fds =3D NULL; - int nfds; - if (tap->helper || tap->vhostfd) { error_setg(errp, "helper=3D and vhostfd=3D are invalid with fd= s=3D"); return -1; } =20 - fds =3D g_strsplit(tap->fds, ":", MAX_TAP_QUEUES); - nfds =3D g_strv_length(fds); - - if (tap->vhostfds) { - vhost_fds =3D g_strsplit(tap->vhostfds, ":", MAX_TAP_QUEUES); - if (nfds !=3D g_strv_length(vhost_fds)) { - error_setg(errp, "The number of fds passed does not match " - "the number of vhostfds passed"); - return -1; - } - } - - vnet_hdr =3D -1; - for (i =3D 0; i < nfds; i++) { - ret =3D net_tap_from_monitor_fd(netdev, peer, name, - vhost_fds ? vhost_fds[i] : NULL, - &vnet_hdr, fds[i], errp); - if (ret < 0) { - return -1; - } - } - - return 0; + return net_init_tap_fds(netdev, name, peer, errp); } else if (tap->helper) { if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid with helper=3D"); --=20 2.48.1