From nobody Fri Nov 14 17:01:15 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=1761842490; cv=none; d=zohomail.com; s=zohoarc; b=ar4/40GgynFL9N2Q/p/stpMEI3xyGT91V+qHYt3TmW9/KhkUYp4GQmoRy3V6cIt5UwKib0Iql197XmJyygyzItfRtsJyNxwS/6wQda9lgSdCVESpJZUvGBINU8nwEH7Z0TR1cKmbKL5rnin6CjsCQ2gbCx9L4xplxbCK42JMnPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842490; 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=eHUx2spBW6/p1Kw9LAswD+KgJ9qZWxm5xopQ1fdR97g=; b=GDg20JQaAZIOfkveojZ1LBkeJX8XtlfQUPa1tlfGu43FzGWl2N8pwhfyCrFZv4c9G+whLYKDUlhpdmGKh3j3jUVLAvIAL9Pmb1DCcriGMMHlALZxeIVRt2ApWalJ2ZSi9qNdj0pMnosfPlRjPNPYzH3YG3CzHx81uRoDayrv5cY= 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 1761842489560139.16517044108878; Thu, 30 Oct 2025 09:41:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhd-0007zk-LN; Thu, 30 Oct 2025 12:40:45 -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 1vEVha-0007xl-OX for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:42 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1vEVhS-0003GP-32 for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:42 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id A591880B25; Thu, 30 Oct 2025 19:40:26 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-lsMkdJwX; Thu, 30 Oct 2025 19:40:26 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842426; bh=eHUx2spBW6/p1Kw9LAswD+KgJ9qZWxm5xopQ1fdR97g=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=MTtk87EkebxyFl1CxlSswkxFYI+8EmjBW0ZMosg4IlkkPh2SqPu0Mprz2ATfSWs8w s2q29hk9xLq1433A5zgMI3G07F3xmRZqyvBt5j8AiQxMB7UyDvBW4OcYVB+eCbYDJA TUAaZK0kYW0fVkwzdhWFmSNft0fc1xjQtCfaT3AY= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 1/7] net/tap: net_init_tap_one(): drop extra error propagation Date: Thu, 30 Oct 2025 19:40:17 +0300 Message-ID: <20251030164023.710048-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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, 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: 1761842496017154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/tap.c b/net/tap.c index abe3b2d036..70de798fe8 100644 --- a/net/tap.c +++ b/net/tap.c @@ -736,9 +736,8 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, 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 Fri Nov 14 17:01:15 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=1761842538; cv=none; d=zohomail.com; s=zohoarc; b=i5q8QD3F0nUF37v/BYPkbZVM0lwt/jRyrnOdDjOvI+CG4mF+B42UlsbsNdFiYL2jsUtgNpraJHc+X/FpLCgdUQKN7p6O1DH5z87yWOjjiguMik7l/Q8lQeahXGkqDD00ljc5dsKPblkx4PRr9V6ydLd0KrSUJtMeOlKjxNOQxhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842538; 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=9vy3Yz69QtSKHmzz4loBmW8l/k+eDWywJDJ/q5yZa/Q=; b=J2i9CO10H66V2D/4z70P6SCO73TfdJEzc7loX1EgyqpRB8py5cziPq/C0F82KpmCJhp53qc2CA3Iya2w9MVcKUI+Yp504kPzZx4/42MBohihjqMK7QKACs3gU9yUJIqfebKVg/PdGOi9AD7ZBsjPJZjlbHt/aVr5mjk4NNi7NSQ= 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 1761842538226526.0178672870094; Thu, 30 Oct 2025 09:42:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVho-00089P-TD; Thu, 30 Oct 2025 12:40: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 1vEVhf-00081T-N1 for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:47 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1vEVhS-0003GS-Eu for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:47 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 437B680B31; Thu, 30 Oct 2025 19:40:27 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-i2ksZwcy; Thu, 30 Oct 2025 19:40:26 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842426; bh=9vy3Yz69QtSKHmzz4loBmW8l/k+eDWywJDJ/q5yZa/Q=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=BMLShFVA6gFWdOEZL/n1J8XMRHZEZhiX3Fdr964i5fE5qE5Int22wI2TnDcReQxYC CZ6e0xbAKUbm7DiQvvxBdWazML3SdidSGiLQAmw1G9D73/Icz7pXNyWTKdX4NPIMQK MfqUMrVSh1nmaNIX9uVF8oFwvmvlGBQ62p6M9zeA= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 2/7] net/tap: net_init_tap_one(): move parameter checking earlier Date: Thu, 30 Oct 2025 19:40:18 +0300 Message-ID: <20251030164023.710048-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1761842541704158500 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 Reviewed-by: Maksim Davydov 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 70de798fe8..f90050c3a0 100644 --- a/net/tap.c +++ b/net/tap.c @@ -768,9 +768,6 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, 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; @@ -832,6 +829,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 Fri Nov 14 17:01:15 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=1761842490; cv=none; d=zohomail.com; s=zohoarc; b=OQpjWeZWyabzXbajuLEAElqpM16wk2OciV9ej6X6SRdDsgv+m9ntL8VK8NZpif/GifoGLlaF8Z/315bbXxUHMSJvlOQ/AQhURJWiui+8uVdD5SFlT9wb8M5aAidlvzgEZeY39DCv22nPvV48gTbOUlHZ5st1OXzQZcUs24S8BVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842490; 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=1Tyws1RO74DCvOk+3QeBN8VTw3xPjk7rHaoR80rF55k=; b=nNbZQ9wmOwmFDTzKT2OOjs6P8sSs34TygVrSWGP9bpFsmQErVNv95hkU6LR6BTS6YJ/XZbZUSb6c4Mx8P6iHuya9AUFDk2fqbz9HKd/kCXwpJ0JwzlGmA2HMeB+wwxyby/4ue3THe7a6kH0yf+C3cLUE9t1dPe9WHuNBBOR97os= 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 176184249020720.482154044811296; Thu, 30 Oct 2025 09:41:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhc-0007yA-3D; Thu, 30 Oct 2025 12:40:44 -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 1vEVhZ-0007wa-L8 for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:41 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1vEVhR-0003GW-R5 for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:41 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id BD9CF80B32; Thu, 30 Oct 2025 19:40:27 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-AyAYyBDw; Thu, 30 Oct 2025 19:40:27 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842427; bh=1Tyws1RO74DCvOk+3QeBN8VTw3xPjk7rHaoR80rF55k=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=cnxRb9uNUTtdi3GOknzmLP+NEhTfDVVGZBq5sJ3aYP52IlR3jotlH90u6MBAaoc5T ozzKmBKMbcHN+z6llKUmZcrzqX0/AFYMDRYrivY3xs+EFLTun9YikgvwXGBhowaNVN G6ivBz03Q9zTwKDhAsmjoyQimLO2Q5gV1I209zy8= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 3/7] net/tap: pass NULL to net_init_tap_one() in cases when scripts are NULL Date: Thu, 30 Oct 2025 19:40:19 +0300 Message-ID: <20251030164023.710048-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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, 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: 1761842496039154100 Content-Type: text/plain; charset="utf-8" Directly pass NULL in cases where we report an error if script or downscript are set. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/tap.c b/net/tap.c index f90050c3a0..5c6b9399e0 100644 --- a/net/tap.c +++ b/net/tap.c @@ -808,8 +808,6 @@ int net_init_tap(const Netdev *netdev, const char *name, 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; Error *err =3D NULL; const char *vhostfdname; char ifname[128]; @@ -819,8 +817,6 @@ int net_init_tap(const Netdev *netdev, const char *name, 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 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ @@ -861,7 +857,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 net_init_tap_one(tap, peer, "tap", name, NULL, - script, downscript, + NULL, NULL, vhostfdname, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); @@ -922,7 +918,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 net_init_tap_one(tap, peer, "tap", name, ifname, - script, downscript, + NULL, NULL, tap->vhostfds ? vhost_fds[i] : NULL, vnet_hdr, fd, &err); if (err) { @@ -967,7 +963,7 @@ free_fail: } =20 net_init_tap_one(tap, peer, "bridge", name, ifname, - script, downscript, vhostfdname, + NULL, NULL, vhostfdname, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); @@ -975,6 +971,8 @@ free_fail: return -1; } } else { + const char *script =3D tap->script; + const char *downscript =3D tap->downscript; g_autofree char *default_script =3D NULL; g_autofree char *default_downscript =3D NULL; if (tap->vhostfds) { --=20 2.48.1 From nobody Fri Nov 14 17:01:15 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=1761842627; cv=none; d=zohomail.com; s=zohoarc; b=EZkB3rGuw8BVhz4aHAUD4lGcwG0GuAVil5oUvwuKraLilxkOM8Zxlo77Rd1A9nD+tgVpqfbFAlDYIlH+nOMrO+3Usfqg39FnYWzYIwFyuNPPdKzvXjsZRUKhAlex08UxYdEumJxA9/UkpFctdoiFwXJaKnGwaQYmlBxISuWorPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842627; 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=TCjKToxw4+lOF11qKeuTQAB3HUw2mNv+VqvMxrCYR10=; b=bqsZByv0xlDpdxX1m9fPe2TLR4Av8DhIkMbaHpws0nTQSgqHPT/kEXu9rCDKnXFRnxvcHutgUPUnyRCId+KDjIiLN3Qm16Ed0DcQKVRnR5xrB0Sg0oBKE18yV8fkJ/HboT6+iJJpgbbp1GYB4wmuqE036+PgnTjuT4BLQSf0D9w= 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 1761842626893523.6701696969992; Thu, 30 Oct 2025 09:43:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhs-0008PV-G1; Thu, 30 Oct 2025 12:41: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 1vEVhj-00087d-5b for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:52 -0400 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEVhS-0003GX-2N for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:49 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 4F04180B33; Thu, 30 Oct 2025 19:40:28 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-gYhFg3Cr; Thu, 30 Oct 2025 19:40:27 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842427; bh=TCjKToxw4+lOF11qKeuTQAB3HUw2mNv+VqvMxrCYR10=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=dpGFL/1el1cskG+FODj/IcHUKDYJpojZlqW8wFwiTf2hXO1GsAcw9joWCWhyeP91w 4/yYOwtcONhEyJoP8ag/HPnW1HwBOzgrAZCrRDpWqV2jHwJ//7l7H1qdkaB4uN+TMu UT4KfSdOCGAxSaOfEaZCUEMOM9A8qeDgFPTiVdHQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 4/7] net/tap: rework scripts handling Date: Thu, 30 Oct 2025 19:40:20 +0300 Message-ID: <20251030164023.710048-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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, T_SPF_TEMPERROR=0.01 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: 1761842657730154100 Content-Type: text/plain; charset="utf-8" Simplify handling scripts: parse all these "no" and '\0' once, and then keep simpler logic for net_tap_open() and net_init_tap_one(): NULL means no script to run, otherwise run script. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/net/tap.c b/net/tap.c index 5c6b9399e0..017c184933 100644 --- a/net/tap.c +++ b/net/tap.c @@ -91,6 +91,21 @@ 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 char *tap_parse_script(const char *script_arg, const char *default_= path) +{ + g_autofree char *res =3D g_strdup(script_arg); + + if (!res) { + res =3D get_relocated_path(default_path); + } + + if (res[0] =3D=3D '\0' || strcmp(res, "no") =3D=3D 0) { + return NULL; + } + + return g_steal_pointer(&res); +} + static void tap_update_fd_handler(TAPState *s) { qemu_set_fd_handler(s->fd, @@ -676,9 +691,7 @@ static int net_tap_init(const NetdevTapOptions *tap, in= t *vnet_hdr, return -1; } =20 - if (setup_script && - setup_script[0] !=3D '\0' && - strcmp(setup_script, "no") !=3D 0) { + if (setup_script) { launch_script(setup_script, ifname, fd, &err); if (err) { error_propagate(errp, err); @@ -714,9 +727,9 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, qemu_set_info_str(&s->nc, "helper=3D%s", tap->helper); } else { qemu_set_info_str(&s->nc, "ifname=3D%s,script=3D%s,downscript=3D%s= ", ifname, - script, downscript); + script ?: "no", downscript ?: "no"); =20 - if (strcmp(downscript, "no") !=3D 0) { + if (downscript) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); @@ -971,23 +984,16 @@ free_fail: return -1; } } else { - const char *script =3D tap->script; - const char *downscript =3D tap->downscript; - g_autofree char *default_script =3D NULL; - g_autofree char *default_downscript =3D NULL; + g_autofree char *script =3D + tap_parse_script(tap->script, DEFAULT_NETWORK_SCRIPT); + g_autofree char *downscript =3D + tap_parse_script(tap->downscript, DEFAULT_NETWORK_DOWN_SCRIPT); + if (tap->vhostfds) { error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); return -1; } =20 - 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 { @@ -995,7 +1001,7 @@ free_fail: } =20 for (i =3D 0; i < queues; i++) { - fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? "no" : script, + fd =3D net_tap_init(tap, &vnet_hdr, i >=3D 1 ? NULL : script, ifname, sizeof ifname, queues > 1, errp); if (fd =3D=3D -1) { return -1; @@ -1010,8 +1016,8 @@ free_fail: } =20 net_init_tap_one(tap, peer, "tap", name, ifname, - i >=3D 1 ? "no" : script, - i >=3D 1 ? "no" : downscript, + i >=3D 1 ? NULL : script, + i >=3D 1 ? NULL : downscript, vhostfdname, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); --=20 2.48.1 From nobody Fri Nov 14 17:01:15 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=1761842544; cv=none; d=zohomail.com; s=zohoarc; b=nKOBcyqYMHsVFEZG5qreQLdX20pelNVN30rf+Dvy1Qo63dh4iHxEyWza5LDJxVU1tJpeUHRbHVgdJK54CHgMytoumwsnHgC0wpKgIM+Q12LDbeAFA0uFTyg7L0mVdkg+KG3BPPkMCRHare2PI2F8gDVZUBHLuVFoOMBDKLt8tOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842544; 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=soshIt7UzNY14fx14ZgoSWzIKXQzxzGA/flYljDxDvo=; b=Rwl6Vor67fnmBuSDgDTUlWjkpppYHPPB7LwJaBk1DING992vpdkh62Tn7DlYerPcbD71y0S0ES63B8r/A86FP/f2lCAk7wCM2k0ZxX/1j6Qu5lN82SedfOErk5suXSHmY2/S05Vb3yq8DxbXQZs1aG/EV4jDF0XdbvCZO9li1Ic= 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 1761842544221261.596384618696; Thu, 30 Oct 2025 09:42:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhf-00081P-N8; Thu, 30 Oct 2025 12:40:47 -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 1vEVhd-00080e-RE for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:45 -0400 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEVhR-0003Ga-Ly for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:45 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 21B1A80984; Thu, 30 Oct 2025 19:40:29 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-rV8b6ttJ; Thu, 30 Oct 2025 19:40:28 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842428; bh=soshIt7UzNY14fx14ZgoSWzIKXQzxzGA/flYljDxDvo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=CffCQzy510GHAgPOawiUs6nwkL23IAf/IRoWpYSAwlFxoIMEFgV83CT3WeUTkx8AH cRR+AmEQ5xgSLxJ2+txwcQKsAkhMpc6ujopCjRMdS8rZiBSsKt42yTAy0BeZbq4h8j wRl4esoh58xKCJQ0gJaa/DWUQ7jTeKb3JvwZ2Y58= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 5/7] net/tap: setup exit notifier only when needed Date: Thu, 30 Oct 2025 19:40:21 +0300 Message-ID: <20251030164023.710048-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1761842547481158500 Content-Type: text/plain; charset="utf-8" No reason to setup notifier on each queue of multique tap, when we actually want to run downscript only once. As well, let's not setup notifier, when downscript is not enabled (downsciprt=3D"no"). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/net/tap.c b/net/tap.c index 017c184933..5653578ccb 100644 --- a/net/tap.c +++ b/net/tap.c @@ -326,11 +326,9 @@ static void tap_exit_notify(Notifier *notifier, void *= data) TAPState *s =3D container_of(notifier, TAPState, exit); Error *err =3D NULL; =20 - if (s->down_script[0]) { - launch_script(s->down_script, s->down_script_arg, s->fd, &err); - if (err) { - error_report_err(err); - } + launch_script(s->down_script, s->down_script_arg, s->fd, &err); + if (err) { + error_report_err(err); } } =20 @@ -346,8 +344,11 @@ static void tap_cleanup(NetClientState *nc) =20 qemu_purge_queued_packets(nc); =20 - tap_exit_notify(&s->exit, NULL); - qemu_remove_exit_notifier(&s->exit); + if (s->exit.notify) { + tap_exit_notify(&s->exit, NULL); + qemu_remove_exit_notifier(&s->exit); + s->exit.notify =3D NULL; + } =20 tap_read_poll(s, false); tap_write_poll(s, false); @@ -443,9 +444,6 @@ static TAPState *net_tap_fd_init(NetClientState *peer, tap_read_poll(s, true); s->vhost_net =3D NULL; =20 - s->exit.notify =3D tap_exit_notify; - qemu_add_exit_notifier(&s->exit); - return s; } =20 @@ -733,6 +731,8 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); + s->exit.notify =3D tap_exit_notify; + qemu_add_exit_notifier(&s->exit); } } =20 --=20 2.48.1 From nobody Fri Nov 14 17:01:15 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=1761842533; cv=none; d=zohomail.com; s=zohoarc; b=GaRAdJzphqbplUJOmyBwdeKfsXE88hOZX4riAeayz6kSv0QHTaOlWOoSYrFjn+tiTCE05K/1o+3/eefmPeuUhx4R8EWa4gE+0Fk446iWZy+t/Pr29W+3LbmwuXnwixdh3Ev5b1JVQkoHxbhBz4CevhfJ6grqZkXCQqBDGlR61Qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842533; 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=dN2uRsSbltKwsRIDdUo3yFjYTt9AQiQ4/eCmWAl+qWY=; b=g4iZNMjNUez0TlcaZPw+MILgku8Tgn3R7jDdwBie6Me921yPhtNZok2f9oc0xUlRTxFumo3b7XNQ3f6GkEkRoLJ7npInkVH+OMfL/aDEE1I9ZnSSMhrM76B7SC95iUTeGrMp3G09d1h3GgmMJRxo4FHCIVBBbgd6NQnBkJ7V0xI= 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 1761842532618315.4491262135514; Thu, 30 Oct 2025 09:42:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhh-00085H-MD; Thu, 30 Oct 2025 12:40:49 -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 1vEVhf-00081X-OF for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:47 -0400 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEVhT-0003Gr-Rs for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:47 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 9F6FA80B2E; Thu, 30 Oct 2025 19:40:29 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-kmSYWKH6; Thu, 30 Oct 2025 19:40:29 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842429; bh=dN2uRsSbltKwsRIDdUo3yFjYTt9AQiQ4/eCmWAl+qWY=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=knY7AIiDiHiNv1GH+kay8nt2me3/oh0oKS9ptVlZ9vnamC9J8s4SV2oY8dPiPJO6y fOrzWy1H5EsNCSuC9CjHEwyGZT6xd4KhvCEgDjABd96dJImwseyxQ1xYN1htLBf9dn ItS3qdGIf5WbfXD5Gq7R1LQv+jqdgaBYJ4U2+mXA= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 6/7] net/tap: tap_set_sndbuf(): add return value Date: Thu, 30 Oct 2025 19:40:22 +0300 Message-ID: <20251030164023.710048-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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: 1761842541689158500 Content-Type: text/plain; charset="utf-8" Follow common recommendations in include/qapi/error.h of having a return value together with errp. This allows to avoid error propagation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap-bsd.c | 3 ++- net/tap-linux.c | 5 ++++- net/tap-solaris.c | 3 ++- net/tap-stub.c | 3 ++- net/tap.c | 5 +---- net/tap_int.h | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index bbf84d1828..9bd282b69c 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -206,8 +206,9 @@ error: } #endif /* __FreeBSD__ */ =20 -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { + return true; } =20 int tap_probe_vnet_hdr(int fd, Error **errp) diff --git a/net/tap-linux.c b/net/tap-linux.c index 2a90b58467..db68693bbf 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -145,7 +145,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) +bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { int sndbuf; =20 @@ -159,7 +159,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 false; } + + return true; } =20 int tap_probe_vnet_hdr(int fd, Error **errp) diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 75397e6c54..e5ba89d926 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -208,8 +208,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_h= dr, return fd; } =20 -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { + return true; } =20 int tap_probe_vnet_hdr(int fd, Error **errp) diff --git a/net/tap-stub.c b/net/tap-stub.c index f7a5e0c163..86d7d38e0f 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -33,8 +33,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, return -1; } =20 -void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) { + return true; } =20 int tap_probe_vnet_hdr(int fd, Error **errp) diff --git a/net/tap.c b/net/tap.c index 5653578ccb..ed20155b11 100644 --- a/net/tap.c +++ b/net/tap.c @@ -709,13 +709,10 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, const char *downscript, const char *vhostfdna= me, 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 - tap_set_sndbuf(s->fd, tap, &err); - if (err) { - error_propagate(errp, err); + if (!tap_set_sndbuf(s->fd, tap, errp)) { goto failed; } =20 diff --git a/net/tap_int.h b/net/tap_int.h index b76a05044b..7963dd6aae 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -34,7 +34,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); +bool 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 Fri Nov 14 17:01:15 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=1761842567; cv=none; d=zohomail.com; s=zohoarc; b=ghOv9te5vZ28uexhLvWrpufxpWPOrVXY9Ny7yJO5kmenD8Y2AOUGz1lN8ToVHTNRC+vqQ11T+G2YSJ4XEbY0IAUCg2VyvB31pKKZ+QEIBiiuF8RCMXBTwGft68iR2uYMocdjGYNwBUtkoCOpuf8+fRKCDNJUaW3y9Ng3spigUtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761842567; 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=LGkbs3h02szBvvteV5V6gUdc2a4VCa3Q9sfv9PJwrLg=; b=YQNce3sUpx/SMspWIFv3V/IKzITfPnKBF62KvaIplABuecBki4Mlr/QhsjhSpgK/Tz+/nDaeDAh8V8OuqTlacfNzdO7QFFvwSinyR1nTMLwuACSYx9PgI1I9TxZCjzinApudugzguMtswSe3BEf/V0XE08FL98reoKtZzZbfLr0= 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 1761842567196191.70553069721825; Thu, 30 Oct 2025 09:42:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEVhv-0000D0-VS; Thu, 30 Oct 2025 12:41:04 -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 1vEVhp-0008Eu-GO for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:57 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1vEVhW-0003Gy-1N for qemu-devel@nongnu.org; Thu, 30 Oct 2025 12:40:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 31C9D80B38; Thu, 30 Oct 2025 19:40:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:861::1:2b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id OeiSuH0Fn4Y0-fmnN09SF; Thu, 30 Oct 2025 19:40:29 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761842429; bh=LGkbs3h02szBvvteV5V6gUdc2a4VCa3Q9sfv9PJwrLg=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=ZudjyC+gFfXj6K9H2x4wJ0BOJ2+7T4+jb3oz14hHj4Ujqc2o2o/mxlBzWeflcKz+B b/pb331sTwMMgQbZhBMhpYVFV6h/x3JkfLXz8dbzeiJHYwjtyrn1KVM5aMOOyrjCCG Mwmk+XkzyUDqBxqgureHLlVUAN29uFT2Iy2y5r2Q= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.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, davydov-max@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v9 7/7] net/tap: rework tap_set_sndbuf() Date: Thu, 30 Oct 2025 19:40:23 +0300 Message-ID: <20251030164023.710048-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251030164023.710048-1-vsementsov@yandex-team.ru> References: <20251030164023.710048-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:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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, 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: 1761842569601158500 Content-Type: text/plain; charset="utf-8" Keep NetdevTapOptions related logic in tap.c, and make tap_set_sndbuf a simple system call wrapper, more like other functions in tap-linux.c Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Tested-by: Lei Yang --- net/tap-bsd.c | 2 +- net/tap-linux.c | 16 ++-------------- net/tap-solaris.c | 2 +- net/tap-stub.c | 2 +- net/tap.c | 6 +++++- net/tap_int.h | 3 +-- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 9bd282b69c..4cea60664e 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -206,7 +206,7 @@ error: } #endif /* __FreeBSD__ */ =20 -bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, int sndbuf, Error **errp) { return true; } diff --git a/net/tap-linux.c b/net/tap-linux.c index db68693bbf..bb73fa4b13 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -143,21 +143,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_= hdr, * Ethernet NICs generally have txqueuelen=3D1000, so 1Mb is * a good value, given a 1500 byte MTU. */ -#define TAP_DEFAULT_SNDBUF 0 - -bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, int sndbuf, Error **errp) { - int sndbuf; - - sndbuf =3D !tap->has_sndbuf ? TAP_DEFAULT_SNDBUF : - tap->sndbuf > INT_MAX ? INT_MAX : - tap->sndbuf; - - if (!sndbuf) { - sndbuf =3D INT_MAX; - } - - if (ioctl(fd, TUNSETSNDBUF, &sndbuf) =3D=3D -1 && tap->has_sndbuf) { + if (ioctl(fd, TUNSETSNDBUF, &sndbuf) =3D=3D -1) { error_setg_errno(errp, errno, "TUNSETSNDBUF ioctl failed"); return false; } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index e5ba89d926..e925ca8ae9 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -208,7 +208,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_h= dr, return fd; } =20 -bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, int sndbuf, Error **errp) { return true; } diff --git a/net/tap-stub.c b/net/tap-stub.c index 86d7d38e0f..6aa60d96ad 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -33,7 +33,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, return -1; } =20 -bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp) +bool tap_set_sndbuf(int fd, int sndbuf, Error **errp) { return true; } diff --git a/net/tap.c b/net/tap.c index ed20155b11..3bd81883fd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -711,8 +711,12 @@ static void net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, { TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; + bool sndbuf_required =3D tap->has_sndbuf; + int sndbuf =3D + (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; =20 - if (!tap_set_sndbuf(s->fd, tap, errp)) { + if (!tap_set_sndbuf(fd, sndbuf, sndbuf_required ? errp : NULL) && + sndbuf_required) { goto failed; } =20 diff --git a/net/tap_int.h b/net/tap_int.h index 7963dd6aae..dc4f484006 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -26,7 +26,6 @@ #ifndef NET_TAP_INT_H #define NET_TAP_INT_H =20 -#include "qapi/qapi-types-net.h" #include "net/net.h" =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, @@ -34,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 -bool tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp); +bool tap_set_sndbuf(int fd, int sndbuf, 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