From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030709; cv=none; d=zohomail.com; s=zohoarc; b=U8Kr9i22pVOKu/Qmb76P+hDsRU8c4T7uqdbdY+jkSfZxMj/PnPsEwyB2vbXX5tr+a5YJahdIgIdnWkfweKV+4nvdm04kViZ54+t0ETf6c/8gCFGVUeQjFX/NdkPuvqZIpKnX8Wd1V8Ldnjv2uNZ8viBbZ3eikOn0GlTsrvVewkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030709; h=Content-Type: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=uihaSoHM7LrSDDH5BIzYL6KB1nlD+77aPlq53M6xXW4=; b=Ma79wU+kpWiIidLTl3x99sHNq48XWjRR2Z3j1CSrYt4i0aBo8M6uad6rD0XKhblrZYqZQjdltwG7s7TutsfhC73B0Ggi7RJQajEnAhv+hDWte6Qbe0v18EBAepU5t3ptN8Z6LI5dxXj4ExQ0DkmBFDNpqLDtAn8qO+20qgX4tqI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030709917428.3451401196253; Thu, 28 May 2026 21:58:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpI7-0005ex-Vj; Fri, 29 May 2026 00:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpI6-0005eb-NF for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpI5-00085T-1t for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:50 -0400 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-N_ERN2oEM4egOiTHHX-rUg-1; Fri, 29 May 2026 00:57:46 -0400 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-304e3e3fba5so3116503eec.0 for ; Thu, 28 May 2026 21:57:45 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uihaSoHM7LrSDDH5BIzYL6KB1nlD+77aPlq53M6xXW4=; b=Nbjp8XOfaGqIxkZG/wOmvXksHDxwm9MIFQyhZPkHmdEPrfy3t/IHq6ziEjU8et8lbDZ95q 6DsZWZrhUIWFxsGhLp+wOwc08KA+gXMPyDE8uNhjOQBZ4u8VAbl5iaFwIEi6RS2dgWrQwN l3QMz5YhQPYM6/y1yq3XHqcwM6ll6MQ= X-MC-Unique: N_ERN2oEM4egOiTHHX-rUg-1 X-Mimecast-MFC-AGG-ID: N_ERN2oEM4egOiTHHX-rUg_1780030665 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030665; x=1780635465; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uihaSoHM7LrSDDH5BIzYL6KB1nlD+77aPlq53M6xXW4=; b=dAa4twV3Pb9YI7P0+RqStrPVysJ6o3LdSrFCTX0Yx+1SzFp6zElLdw8DDvYmDpy6DI 0KPCDwF769JMDRl66QKabwnOTupFKqwKj+d2p588sk+qTyPLViACC4SCic+wBp6byByS FlapbMS1LowFgMsOAaDbsd1baZed+Dtvq9Wh71kt4IfBLVgQ+lNaD5rD5OS0UGxq+SNv Le0EgpJ7z1Q9qePM+LikokoHrEgNnw+jsrI+6RLZlrQxZZcUOzGoXcrGuIaNxKA7nkE+ CWz+5SriccA8wWRh87SIiogiLzkQRb1g9m8TH+xZflzDfSB3LfHRuSN5c3dWJvp835X3 s/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030665; x=1780635465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uihaSoHM7LrSDDH5BIzYL6KB1nlD+77aPlq53M6xXW4=; b=AlTuTuw0WlP84PANg6eT/VeqOWyWEByBJwGXppZWiFG5CMJDRZFxyplc2MG27FNKsM myTEPbitZ/tOqN5A/MLvDfYeYPr0U2UU6Rw0mAH8azZCOkKOzWiFS5TkUcXOKeG67L1b Z3HEJ+MJZt/wPBNQtZEDraRIsqD1uxykmVF9uoJM1IKrnBJWF3seNCda8ylqsTWWV7nP sbWaPuBgcOdFyoH2Nj6WzAnPSF+MCJe2PZESpvqtgP2n1bJpMojufbN8IGN/XRdvY1/a nk7OIdQ9ecSyWho8aGJmNySCPPYrnYSeXfWk3DYKXwBFmvUr5kltFa650DX9w/ipLJY1 CIWw== X-Gm-Message-State: AOJu0YwMtUQZUx93LtxvudKlKtthnZxbz7896YSBYX0QUDBUWHsU23WX W0tCFLQFs+AvZQpEH/mzx5X5eIcNDJYBuv7YhBgBlw4kks+eBy1+iRKQZmsEc0az6uAi1MlApkE J5sNA1REKUeWjolRbDDwio5GGJTa157yYnScbsgt5P8ByzpUv+KHse4ZVN6ey1U7kumVnKsauRr KOGGtb+/kH6vcR8waluugy1X8tTNCye/CYcvqHkOqE4lA= X-Gm-Gg: Acq92OF1QA8g9nn6wNETFlnDWgwELdFQTllAqhe0aG3MzANo94b7ocNwp1OUxsO9aT+ AOTmlvY1/08rthRTWgWsC+kxPJ/nyeSNJ9ED7Eql9HhPDsHnYS6mcOAP/pppmN/OW7NZhGUK+Os m/tQkO+Qq1dx2CR1e5ctNzP4miMnWOII3aFGs/NSiU8864t9t/1yFt4MF9KsB1R0FpHaSvXoqXQ Rxe2dwbWipNoVcBlzrFXpskwa2+WxMtQTQZzh2V2s8FOFm6oyvRBR9WKVevprhSPqFWLayXfEBf RxkeMVS7i9H2VtnVwK4GrMbw1JBSL5/2jSOgsOkJLBl6bqq/QyrWEgoeg/QJjoxz3MmzwQK3yTE 13u6VsIVcGhSXqt3YHh7x07m8TsWju+vwb+v8j3BL6WzUZquiYX5xjCYoD4Dj9RevLfgsBAMz X-Received: by 2002:a05:7300:80cb:b0:2ee:ade0:e0bf with SMTP id 5a478bee46e88-304eb161d6dmr628786eec.30.1780030664830; Thu, 28 May 2026 21:57:44 -0700 (PDT) X-Received: by 2002:a05:7300:80cb:b0:2ee:ade0:e0bf with SMTP id 5a478bee46e88-304eb161d6dmr628773eec.30.1780030664115; Thu, 28 May 2026 21:57:44 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 01/15] net/af-xdp: fix type overflow Date: Fri, 29 May 2026 12:57:16 +0800 Message-ID: <20260529045730.90322-2-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030713392154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy In for-loop in net_init_af_xdp, we do nc->queue_index =3D i, where is is int64_t for 0 to queues-1, and nc->queue_index is unsigned int. Also in parse_socket_fds, g_strv_length() returns guint which is equivalent to unsigned int. Let's simply use int type for queues, and update the check appropriately. It could be unsigned int, but in future commits we'll share with net/tap.c the common function which will return number of queues or negative error. So, let's simply use int for queues-related variables, that simplifies things. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/af-xdp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/af-xdp.c b/net/af-xdp.c index 14f302ea21..ff1cb30a98 100644 --- a/net/af-xdp.c +++ b/net/af-xdp.c @@ -442,14 +442,14 @@ static NetClientInfo net_af_xdp_info =3D { }; =20 static int *parse_socket_fds(const char *sock_fds_str, - int64_t n_expected, Error **errp) + int n_expected, Error **errp) { gchar **substrings =3D g_strsplit(sock_fds_str, ":", -1); - int64_t i, n_sock_fds =3D g_strv_length(substrings); + int i, n_sock_fds =3D g_strv_length(substrings); int *sock_fds =3D NULL; =20 if (n_sock_fds !=3D n_expected) { - error_setg(errp, "expected %"PRIi64" socket fds, got %"PRIi64, + error_setg(errp, "expected %d socket fds, got %d", n_expected, n_sock_fds); goto exit; } @@ -484,7 +484,7 @@ int net_init_af_xdp(const Netdev *netdev, unsigned int ifindex; uint32_t prog_id =3D 0; g_autofree int *sock_fds =3D NULL; - int64_t i, queues; + int i, queues; Error *err =3D NULL; AFXDPState *s; bool inhibit; @@ -496,13 +496,14 @@ int net_init_af_xdp(const Netdev *netdev, return -1; } =20 - queues =3D opts->has_queues ? opts->queues : 1; - if (queues < 1) { + if (opts->has_queues && (opts->queues < 1 || opts->queues > INT_MAX)) { error_setg(errp, "invalid number of queues (%" PRIi64 ") for '%s'", - queues, opts->ifname); + opts->queues, opts->ifname); return -1; } =20 + queues =3D opts->has_queues ? opts->queues : 1; + inhibit =3D opts->has_inhibit && opts->inhibit; if (inhibit && !opts->sock_fds && !opts->map_path) { error_setg(errp, "'inhibit=3Don' requires 'sock-fds' or 'map-path'= "); @@ -537,7 +538,7 @@ int net_init_af_xdp(const Netdev *netdev, =20 for (i =3D 0; i < queues; i++) { nc =3D qemu_new_net_client(&net_af_xdp_info, peer, "af-xdp", name); - qemu_set_info_str(nc, "af-xdp%"PRIi64" to %s", i, opts->ifname); + qemu_set_info_str(nc, "af-xdp%d to %s", i, opts->ifname); nc->queue_index =3D i; =20 if (!nc0) { --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030703; cv=none; d=zohomail.com; s=zohoarc; b=Qir/awfHErI4aSg252DdfVC96jXhWFSzwUp+lNcL+ses3ZeQyrOuH541hbzwehx3Sdn2PTAYNOxUFiBbsfh8d1mIBNcoL9bLF8Pn4j07p5eVtJX1M4z9APUnRcjG+ANIQcPuivMA0P1QFcSU5CitbhRBpQUH5loykfIVKPiiKaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030703; h=Content-Type: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=AEzVLZ1GXyHFH+/ory9dQMaz4t7ZvXxDRG8tjc701tI=; b=bIlXA2I4LF6zN7lqc1ZkJuLkLVzlI+nQ3ZHe3WDrlYYbZm3IXenGlBAjNitKHTpIQlh5NVe9k7QQA1y8gArJWwESynJTJmHsmwZzx9z/x3htTDWmsUHkqFOOE1Jh6ZVHSG/AdDEN0h3Z1RltqG2dxODqk2E0PNGluVFaWrbXSy4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030703063653.0059108276513; Thu, 28 May 2026 21:58:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIB-0005fu-OF; Fri, 29 May 2026 00:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIA-0005fW-CR for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpI8-00085s-FV for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:54 -0400 Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-5Qe6gaVHPWyF2OaLasoRjQ-1; Fri, 29 May 2026 00:57:49 -0400 Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-304c652be4eso1431776eec.1 for ; Thu, 28 May 2026 21:57:49 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AEzVLZ1GXyHFH+/ory9dQMaz4t7ZvXxDRG8tjc701tI=; b=W0Ckw56FfQVwPgkdBPdOl/PTs6OecYK6+MxGmvW2Ud4OH0dNAmrFvjsLNpC4NJuXIjbg2G h52u5Q6S66UrJwwfyCY6eoZz2UQypJp96O7Tr6rDlteZkOtbAKNWES7/D2KVzYVc0QqL5L qtn7s8f4MKuqFLbY5OiG4Rc3hHNtOY8= X-MC-Unique: 5Qe6gaVHPWyF2OaLasoRjQ-1 X-Mimecast-MFC-AGG-ID: 5Qe6gaVHPWyF2OaLasoRjQ_1780030669 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030669; x=1780635469; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AEzVLZ1GXyHFH+/ory9dQMaz4t7ZvXxDRG8tjc701tI=; b=AzOjb9ZvwtAytwBHvZAwftOGVSA8Tb+M5gNdCYSoI4sOcWaHG4TeN/NLV6FnKWKEZq +En5zKJQpCQ7sAxyYXjVzPknvT6Tmgws3PdGEnT2MDP76NVeQGCMM6tCJCOkFVpD4gm0 VgiFikZDZrki0n6sEys7JXQtT4ckz0Y+PHF06682IwBkFF4QTOmjLVNu02z15GHu2FyV v+je0hn9mhUpf/5rRqOBvfDzWNBfleSVGvq2KvmnL/ZdO4kIY0ArZKVTAxueieS2qVem 994b52dv3MpMmFqqAHLDHRdwi+9BdNB7W9OoTHWaDHKAgMmBvc2tX64OUUj63/YAwfrN NstA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030669; x=1780635469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AEzVLZ1GXyHFH+/ory9dQMaz4t7ZvXxDRG8tjc701tI=; b=f8xe04muZxUDY9QdROnX7VICHnmV/pkdFCUEKVjKojojRAWCsJeoDxk3Imq1xjZ+Xm AOxIoUzLZFg7uMDij6p1zmzO96bq6JgoboeXlJmU20VUW/0fH7LVhbip8J1+kjYTuv/m gY23FCF2MppeOWywoGnd3F9hTQlaxYSFN7FvVKL5ujfLFWqHUq04yc5iScMN2RneJleA 8otZWA445c23ebBi1TmG8KnCq1uIJ5LLKikYcyrgYP3HrfshcYhxbSo9xVb+Rnmpnl5f qHCQs7vxaqX4eSreHUxaN5F3rxkWwNWhhvV5ZiMHzjj/XruwZevo+1mzfDOwnNjNdOSN BXnQ== X-Gm-Message-State: AOJu0YzYyLfqFAD5g5a6eMEPaFIyQ+pBKuQzlkPB8CtpPfjBdCXUs6Qn iFkHwMqTUWw8Y4xyQErgR3rWICm9SshLsJweyyt+vfFN8njL1a+ZhggEgjkBjwSiYBxO6JPVD1v YEU0pGxNUbXunn0m0bf5kWEDibhJHgA+gVeGKZbhCfJEclfak3h+1WZwARqBJl6E7h53GUdz2cs GrzIAQ6QfPWzVbUsABnPMLWLcdFC2H22RVD9oRkzcOuxs= X-Gm-Gg: Acq92OHuWN6mPZ0VXinquqk0m92LzWhAxBaR2jYeZoWOu/S+o7JTQ/ocPvIoSRu1Sm8 lnX87J4C6fxRetIqkQtMjkJbq7H8DhNkdEqTm1LwRO3uuBQ4Ij3EiK+3P9YpI2hkYf/nAh5CqNc L8qCE9XmKkK8M3Ygot6iErjAhEw/JQqejrfXfj+xpCJ3stbtV7qpa/QcZtNB1+WC98qO7BiGvx9 9GVBFSRaaWIPww6OUBjI6YB1Ok7wwvFEXSLtfnEReel5eV6VIckeCFYdkthrO5BDT5KSg1LN5aq Pfa1yqOiLdCOZBCPsgUe9XuC4I+PDHt7p8WHSt8YSz9CB9cOKfRq938tmkole3uTRkJOcLjU7WX jp/rWUxEJhUzZvkYixa1piI4Qh+qkhFAf4iIgmTPKm8+IDtgfm+UAHCUg1p+XZ7QjPRVynCKN X-Received: by 2002:a05:7022:f411:b0:12c:9037:5126 with SMTP id a92af1059eb24-137ae515e54mr462274c88.9.1780030668703; Thu, 28 May 2026 21:57:48 -0700 (PDT) X-Received: by 2002:a05:7022:f411:b0:12c:9037:5126 with SMTP id a92af1059eb24-137ae515e54mr462262c88.9.1780030667983; Thu, 28 May 2026 21:57:47 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 02/15] net/tap: net_init_tap_one(): add return value Date: Fri, 29 May 2026 12:57:17 +0800 Message-ID: <20260529045730.90322-3-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030705435154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/net/tap.c b/net/tap.c index 8d7ab6ba6f..a389aec218 100644 --- a/net/tap.c +++ b/net/tap.c @@ -703,7 +703,7 @@ static int net_tap_init(const NetdevTapOptions *tap, in= t *vnet_hdr, =20 #define MAX_TAP_QUEUES 1024 =20 -static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, +static bool 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, @@ -783,10 +783,11 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } } =20 - return; + return true; =20 failed: qemu_del_net_client(&s->nc); + return false; } =20 static int get_fds(char *str, char *fds[], int max) @@ -821,7 +822,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 */ - Error *err =3D NULL; const char *vhostfdname; char ifname[128]; int ret =3D 0; @@ -869,11 +869,9 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 - net_init_tap_one(tap, peer, "tap", name, NULL, - NULL, NULL, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, NULL, + NULL, NULL, + vhostfdname, vnet_hdr, fd, errp)) { close(fd); return -1; } @@ -930,12 +928,10 @@ int net_init_tap(const Netdev *netdev, const char *na= me, goto free_fail; } =20 - net_init_tap_one(tap, peer, "tap", name, ifname, - NULL, NULL, - tap->vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, ifname, + NULL, NULL, + tap->vhostfds ? vhost_fds[i] : NULL, + vnet_hdr, fd, errp)) { ret =3D -1; goto free_fail; } @@ -975,11 +971,9 @@ free_fail: return -1; } =20 - net_init_tap_one(tap, peer, "bridge", name, ifname, - NULL, NULL, vhostfdname, - vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "bridge", name, ifname, + NULL, NULL, vhostfdname, + vnet_hdr, fd, errp)) { close(fd); return -1; } @@ -1015,12 +1009,10 @@ free_fail: } } =20 - net_init_tap_one(tap, peer, "tap", name, ifname, - i >=3D 1 ? NULL : script, - i >=3D 1 ? NULL : downscript, - vhostfdname, vnet_hdr, fd, &err); - if (err) { - error_propagate(errp, err); + if (!net_init_tap_one(tap, peer, "tap", name, ifname, + i >=3D 1 ? NULL : script, + i >=3D 1 ? NULL : downscript, + vhostfdname, vnet_hdr, fd, errp)) { close(fd); return -1; } --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030789; cv=none; d=zohomail.com; s=zohoarc; b=ZmWAqOcpsL2SIlqR/ZokuMeDvVvXBBvlgbF3oEiFV/173d1h/a2LGKw1+EN+CownuxgU3uVgea7DnLomfeZPUXfvtnGk77WcEbw4RqgOJPvp6Ia1HIfu+rC/mokMHKoCtq69Oen/qqEHRRuJ5/W8vkq8ZUGgBKW1PwEoe1hnG/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030789; h=Content-Type: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=mulJDhFXAKpDPbSq+OgUy/fpJcNoIOEb6I4PhYcrchc=; b=JptJsJWh4bY+OnM3LnYQ7Xs6BJSfQhjd4AsuE/41ODFTqgn8qAFmrG5nCZkwdGON9/3lBO+XNVumVpka1nP+Nyl+KG3qzMpbzTUjTiwFRHX7Vbl2U57cNVCUin8L3xmABGd/3UKWKaLBceD4A+Ba8QQhePjM8qnRhkaahTwtScI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030789208264.2219009314241; Thu, 28 May 2026 21:59:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIE-0005gA-Ag; Fri, 29 May 2026 00:57:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpID-0005g2-6F for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIB-000869-Mr for qemu-devel@nongnu.org; Fri, 29 May 2026 00:57:56 -0400 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176--yyB7lP9MPyOrcAqw0UJiw-1; Fri, 29 May 2026 00:57:53 -0400 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-304efad654dso300189eec.1 for ; Thu, 28 May 2026 21:57:52 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mulJDhFXAKpDPbSq+OgUy/fpJcNoIOEb6I4PhYcrchc=; b=Nf4xPdn5uYHsP/LAzJ3tmUWjNwdaX8GpXxk7aim5HRCpMpAGHHjF2Lkk9J0OkJbN9F8DsP HN5SekaJ7Oh1ZK2B6H6MA1X9fNCQC4wy2/qRFdxUrUvoSMv5sryjfSz9RWj9nDp/XEpspN T+cf8kHomPfcKuHPawadVyNtNl9xrGs= X-MC-Unique: -yyB7lP9MPyOrcAqw0UJiw-1 X-Mimecast-MFC-AGG-ID: -yyB7lP9MPyOrcAqw0UJiw_1780030672 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030672; x=1780635472; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mulJDhFXAKpDPbSq+OgUy/fpJcNoIOEb6I4PhYcrchc=; b=Ypl44cnZIXra3nZdIWoJFnzC1Q4rscptbf9KFEHJ2G4ZzDJt91VPKMZ68vUCcW3bSU JM7pK+tBsVQ9hlGtE8ZnYniFfpeiodN/lwd3Lh/fo0R4/LEPXSuRJ/yZsUJr7uHSouPo OLCQcbk1x65CxTvCJJRu6SwATfKmQUqkrn/EZv0dEWGRIGf99wQywpsND1OkeUviQzoM hE1UM3nPLUmAoJif2U+/Wqd6HYDbDhzUcOaRTuH/kQ3jWC9lZKKyjj2iJg+HSLTTR4Gd QxVKlNMyqGCNTVb+r91gZS/SK9P4j0Qq6kQkFXDXg0O9jquEZCq3JLC0EWY6wZ3m4Bwg vHMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030672; x=1780635472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mulJDhFXAKpDPbSq+OgUy/fpJcNoIOEb6I4PhYcrchc=; b=kaM9yw7FUIrEb2sylVODDTZkPOFTylyPw70l4z2WsLXkWR4yWJCpvBDyATcj7qWy+H HHgF7eDNzQTn9VYgHVk1tu4MEV1l9k4UTKWN3XpnaCucGS3ZgZUljWOIRI80mOqva77n a+LHnFjJlG4roC7aNd1Gx1TiPAHBmLCCAhpM8lejJMGtxnM2FecJ+8YniqFmm4itxDYa iiox7L8mzAnD5O0+JGvbvwnUjZ1RGKKXIdcewOkBM3lfSPpapm6FBsQepgb2ZZFohiL8 z4b0nRrY0vIrR0uy64iB9LetTw4JIXY7RyzTxkBau2EHraA7OxXpjOznrPn4HqS7BeZf bhOg== X-Gm-Message-State: AOJu0YwzfVi8tlBZ3cDOgtq/v8472TuG2B/kLupUG3GHpJIZFqVBP7Fy ZBaLITZDtgj/bN8otzocNZCqn0gc4VtFMibGRGBparNZpPR/2BA9bloTvJvApcFQyE+mRUk2V5N xwWWzOIwceUEncWHT7eGY+aKuJ+GMJ7JZMyaldZaCEkKPeffMN0zgOboJwUd9JsAR70XNnEftPQ UNZ+2jennp3lS6Xk73XNe/nCvLPsBjdY/OdkySfrsJuR0= X-Gm-Gg: Acq92OEZgTMGnuaZrE84mAqK43+QvrzmE1Hn/Tu30WFSt8h4fk3HSVyCMaF3UYKfL9a RC5+/1KXVVNZnwri2ldJ92PeeY6s5JaAvIMABO4HRBGnTkh2sf3P8E3tcuvLJUA+jAlY9Tw2eHB KUwfURJw1ddzU1K1rUZhb0kVYUCZNTgP3fCqtVgvvRD6W5pZ4TcfAu44yWeyAu+yMmdVe6GAgkl pgZJH+P5/0GhsU2D7k51F0F+tNBoQ0X2prbTp+4vWfVbSGoD6bzoDtdvBO3ATseQKxRBVWfUIAt 9QCxo3fAyfWiwO0MUaUwA6yaW94GPWBPwr4e4GBzcGA8Riv2C8T6bsash3wDu/R5Lg5cX7xMmir vL2lQRZBZVaX3TmHvkCXJq3LL+lb1qQmBdjNmaqpkrJXfoovq/YIt72p/I1C1LbCGR5ZeZ3B0 X-Received: by 2002:a05:7300:2d06:b0:2f2:32bc:787d with SMTP id 5a478bee46e88-304eb116620mr651307eec.23.1780030671787; Thu, 28 May 2026 21:57:51 -0700 (PDT) X-Received: by 2002:a05:7300:2d06:b0:2f2:32bc:787d with SMTP id 5a478bee46e88-304eb116620mr651296eec.23.1780030671095; Thu, 28 May 2026 21:57:51 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 03/15] net/tap: net_init_tap(): drop extra vhostfdname variable Date: Fri, 29 May 2026 12:57:18 +0800 Message-ID: <20260529045730.90322-4-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030790581158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/tap.c b/net/tap.c index a389aec218..55b8b33ea8 100644 --- a/net/tap.c +++ b/net/tap.c @@ -822,14 +822,12 @@ int net_init_tap(const Netdev *netdev, const char *na= me, const NetdevTapOptions *tap; int fd, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ - 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; =20 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ @@ -871,7 +869,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 if (!net_init_tap_one(tap, peer, "tap", name, NULL, NULL, NULL, - vhostfdname, vnet_hdr, fd, errp)) { + tap->vhostfd, vnet_hdr, fd, errp)) { close(fd); return -1; } @@ -972,7 +970,7 @@ free_fail: } =20 if (!net_init_tap_one(tap, peer, "bridge", name, ifname, - NULL, NULL, vhostfdname, + NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp)) { close(fd); return -1; @@ -1012,7 +1010,7 @@ free_fail: if (!net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, - vhostfdname, vnet_hdr, fd, errp)) { + tap->vhostfd, vnet_hdr, fd, errp)) { close(fd); return -1; } --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030782; cv=none; d=zohomail.com; s=zohoarc; b=nntOXmaf5odsF1VYEUa+G1Ze/zuP0a5HZ4ElhxNNsH7jeFeOn2a4kEgrkCW3ZFDtY/wYAELo1vvVlmNPi2lI31AL9Gi+7Kh7Aj+vqk/O37ydEg5sgc2/q27WfQkPqYjZVD+QT4K/F+k+urIhloLNY8x+AagfAHnEBaAj8Av+CMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030782; h=Content-Type: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=YU/NlBoWE6VBtjpdcgX0vRzu0ouBLdi1u6lcRcjVnYo=; b=C+9cp4ltTZ1yqqvgrLIfW0aItOyg7JIKWVeCXun5qnOOGrr759YESUNElEl4eYR+YeXSFhq8bdGe1WycxjK6XQvFVVZELv0Fj3pM8f61I/Tou9fkgpGzj2FkwCnfCX+Pvkk3U2meDFO5SE8OjgAZSTdAlVd69ZvT8RQbPqkPinY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17800307824518.368648043110966; Thu, 28 May 2026 21:59:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpII-0005gs-8O; Fri, 29 May 2026 00:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIG-0005gQ-Ib for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIF-00086a-1t for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:00 -0400 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-yls1u-NqNe-qLxJQD77g9Q-1; Fri, 29 May 2026 00:57:56 -0400 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-304ee7d1368so115601eec.0 for ; Thu, 28 May 2026 21:57:56 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YU/NlBoWE6VBtjpdcgX0vRzu0ouBLdi1u6lcRcjVnYo=; b=HdsVON+ix55LC3Pbnv2gMPrThs+qC+SYp/WcUUd2P5wi8963Yw4EvQMJg7eSFJ+uS/NCcY ZQPkguVZuxi28gpQHoX+8fOHPRiYbzl6Mof5eFWlrs3yMMdwqtsUC1bbYehg/WJrfnYkLP 9TuWIwgsDlMKnm7OFLMPF6xU1gKAc4k= X-MC-Unique: yls1u-NqNe-qLxJQD77g9Q-1 X-Mimecast-MFC-AGG-ID: yls1u-NqNe-qLxJQD77g9Q_1780030675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030675; x=1780635475; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YU/NlBoWE6VBtjpdcgX0vRzu0ouBLdi1u6lcRcjVnYo=; b=eY09Oo19SMmSlmoEoYIrExjEQmfF1IKwdmaB76EslNGQ6t9RBTq6KIxUGfB1fD1yFL PKaKCE2/IrZOdUKySq2pS/jiMPNtPyaMOEoZhBMhAi7fEAGtBTvQ7gY5CDbkBF22mcVV nDoLTM4OKEWJ4ixIKf11mBKcsbTn1Q7eiqKFyG3DjLwcWOOC2ZSdz1rSoEritIuvGVzg VsJyEB27Lp45C79K6oPARtSIKa6JoxNzvbAKEONNjy3dpSyqCHBjVAMLHVysijSCKhAf 3Tf2qgXEolJoqlc9jqJVo7AghgqvzGLbIkwHG2mUWkkXvLKI+aghnYY5we1C5Mi9Hhbf HlRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030675; x=1780635475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YU/NlBoWE6VBtjpdcgX0vRzu0ouBLdi1u6lcRcjVnYo=; b=O9Vd5Z4JFObLfEPou34sT+ZFpImyPH7rrw97rz9stC9H/RC9XhZpqjqemsUXHGZfQC Hq/WE+LHq0Ysv7K4RcJNRsehlOnZSIslsXmJV9+z1EHEQD79dbEZ9lHSbsPncJSvf0dv y7ZiD+FL5gbhUwCVkIxaTHidEv4ZPTfRaybyGrTDMNKQVk23ZBAcsjgOrcHLertOhejA Uc9Zg+J3pkqfmw7UtbPN7qnobaZ8GGhwKYbuQaaDM+tHYehbOISWBCklkN40L+Q8WEyf edodq4DwWlrbofVgkn7qSxXnE7Z9ipesfC9YqDn0eP2/RRmoS7NZsTmyYpmijf7ZYxlb 4TTA== X-Gm-Message-State: AOJu0Yx5hgVrhPsZNFfUG5TBrFoWrmtiGryI3Z9JrV4tMH1icwtof0GL 3po8iBiWppkHb2ZRkxtByF+c5OqzZh3hw+BVqLh/tKjufXRG7BwWgkLfg2j7hSMOC39dGu5LIcl 3MpiLFGD+oBhRlVWnTwu/+s2Da8yRaa9AnixAkdAmVX6AbUOi/8wx2f6W2b5HYvl20UdiZYHLh2 UpNsjBCF1M0J/LttL5swopfFcXz3UaJ98IHis43zciU+I= X-Gm-Gg: Acq92OE8GihIJgzT23pZl4i58nDPGq/Z/wUNNfTkoZUB248RDXMUPFU3wkHEC5RMXAY uUU6wcbchU8E90KLjgE3H9WuCyOuUcsbasxFHjalomqJBgJ2OMcDPefRPbxrYmkcvoVrQsar9+H r+ud66in4bvvR2qKyVmB1t66yZACngQ0vd6t2PSCB1j6+vhgZU6/ptFaf13pPt2at/D7ScXUtl4 nAU88oHIvwcEPK6E5eFBuflevLnCXjuoKZ+AyZSsXQWw1g9cgv/oZ3dfANYoZF7klQye1DcSF/c eFD+sqTmBhKdaFP8hyLKPKhPKgN1jZUsttpkuMalxJnGfNBGet0+MIBNbmVRMQsKIegX0vSga+J cC0xNLM04H4QrjQVNwILvKBt+mbbCjW1HV7JSz3wdzMxRyvNvOKO8dxceJWJzXfruMMg2jrIJ X-Received: by 2002:a05:7300:dc88:b0:2be:7fc2:fc38 with SMTP id 5a478bee46e88-304eb06d19fmr790047eec.5.1780030675144; Thu, 28 May 2026 21:57:55 -0700 (PDT) X-Received: by 2002:a05:7300:dc88:b0:2be:7fc2:fc38 with SMTP id 5a478bee46e88-304eb06d19fmr790030eec.5.1780030674452; Thu, 28 May 2026 21:57:54 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 04/15] net/tap: net_init_tap(): refactor parameter checking Date: Fri, 29 May 2026 12:57:19 +0800 Message-ID: <20260529045730.90322-5-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030784244154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Move checks to the top of the function to simplify further refactoring. Merge duplicated checks. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 53 +++++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/net/tap.c b/net/tap.c index 55b8b33ea8..331a779585 100644 --- a/net/tap.c +++ b/net/tap.c @@ -841,16 +841,30 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } =20 - 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 " - "are invalid with fd=3D"); - return -1; - } + if (tap->has_queues + !!tap->helper + !!tap->fds + !!tap->fd > 1) { + error_setg(errp, "queues=3D, helper=3D, fds=3D and fd=3D are mutua= l exclusive"); + return -1; + } =20 + if ((tap->fd || tap->fds || tap->helper) && + (tap->ifname || tap->script || tap->downscript || + tap->has_vnet_hdr)) { + error_setg(errp, "ifname=3D, script=3D, downscript=3D, vnet_hdr=3D= " + "are invalid with fd=3D/fds=3D/helper=3D"); + return -1; + } + + if (tap->vhostfds && !tap->fds) { + error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't specifie= d"); + return -1; + } + + if (tap->vhostfd && tap->fds) { + error_setg(errp, "vhostfd=3D is invalid with fds=3D"); + return -1; + } + + if (tap->fd) { fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); if (fd =3D=3D -1) { return -1; @@ -878,15 +892,6 @@ 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"); - return -1; - } - fds =3D g_new0(char *, MAX_TAP_QUEUES); vhost_fds =3D g_new0(char *, MAX_TAP_QUEUES); =20 @@ -946,13 +951,6 @@ 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"); - return -1; - } - fd =3D net_bridge_run_helper(tap->helper, tap->br ?: DEFAULT_BRIDGE_INTERFACE, errp); @@ -981,11 +979,6 @@ free_fail: g_autofree char *downscript =3D tap_parse_script(tap->downscript, DEFAULT_NETWORK_DOWN_SCRIPT); =20 - if (tap->vhostfds) { - error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); - return -1; - } - if (tap->ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); } else { --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030742; cv=none; d=zohomail.com; s=zohoarc; b=lt/GXHsULwc5OaeekxTvSTSX4C2aRyAwC5SgfLuNjoYtDdu+ezvhEHerT39yoRI6y9UoxZm5Xsvi378Glu0InaS2SmTMt0Tmaj/z3VgLha873jAn7OoUrMNA2CMIbnbecmW1yBtlyFqeum5ywGSeNFuDBrNwhDYieLHiKgGuUrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030742; h=Content-Type: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=wXgUoz2kDhdvNT3gb2pcIb2zVVrprNZrWtVAiaM5OzM=; b=dg5arF/fVWxAPbPb2FkgMsZbXhh5mNMlz1+E8Z36T//V5QT3s2wsyUhd8QALVDdFOBMlLe4ixCAObsb9gJtKsre4s9hm1I47cfm9v1pEcKsJcl2Jo0QyFLYNUayQXBGBk58j2OWqJlkSF0PtKqwCmVOqkD7imRefe+b/LtrZ0yI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030742253752.1839282784425; Thu, 28 May 2026 21:59:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIO-0005hF-Oq; Fri, 29 May 2026 00:58:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIM-0005h0-Nq for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIL-00086w-0M for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:06 -0400 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-fdFzWZ5zN3SdZJnuwhXmbQ-1; Fri, 29 May 2026 00:58:00 -0400 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-2fe1cf409a1so3524656eec.1 for ; Thu, 28 May 2026 21:58:00 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wXgUoz2kDhdvNT3gb2pcIb2zVVrprNZrWtVAiaM5OzM=; b=amt2mN6YC0wTRbWE8iroO51yIXklysFaueGkt+srUAbsaUQxNd1CDFQ66Xbowehaf81tf7 nPb6FxH0z8DJ74zqcBjb7JSin7ZPnMyWbnlsWoo+0CmL2xH7K4ZohgiNgZUvgevDm9ickJ Y666SDZWJYErODslbFSJO5KgoT1FJb0= X-MC-Unique: fdFzWZ5zN3SdZJnuwhXmbQ-1 X-Mimecast-MFC-AGG-ID: fdFzWZ5zN3SdZJnuwhXmbQ_1780030679 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030679; x=1780635479; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wXgUoz2kDhdvNT3gb2pcIb2zVVrprNZrWtVAiaM5OzM=; b=TL1mFPswIlDL+iVtPxk3NWwPZ2omZc+VVptckxZMkuFZAU8UFzGRGIPCbqi7PTEp/f 6apf+JazW0Gqb5suqjVT5vwXo+USrOmHCT+7V2r0COtYPKpGrJzUjIhvdP1d9KsI8lVF SC1pZgWl8OVfeQsYIFgMGB4EygAIo7FtRD3PhCnSjJxhEs9yUcDRyEoHrWzXTO/tiQW0 zyqlV+3f06BTntaMG+IMfjIEZSSx6IsZ6vlWgoKnfM5STInh+qc7NyrOcFVuEc2kbOD+ GsN5q5jBMc6A5ncAS/ATqsbjjZVoGHSjYptXkb2bEfcRdqyknMbIqCgAH+rmFk0QNWPb uDXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030679; x=1780635479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wXgUoz2kDhdvNT3gb2pcIb2zVVrprNZrWtVAiaM5OzM=; b=IvkH0SYWu+CQmT/bNgkOBGxDJOqhJgJCYKKkDA0c3PCAb7Tvuhs3vVl3L2nnV7EUqO B1ImB8eCLFBoEZIlEPjcbA1Mq6tqgCD2TgfXXfPHsvHmDFBIEUtodT07wVQ8O5Em4ph1 TRLdkRqxgTZsZZE+T+2/Tmls45mKVu2ilh7hl7KDLd8+zgNwRlU+XGzxfnSqiLQlQsei qHaa1/Pp0Zu4xXpiBLKfJVcwbkCSWw1t0HfVjH64yzNng9Hh4EXyBjnHvHAV0G9KUZ/t iGqLsZXroi1/eHaTPTENWEgwhCXvEpVvJ5LNasjutHNk0sGX3Y9id9QtsPPY+8kUVJrk P1gA== X-Gm-Message-State: AOJu0Yzr0m5syFY3bhdE80LOFYeqf0Fsu4swtlIHcw09kwy9Yi+asijo 9vnee6Fcih4zkm5YQZg4cMEYAuMFEIPtDNXMzh8ZTaZ0E90FacgFJv/MkoURdr6jioQcIt2AWcz FlfKlAlxVVHGPordri4FI6q191svINPN1MVLJkzRmYKApiKFBBaObCmKQM/GWGH5Pgvp7QB8YSX NTmVqedalBx4rz/t1KJ/G7fy2EJAcEVpI2xQ68aLrUYbw= X-Gm-Gg: Acq92OEKup7IvVVH4Gfo1hc2+mU1bBE329a7hFQkgAmUI0E8NYqg9akX6wUgXOeVVam wDOjVRkv8JSlsUjX1uvv7XiqOpbRlmpTDyGqBPXJJNmOrB7kXHziV4uvmDA/pPyRWFZDK1G48wR HtrPD+z5N87H6y0nXq6E17N5z7r4w91kU+DChgxf5+uUFrpA4fUhQRGTmiokyixZ8n6UiCxpZNP S1w6Ur8FQ48jOaTp322oRv2jYq+3jY4ItLWxzPCpUrOL6ehAIOcEdcp34khF6TMJsixORGut0Aa vNHPppRROIVmgVusYup1RT8a6d5o68wMqqCqeKagR3LqOGiYOLZBDjd4ELAtlIp0pFJnXsqDwte dBJVgkEy+RHWWaUkBcbGQ+8mI0ICmivLLgAnYITMofuqVsSMV3TQE/hvN+58EB/Z12slhBdeL X-Received: by 2002:a05:7300:6d21:b0:304:cf6c:4cfe with SMTP id 5a478bee46e88-304eb0bcb61mr605314eec.9.1780030679368; Thu, 28 May 2026 21:57:59 -0700 (PDT) X-Received: by 2002:a05:7300:6d21:b0:304:cf6c:4cfe with SMTP id 5a478bee46e88-304eb0bcb61mr605299eec.9.1780030678739; Thu, 28 May 2026 21:57:58 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 05/15] net/tap: net_init_tap(): common fail label Date: Fri, 29 May 2026 12:57:20 +0800 Message-ID: <20260529045730.90322-6-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030745753154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add common failure label. This: - simplifies failure paths in the function - get rid of unusual free_fail: in the middle of the function - simplify further refactoring Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 84 ++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/net/tap.c b/net/tap.c index 331a779585..2eb8a2caeb 100644 --- a/net/tap.c +++ b/net/tap.c @@ -820,10 +820,12 @@ int net_init_tap(const Netdev *netdev, const char *na= me, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap; - int fd, vnet_hdr =3D 0, i =3D 0, queues; + int fd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ char ifname[128]; - int ret =3D 0; + char **fds =3D NULL, **vhost_fds =3D NULL; + int nfds =3D 0, nvhosts =3D 0; + =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -867,31 +869,24 @@ int net_init_tap(const Netdev *netdev, const char *na= me, if (tap->fd) { fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); if (fd =3D=3D -1) { - return -1; + goto fail; } =20 if (!qemu_set_blocking(fd, false, errp)) { - close(fd); - return -1; + goto fail; } =20 vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { - close(fd); - return -1; + goto fail; } =20 if (!net_init_tap_one(tap, peer, "tap", name, NULL, NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp)) { - close(fd); - return -1; + goto fail; } } else if (tap->fds) { - char **fds; - char **vhost_fds; - int nfds =3D 0, nvhosts =3D 0; - fds =3D g_new0(char *, MAX_TAP_QUEUES); vhost_fds =3D g_new0(char *, MAX_TAP_QUEUES); =20 @@ -901,77 +896,58 @@ int net_init_tap(const Netdev *netdev, const char *na= me, if (nfds !=3D nvhosts) { error_setg(errp, "The number of fds passed does not match " "the number of vhostfds passed"); - ret =3D -1; - goto free_fail; + goto fail; } } =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; + goto fail; } =20 if (!qemu_set_blocking(fd, false, errp)) { - ret =3D -1; - goto free_fail; + goto fail; } =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; + goto fail; } } 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; + goto fail; } =20 if (!net_init_tap_one(tap, peer, "tap", name, ifname, NULL, NULL, tap->vhostfds ? vhost_fds[i] : NULL, vnet_hdr, fd, errp)) { - ret =3D -1; - goto free_fail; + goto fail; } } - -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) { fd =3D net_bridge_run_helper(tap->helper, tap->br ?: DEFAULT_BRIDGE_INTERFACE, errp); if (fd =3D=3D -1) { - return -1; + goto fail; } =20 if (!qemu_set_blocking(fd, false, errp)) { - return -1; + goto fail; } vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { - close(fd); - return -1; + goto fail; } =20 if (!net_init_tap_one(tap, peer, "bridge", name, ifname, NULL, NULL, tap->vhostfd, vnet_hdr, fd, errp)) { - close(fd); - return -1; + goto fail; } } else { g_autofree char *script =3D @@ -989,14 +965,13 @@ free_fail: 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; + goto fail; } =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; + goto fail; } } =20 @@ -1004,13 +979,28 @@ free_fail: i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, tap->vhostfd, vnet_hdr, fd, errp)) { - close(fd); - return -1; + goto fail; } } } =20 return 0; + +fail: + close(fd); + if (vhost_fds) { + for (i =3D 0; i < nvhosts; i++) { + g_free(vhost_fds[i]); + } + g_free(vhost_fds); + } + if (fds) { + for (i =3D 0; i < nfds; i++) { + g_free(fds[i]); + } + g_free(fds); + } + return -1; } =20 int tap_enable(NetClientState *nc) --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030701; cv=none; d=zohomail.com; s=zohoarc; b=N6le1VayEkMD0XXPEl05pGT7YRto9qvy+HUr0RarThr0afcN8CSH51QZCy8Tf7rPwx3ka5sAb95BGZ/z5oVizH7Zbv8ViUVb7VTGsR10K6w7vWVKraD7EGqtm7NuM7GEndqTJltRU+hoxgk/ZM3zqn1+zUqhiN1wMNdyIIOMs80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030701; h=Content-Type: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=+urkdBxoRfMQzsCR9ka10liC8QUAMNwGeIvlBxb3yJs=; b=JZ1hGg1iHBWXD/Qvxh0QtQ/t7rsXbXKyUjpxuA8n/bJoYIl3iEMav0mqn++HdBjPFGh+vIfKaHKRP8RmNeOWSY8gNvWCfczvB1kie4064jz6NX25hBWLotS2pI10Kzb9Yjt5Tb0JiiRNhDwpwRXAfkGmLSdGBBuo1QkdGoG0DJY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178003070150134.585801625466615; Thu, 28 May 2026 21:58:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIQ-0005hf-J0; Fri, 29 May 2026 00:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIP-0005hN-8q for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIN-00087K-EP for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:08 -0400 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-qCEhwbyHMTCbdECEsOpZqA-1; Fri, 29 May 2026 00:58:04 -0400 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-2fe1cf409a1so3524700eec.1 for ; Thu, 28 May 2026 21:58:04 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.57.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+urkdBxoRfMQzsCR9ka10liC8QUAMNwGeIvlBxb3yJs=; b=LVfD91O/kFToYw4wyYmL5xF7Jk8ASQak+iBBE9TaqmBwREJtNkUkZOQSXIbK3LKUddj+Ln X0akZUdHShzhaHDptkCHalPxi674HefQFCEWSoJ4BjyvLwLs86JvPmUyxSbn08d6F4XUp7 2KDxtfYkhw8ysc3xqL1lvXszuTE7db4= X-MC-Unique: qCEhwbyHMTCbdECEsOpZqA-1 X-Mimecast-MFC-AGG-ID: qCEhwbyHMTCbdECEsOpZqA_1780030683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030683; x=1780635483; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+urkdBxoRfMQzsCR9ka10liC8QUAMNwGeIvlBxb3yJs=; b=MK6RKYfFCY2j4Ln4kFWHAyk8tIy+J9fRZVjTv/7gcI3v5SYKKsbj9PUbjYe/cxyddh Zpv0kFpEbqf76EUcQJuMjphAEOhqIIjk+K0HNyScEQPQWeaCzjS66F+P8NxlGz1pE+Hh gmzoRdX5R/Ef9IupVqFn9Nhhgs91e5dSz+uo42UlpIxmDDUV2JFVpejhIJVRAJDte6+j 0thvAyd+lgZWw+ac9rBLfSAO7JKmBRBgH/jAD9zYAiBJ54hVqp3/To0JXX9AIuzv/xlO 3EJXekimVY1KceKyeHdQc9uo9IFsI64IPYKRapI4Ga2Aj52qYiMINH607u8Uxgp4fs9U l+BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030683; x=1780635483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+urkdBxoRfMQzsCR9ka10liC8QUAMNwGeIvlBxb3yJs=; b=GclrgiUdfA+j9zf6OBgAf3P/XrOvdlnansGYjcFeqRPB4Z8w2wJ9qZ0Qjln6ZF4QHu jHai/P1k61Wns1uE2VPgRlSNZXS3pFEdFzo/k92oyzIWMPwP3dlMxdlzkj4e6HU96cRD GsPoLRb+nPHOiNzypmjDva1Lj6FxrRwYxBGWzohwGGYdhrsVHYC310dS1LxX4A/sHLwJ s49YXKm8hN0UA9jBPjwOOKJwWLo1X1e+JPAvw+t1GwdXf/QmiNBeZH9BA8nG3VUEbwFN oaYXfr2TqzJ7nPLOorq6WCU4gXi/UYOmn0/ineN6itPOfeEBkLbtl6OAEPbHF/u4TcnD 7xAA== X-Gm-Message-State: AOJu0YxEjznrcVOQSV5CvhPpD3n0u4kY8TF2ppB6hZvEkiKvvPFTEv19 0XIsxJpJJwcJ2B1GmmbLrA0kaI2nTXs6cZ3yf4ISTorLkzaIXvxzhIKkm6EqfMSiFLqzeHuXdDW IVDGXuaYOej5G0DW3NKppFJna0wszl/EdVU3c3IDVYT+gz/4DN0WQi5fjsbvJGZfTKIIHjQl/l9 /O1SnAEu4OUcVsh+UgpE2ObRa3fGkNSTXW3XWZL3suibI= X-Gm-Gg: Acq92OGHzYqnYzy18AiT/Wnu8CTlwK6RyBTi8bGWtnjXlQYRO/3+2GCIBTCdamzyijH xMTk/YX+qdpuGA6+PRo2zQuHzZLEU5bG57kss9FzcW8gGYtgj1Wj6Xk7EbnR1OTYIeOY6MkBcXo NAnmtVcQLbB3wduhe+D2vEqy2dJu+ZdomkUl8BVWibWO70wTMnSyxMNmuYEZ7tdx1Afw4EYmLnS Sdki15CBjrglOU0qNltDnH+gKkefR2bjyrFZB2FAAAehHO+geKt3jm2zDE2XCYIVCRrewgZm5n0 HEdFXGp7myX8DUgMRd7lBJAWqRSETi6iSJClZBU5oqafA0Q4gUKE5wv88vzXzl9VfGp0KOr18PX sDPjJIlDs5rAaGYaVfB7NI7p9cTYNv9bZ5P8BZpCXGN3RjEAoIlg5YkWpZDY+zWs65XElOOYj X-Received: by 2002:a05:7300:fd84:b0:2ed:2942:34ab with SMTP id 5a478bee46e88-304eb06ccabmr614929eec.3.1780030683112; Thu, 28 May 2026 21:58:03 -0700 (PDT) X-Received: by 2002:a05:7300:fd84:b0:2ed:2942:34ab with SMTP id 5a478bee46e88-304eb06ccabmr614912eec.3.1780030682427; Thu, 28 May 2026 21:58:02 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 06/15] net/tap: net_init_tap_one() refactor to get vhostfd param Date: Fri, 29 May 2026 12:57:21 +0800 Message-ID: <20260529045730.90322-7-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030705207158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Get vhostfd instead of vhostfdname: - more symmetry with fd param - prepare to further changes Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/net/tap.c b/net/tap.c index 2eb8a2caeb..2c5f8e73fe 100644 --- a/net/tap.c +++ b/net/tap.c @@ -706,11 +706,10 @@ static int net_tap_init(const NetdevTapOptions *tap, = int *vnet_hdr, static bool 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, + const char *downscript, int vhostfd, int vnet_hdr, int fd, Error **errp) { 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; @@ -738,7 +737,7 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, } =20 if (tap->has_vhost ? tap->vhost : - vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { + (vhostfd !=3D -1) || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; =20 options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; @@ -749,15 +748,7 @@ static bool net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, options.busyloop_timeout =3D 0; } =20 - if (vhostfdname) { - vhostfd =3D monitor_fd_param(monitor_cur(), vhostfdname, errp); - if (vhostfd =3D=3D -1) { - goto failed; - } - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto failed; - } - } else { + if (vhostfd =3D=3D -1) { vhostfd =3D open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { error_setg_file_open(errp, errno, "/dev/vhost-net"); @@ -820,7 +811,7 @@ int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap; - int fd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; + int fd =3D -1, vhostfd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ char ifname[128]; char **fds =3D NULL, **vhost_fds =3D NULL; @@ -866,6 +857,17 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 + if (tap->vhostfd) { + vhostfd =3D monitor_fd_param(monitor_cur(), tap->vhostfd, errp); + if (vhostfd =3D=3D -1) { + return -1; + } + + if (!qemu_set_blocking(vhostfd, false, errp)) { + goto fail; + } + } + if (tap->fd) { fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); if (fd =3D=3D -1) { @@ -883,7 +885,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 if (!net_init_tap_one(tap, peer, "tap", name, NULL, NULL, NULL, - tap->vhostfd, vnet_hdr, fd, errp)) { + vhostfd, vnet_hdr, fd, errp)) { goto fail; } } else if (tap->fds) { @@ -910,6 +912,17 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, goto fail; } =20 + if (tap->vhostfds) { + vhostfd =3D monitor_fd_param(monitor_cur(), vhost_fds[i], = errp); + if (vhostfd =3D=3D -1) { + goto fail; + } + + if (!qemu_set_blocking(vhostfd, false, errp)) { + goto fail; + } + } + if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { @@ -923,7 +936,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 if (!net_init_tap_one(tap, peer, "tap", name, ifname, NULL, NULL, - tap->vhostfds ? vhost_fds[i] : NULL, + vhostfd, vnet_hdr, fd, errp)) { goto fail; } @@ -945,7 +958,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 if (!net_init_tap_one(tap, peer, "bridge", name, ifname, - NULL, NULL, tap->vhostfd, + NULL, NULL, vhostfd, vnet_hdr, fd, errp)) { goto fail; } @@ -978,7 +991,7 @@ int net_init_tap(const Netdev *netdev, const char *name, if (!net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, - tap->vhostfd, vnet_hdr, fd, errp)) { + vhostfd, vnet_hdr, fd, errp)) { goto fail; } } @@ -988,6 +1001,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, =20 fail: close(fd); + close(vhostfd); if (vhost_fds) { for (i =3D 0; i < nvhosts; i++) { g_free(vhost_fds[i]); --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030718; cv=none; d=zohomail.com; s=zohoarc; b=d9a8rAQTRD7cSew9JoEY/Ur15livvFvq8RiJlQwr5ILj6uOOC3MOE0ohJfxJ15SsZN4qUDY1oopjdutROeeRUWBGNFuC670uVgvnDPAGUEJWCT3JHii2N04ySipc0cYqUcX9O8ZPfw3uAZtEnwiuKbkxLGU+DGD6I6AfZ/auN28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030718; h=Content-Type: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=TeaCWgxz26pIuZ3T1/Jo3a4lmDTksPW+9uKpcpmoWbE=; b=c/RTmY+C5O7HJYG5XadQ2/EM9KMKTafKXuskKmBl+4hxXIAObf7jxG2lPf8ZLuC+UHD7qgHsJWehQWBhHrUMROxmA5vF1POtnBifPuDu1YeP+Wkkpcuwge3ASDnnjcrgs/r1pIv9mDWmZ9sd9olsyJL20ST0EBaoPzQ/98YsDnA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030718589462.80903635216646; Thu, 28 May 2026 21:58:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIU-0005r1-4Y; Fri, 29 May 2026 00:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIS-0005nF-Gv for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIQ-00087g-Qy for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:12 -0400 Received: from mail-dl1-f72.google.com (mail-dl1-f72.google.com [74.125.82.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-deR2WmYfPoOyoOFVxfyeLQ-1; Fri, 29 May 2026 00:58:08 -0400 Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-135916eefa0so1633787c88.1 for ; Thu, 28 May 2026 21:58:07 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TeaCWgxz26pIuZ3T1/Jo3a4lmDTksPW+9uKpcpmoWbE=; b=LMze9WUHoCf/AJ6pSrLeqVAqv7V0pdTD3XmQbiMHkFqkvc6G3sg0zOZGvDDiXk17BAVylF MtLUHX+hfkjPwZDkm8sO2/svfGjhUkZOYlECmfMeHy29MO+cAhXSAX/McwDT+3NSXPtSFd ZRsiHSBYoIbpQOsBGxARge5uQkm+bl4= X-MC-Unique: deR2WmYfPoOyoOFVxfyeLQ-1 X-Mimecast-MFC-AGG-ID: deR2WmYfPoOyoOFVxfyeLQ_1780030687 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030687; x=1780635487; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TeaCWgxz26pIuZ3T1/Jo3a4lmDTksPW+9uKpcpmoWbE=; b=tyr/gkmGwI/eciWVyKW2IR18l1vIySOl+MQafivMUw952U3xrNyAO0Kk+/FAZkdpAI 8YUvKwupxHZ8gTy0xVqvLbYckZgFUPSDFEj4qY2K9kHm7p7NfKKcUXMAIV35EsjMlVND g1ljpSoR6RRuKX0+lMoLhXhye5gGbBXhVJtWpfpdyu7PrOIDMXBzQDfeZF2zX3d/W+KN Z5VoTdzMbYaBIVR19OHWLMZA/0BJM2ymenFRXAZBj8HpuEtYcxzmMYt2G5wfyetmI8/W QfcnkkS4ixkt3Qrp7Yb+zgUOpMqEb6QxzsrBYUbW2T4xm5zTqFohgLvQgCZRf26H7AYS gdVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030687; x=1780635487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TeaCWgxz26pIuZ3T1/Jo3a4lmDTksPW+9uKpcpmoWbE=; b=rM1a44XXt5Tfaf/f+j82Pa4GaVdXDHRj3JOF/srI10qdzytSEkiSFgjY+fYY3WnsOH SGbh0hPdPA9LTinE9JhDUgrL7Gc7jtbh/vFxvdSiHATkeYrXFp2Uvx1phUwTuRcytHLs YJnCtKyb59uYRxblPbzerzUrp13EeZzJCLUPcgp2PzkWUwriYfzjQZUv0cGiI0TG19Ih FxoW9SvsQXT2k80sdsYV72h5S7HgoaW/ZeetzHnV9Nuevc6rrnHgy6Els5zjZqg8kyJD E8oFK+8SZQKwc9SAu0FaJGhdI90P3qPD5Sx52ngCjZ1YL8TgYi8BY/lSS/J5IL/d033A b6ow== X-Gm-Message-State: AOJu0YyU7DzV5gXktaSuOCxLTbZZi4V9AjXJREp+ymJvP2aKSjeIODxq IShv2pKtgp0qE3SFXFvo6U0G0RT04G5CbjlE9zyqkRFNVxV59jy8MePwlsQKYMVog4FLeTd0iFk OAV5EWCiW9BAsuHipG6dQ/FMAKDTX7nIUABSmlX+Y7eJ18rOX20CtjZkrq0GLMyYKc4HTl91vzE bs7uiH9nwDOwxDwaVRNgjrDf/Z+wUIzV//CUhbkRLHuOE= X-Gm-Gg: Acq92OFSBAyKpFx1a6gWC4uZU5CHPASia/7FpiGM/VPPKMj+UTZhcAL9s8GqhQunpyh Fie/N6HsYNGy9gfJdB4++5gScEHiB6YrRfe0+gDFCWfAbfEjCcAdhF05FPUwCNpm2pEr4E/1sqC zLS6zp01G6NMqjjYUgx0Qy8cEw5JLFG4VOJ9PWO0+zLULmQj7QjdKT+vHfegzWbolfvQIQzj4sW byYeetqTor2ZdnA+Y9lylIgLhdB47/4w2RZ5ZFo//eqAojHkQrM7eOrrv8+Pax63cy/fpTxnDdu KROYlQUnkgEu+xMIKGa9fiWH6EjMtpPGzhPigOseQVUbrN9CjO/4usq28Efic3FG3gNB0DKybna SUBWQIZehceeOnvPDIJVYOYpIgu4fk+wiOv5kFJqJZhAnWjmNI8y7sky6PsDleTDhxU2EFret X-Received: by 2002:a05:7022:6b86:b0:136:6d82:18ce with SMTP id a92af1059eb24-137af649b32mr541513c88.23.1780030686855; Thu, 28 May 2026 21:58:06 -0700 (PDT) X-Received: by 2002:a05:7022:6b86:b0:136:6d82:18ce with SMTP id a92af1059eb24-137af649b32mr541495c88.23.1780030686238; Thu, 28 May 2026 21:58:06 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 07/15] net/tap: net_init_tap_one(): drop model parameter Date: Fri, 29 May 2026 12:57:22 +0800 Message-ID: <20260529045730.90322-8-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030720502158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It could be simply derived from tap parameter. And this change simplifies further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index 2c5f8e73fe..db3fe380a4 100644 --- a/net/tap.c +++ b/net/tap.c @@ -704,12 +704,13 @@ static int net_tap_init(const NetdevTapOptions *tap, = int *vnet_hdr, #define MAX_TAP_QUEUES 1024 =20 static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, - const char *model, const char *name, + const char *name, const char *ifname, const char *script, const char *downscript, int vhostfd, int vnet_hdr, int fd, Error **errp) { - TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); + TAPState *s =3D net_tap_fd_init(peer, tap->helper ? "bridge" : "tap", + name, fd, vnet_hdr); bool sndbuf_required =3D tap->has_sndbuf; int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; @@ -883,7 +884,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto fail; } =20 - if (!net_init_tap_one(tap, peer, "tap", name, NULL, + if (!net_init_tap_one(tap, peer, name, NULL, NULL, NULL, vhostfd, vnet_hdr, fd, errp)) { goto fail; @@ -934,7 +935,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto fail; } =20 - if (!net_init_tap_one(tap, peer, "tap", name, ifname, + if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, vhostfd, vnet_hdr, fd, errp)) { @@ -957,7 +958,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto fail; } =20 - if (!net_init_tap_one(tap, peer, "bridge", name, ifname, + if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, vhostfd, vnet_hdr, fd, errp)) { goto fail; @@ -988,7 +989,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } } =20 - if (!net_init_tap_one(tap, peer, "tap", name, ifname, + if (!net_init_tap_one(tap, peer, name, ifname, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, vhostfd, vnet_hdr, fd, errp)) { --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030734; cv=none; d=zohomail.com; s=zohoarc; b=lyG+4Voi1c5zoGY1ytBGspzZfIAzGqGXLjRxd19OlK2X75vfU6iPp8AcVOpsfl89ZZBh5lHoQeQqqhkfbzAI14OFGK1a6wRvODmV7Ilmz7l7GwUoKKtRVhZcV7RJxlykaI+W5kFnh2bkDjqYcAndq0e2bhRA09rdLI0o5MNz6EU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030734; h=Content-Type: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=lXBpO/M4FGwucGl9YxH11gyjZXTSpbMqtOVX+sjCIEQ=; b=YtatFoET4RpSgLX/jq3pcu3pUA2eoT71ddwkMdAMcjHylUdg57CXJL3Eu5Qnm0Wg48K+n82g93b7+EPP+GQKXb4ACXb/7XM297R1eCCsalxN0wbHY+I14OJOX4O/uOGSlw1X0y2Fu6TzIg4ABstjEvPvqa78hbi0k0v0Y68WS6U= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030734806733.0179152389449; Thu, 28 May 2026 21:58:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIY-0005ur-Ty; Fri, 29 May 2026 00:58:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIW-0005tV-M0 for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIU-00089C-Jd for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:16 -0400 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-Mifx91fzPG-iJVU_ay_mHQ-1; Fri, 29 May 2026 00:58:12 -0400 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-304d8613efbso1750970eec.1 for ; Thu, 28 May 2026 21:58:12 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXBpO/M4FGwucGl9YxH11gyjZXTSpbMqtOVX+sjCIEQ=; b=XoCWFU0RemxvdUqj0spLXOpaHryXr19w5ngVWhQVtG/3FrfbI6Z9+8WmB7INLS5DjsYhpS 6suD6IAZFF7CL426LDiR9KkA8dvloKGoLel2z93FG2YTmEwNnrVuSItASj8v1xNe+w980m W1oDxsMEl/WKGrYg4mW9118h+e9K8QM= X-MC-Unique: Mifx91fzPG-iJVU_ay_mHQ-1 X-Mimecast-MFC-AGG-ID: Mifx91fzPG-iJVU_ay_mHQ_1780030691 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030691; x=1780635491; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lXBpO/M4FGwucGl9YxH11gyjZXTSpbMqtOVX+sjCIEQ=; b=J9iYcEED/PGGvJoHpBshvGWALeqYa2KsKCjmw3sGV9EayLRt52RSzDS57T4T+njoK0 qJKqOzWJnK0taILKfyqUQN9UQ6sLIrPM37JC8FTuhMbqz3NKBE4rj0bk5xfDrxKGRmlm VvD46S24CAqWLus8xWNyUZUxpBxlXYE6MrB2ooVHjXKRh+iayLFenes9Rr6G+qu6LZhd UP3s4MLJuUCeD7Vh65KYq0oFbmSQoKQnA56cxdk+FVks98W6gFjSe3diNfhkKHkRrE40 bUTqQCdzc5mE7EUQvsyY3zkNeMkWrfS1ObGZtDk7surMrWBRDWucgtYVDxyodIwLAvBj jANg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030691; x=1780635491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lXBpO/M4FGwucGl9YxH11gyjZXTSpbMqtOVX+sjCIEQ=; b=aPdM/RWjkfId5SiQTbM/TqRUk0ta7xmM1CLgat7YgGakLeEmkS94YCHoU/vN40a/qu ULiAXVuabdAMT61n/C0C1T4FgdLh/WvQa4/41wN92vGnxpdCdwRZLulZG7vJci3Pk2BQ UYE1kiogfgJvdNWyn/I/cxjVuCZa3jLWag0r6fc86sKS9tSu+jKvPyEvSXqn71vv3PFm 1mbhHBl0CE419ngnGjPAa9MNxs8TRE3sjXhcNyKxWqdARxT1t5QjHnkxse6o3jkcZhbc qCut+VsRwVq8VgkWQO5ppOkGjIZ3CV8NEw2O493cN/1q3V5SlWKvQbr10YLeXmThRyra 3bsQ== X-Gm-Message-State: AOJu0Ywdtem7nSdLUbi4DeNMQ1FX/zxMtLvqdGRw6C82PM0rfSI9u3O4 NothgLN4EooM3AdJTDmvkc/wJP9hV7WT4WT0egKYxd32emf/tX3s4D2eOg+dt5U1tMbgZBXDYIm 9xON/PsqNpuZE2/z7TS22pxLF2VHkzhb55PCXRUJTDZ03g1i/ET+S+MreXSrIZytz822k9OieZ3 QYOxhv67A8bwf8KbvZ0KTYAOmqsAGyHKv0+spf6MgvDTY= X-Gm-Gg: Acq92OHDI8Q9ayDI92po8g46avNkFpuVLgeglr+FR7XALuWsGln3qoVdm2tUM5bbu/Q bFxU8V3TTzDrlqJzUi7qTbTTQq0808oaYTis6foWHge2eK+nCsOtmmYqgICaHe5o1qd6VIIi7xm Jm9yfAfEXaJ2J07T6JJqa5NVg5rHaeBcE4tmIFnIil6qiJsqGLv86gsMPzbI0FXzS/sL91nXDhF epvi/qYXtnd8D8o1mWUhjSvEhBsaPhSzzmu+LXsGlcLw3//qcroQwmHqlPTxJnywFkZ0gid90or j8HqCqoSIZn0gSRqaaUUFFiSpij7L8qlL0xkn5qaxgPvf49ocKM42PApJBzi9VFpsH1e22VVb0N 2jA3maTb8D0/A73XGhvL1798XMAxXhI/lYyy+6BtfaYOJ8POK76mhh7wHmoILcswBtH7/9gJ8 X-Received: by 2002:a05:7300:a286:b0:304:8361:a87e with SMTP id 5a478bee46e88-304eb25db22mr597470eec.33.1780030691020; Thu, 28 May 2026 21:58:11 -0700 (PDT) X-Received: by 2002:a05:7300:a286:b0:304:8361:a87e with SMTP id 5a478bee46e88-304eb25db22mr597447eec.33.1780030690292; Thu, 28 May 2026 21:58:10 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 08/15] net: introduce net_parse_fds() Date: Fri, 29 May 2026 12:57:23 +0800 Message-ID: <20260529045730.90322-9-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030737658154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add common net_parse_fds() and net_free_fds() helpers and use them in tap.c and af-xdp.c. Choose returning queues instead of fds, because we'll have derived helper in net/tap, which will be able to return fds=3DNULL and non-zero queues on success. That's also why we move to INT_MAX for queues, to support negative return value for net_parse_fds() (for failure paths). Note that redundant restriction of MAX_TAP_QUEUES is dropped for tap.c Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/af-xdp.c | 33 ++----------------- net/tap.c | 92 +++++++++++----------------------------------------- net/util.c | 50 ++++++++++++++++++++++++++++ net/util.h | 14 ++++++++ 4 files changed, 85 insertions(+), 104 deletions(-) diff --git a/net/af-xdp.c b/net/af-xdp.c index ff1cb30a98..1ffd6363a8 100644 --- a/net/af-xdp.c +++ b/net/af-xdp.c @@ -21,6 +21,7 @@ #include "clients.h" #include "monitor/monitor.h" #include "net/net.h" +#include "net/util.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -441,35 +442,6 @@ static NetClientInfo net_af_xdp_info =3D { .cleanup =3D af_xdp_cleanup, }; =20 -static int *parse_socket_fds(const char *sock_fds_str, - int n_expected, Error **errp) -{ - gchar **substrings =3D g_strsplit(sock_fds_str, ":", -1); - int i, n_sock_fds =3D g_strv_length(substrings); - int *sock_fds =3D NULL; - - if (n_sock_fds !=3D n_expected) { - error_setg(errp, "expected %d socket fds, got %d", - n_expected, n_sock_fds); - goto exit; - } - - sock_fds =3D g_new(int, n_sock_fds); - - for (i =3D 0; i < n_sock_fds; i++) { - sock_fds[i] =3D monitor_fd_param(monitor_cur(), substrings[i], err= p); - if (sock_fds[i] < 0) { - g_free(sock_fds); - sock_fds =3D NULL; - goto exit; - } - } - -exit: - g_strfreev(substrings); - return sock_fds; -} - /* * The exported init function. * @@ -530,8 +502,7 @@ int net_init_af_xdp(const Netdev *netdev, } =20 if (opts->sock_fds) { - sock_fds =3D parse_socket_fds(opts->sock_fds, queues, errp); - if (!sock_fds) { + if (net_parse_fds(opts->sock_fds, &sock_fds, queues, errp) < 0) { return -1; } } diff --git a/net/tap.c b/net/tap.c index db3fe380a4..2d4630c350 100644 --- a/net/tap.c +++ b/net/tap.c @@ -45,6 +45,7 @@ #include "hw/virtio/vhost.h" =20 #include "net/tap.h" +#include "net/util.h" =20 #include "net/vhost_net.h" =20 @@ -701,8 +702,6 @@ static int net_tap_init(const NetdevTapOptions *tap, in= t *vnet_hdr, return fd; } =20 -#define MAX_TAP_QUEUES 1024 - static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, const char *name, const char *ifname, const char *script, @@ -782,32 +781,6 @@ failed: return false; } =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) { @@ -815,9 +788,7 @@ int net_init_tap(const Netdev *netdev, const char *name, int fd =3D -1, vhostfd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ char ifname[128]; - char **fds =3D NULL, **vhost_fds =3D NULL; - int nfds =3D 0, nvhosts =3D 0; - + int *fds =3D NULL, *vhost_fds =3D NULL; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -890,46 +861,31 @@ int net_init_tap(const Netdev *netdev, const char *na= me, goto fail; } } else if (tap->fds) { - fds =3D g_new0(char *, MAX_TAP_QUEUES); - vhost_fds =3D g_new0(char *, MAX_TAP_QUEUES); - - 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) { - error_setg(errp, "The number of fds passed does not match " - "the number of vhostfds passed"); - goto fail; - } + queues =3D net_parse_fds(tap->fds, &fds, 0, errp); + if (queues < 0) { + goto fail; } =20 - for (i =3D 0; i < nfds; i++) { - fd =3D monitor_fd_param(monitor_cur(), fds[i], errp); - if (fd =3D=3D -1) { - goto fail; - } + if (tap->vhostfds && net_parse_fds(tap->vhostfds, &vhost_fds, + queues, errp) < 0) { + goto fail; + } =20 - if (!qemu_set_blocking(fd, false, errp)) { + for (i =3D 0; i < queues; i++) { + if (!qemu_set_blocking(fds[i], false, errp)) { goto fail; } =20 - if (tap->vhostfds) { - vhostfd =3D monitor_fd_param(monitor_cur(), vhost_fds[i], = errp); - if (vhostfd =3D=3D -1) { - goto fail; - } - - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto fail; - } + if (vhost_fds && !qemu_set_blocking(vhost_fds[i], false, errp)= ) { + goto fail; } =20 if (i =3D=3D 0) { - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + vnet_hdr =3D tap_probe_vnet_hdr(fds[i], errp); if (vnet_hdr < 0) { goto fail; } - } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd, NULL)) { + } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fds[i], NULL)) { error_setg(errp, "vnet_hdr not consistent across given tap fds"); goto fail; @@ -937,8 +893,8 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, - vhostfd, - vnet_hdr, fd, errp)) { + vhost_fds ? vhost_fds[i] : -1, + vnet_hdr, fds[i], errp)) { goto fail; } } @@ -1003,18 +959,8 @@ int net_init_tap(const Netdev *netdev, const char *na= me, fail: close(fd); close(vhostfd); - if (vhost_fds) { - for (i =3D 0; i < nvhosts; i++) { - g_free(vhost_fds[i]); - } - g_free(vhost_fds); - } - if (fds) { - for (i =3D 0; i < nfds; i++) { - g_free(fds[i]); - } - g_free(fds); - } + net_free_fds(fds, queues); + net_free_fds(vhost_fds, queues); return -1; } =20 diff --git a/net/util.c b/net/util.c index 0b3dbfe5d3..1998a6554e 100644 --- a/net/util.c +++ b/net/util.c @@ -23,6 +23,8 @@ */ =20 #include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "qapi/error.h" #include "util.h" =20 int net_parse_macaddr(uint8_t *macaddr, const char *p) @@ -57,3 +59,51 @@ int net_parse_macaddr(uint8_t *macaddr, const char *p) =20 return 0; } + +void net_free_fds(int *fds, int nfds) +{ + int i; + + if (!fds || nfds <=3D 0) { + return; + } + + for (i =3D 0; i < nfds; i++) { + if (fds[i] !=3D -1) { + close(fds[i]); + } + } + + g_free(fds); +} + +int net_parse_fds(const char *fds_param, int **fds, int expected_nfds, + Error **errp) +{ + g_auto(GStrv) fdnames =3D g_strsplit(fds_param, ":", -1); + unsigned nfds =3D g_strv_length(fdnames); + int i; + + if (nfds > INT_MAX) { + error_setg(errp, "fds parameter exceeds maximum of %d", INT_MAX); + return -1; + } + + if (expected_nfds && nfds !=3D expected_nfds) { + error_setg(errp, "expected %u socket fds, got %u", expected_nfds, = nfds); + return -1; + } + + *fds =3D g_new(int, nfds); + + for (i =3D 0; i < nfds; i++) { + (*fds)[i] =3D monitor_fd_param(monitor_cur(), fdnames[i], errp); + if ((*fds)[i] =3D=3D -1) { + net_free_fds(*fds, i); + *fds =3D NULL; + return -1; + } + } + + return nfds; +} diff --git a/net/util.h b/net/util.h index 288312979f..4dbc5d416d 100644 --- a/net/util.h +++ b/net/util.h @@ -83,4 +83,18 @@ static inline bool in6_equal_net(const struct in6_addr *= a, =20 int net_parse_macaddr(uint8_t *macaddr, const char *p); =20 +/* + * Close all @fds and free @fds itself + */ +void net_free_fds(int *fds, int nfds); + +/* + * Parse @fds_param, where monitor fds are separated by a colon. + * @nfds must be non-NULL. If *@nfds is zero - set it accordingly. + * If *@nfds is non-zero - check that we have exactly *@nfds fds + * and fail otherwise. + */ +int net_parse_fds(const char *fds_param, int **fds, int expected_nfds, + Error **errp); + #endif /* QEMU_NET_UTIL_H */ --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030721; cv=none; d=zohomail.com; s=zohoarc; b=hqgYdRDUdu1XJd2Samlk2NfcTXHBf2uFxKzRhZl2nV1KmNlFtFFq4idcP7bjJaFCbuIvpaFHXRTSIZk3c1YjYbhhyBNWNQTtFvvJ09fXLztScy+MomtaBxBtQjnAI3afpvYSFvzHQS+YVjszGvuWTgZFLRf+ZrPyG1S5/s4gvWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030721; h=Content-Type: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=XsdnJ8QU8/mkgWQMKrIoYbBA3H/ZLUxSs+Qt+5roZpU=; b=jLJ90UsweTCp3zkSIghyz/G+yC+xhwvUnqy2qeKKnhxHZz3+qFM6VNNULmaUX7ZPC1a01RGTyEtAheX7eEOCPl5YcxIE7BzJAAJGUgS32Chi8n90xmpZGH8jxQBACwPS56lh3a362dYGNn8u4/3kHZ9tjr1rlZLp5+Nza4Ak554= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030721037965.5063523659387; Thu, 28 May 2026 21:58:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIf-00068R-IW; Fri, 29 May 2026 00:58:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpId-00066B-Fz for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIY-00089z-QG for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:22 -0400 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-IiTcB876MeGqEEMCP8_kbA-1; Fri, 29 May 2026 00:58:16 -0400 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-304b8d0ee63so3940239eec.0 for ; Thu, 28 May 2026 21:58:15 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XsdnJ8QU8/mkgWQMKrIoYbBA3H/ZLUxSs+Qt+5roZpU=; b=IXK1SrGXIBN+6hBPZVvq11w1cGfoQas+dnS8xnhe7SDA876oUPnFqf68wzDNh4jCOz5VWJ uFV7HOzXeblXsIlVt25csQN1s939tuiJY4WcA0sVhol6Q6I5ec+Lnug8NcUN5MEu9ce4hR eL4xgLq1WT/OCrNL1DeBYk3jaLcqZ/8= X-MC-Unique: IiTcB876MeGqEEMCP8_kbA-1 X-Mimecast-MFC-AGG-ID: IiTcB876MeGqEEMCP8_kbA_1780030695 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030695; x=1780635495; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XsdnJ8QU8/mkgWQMKrIoYbBA3H/ZLUxSs+Qt+5roZpU=; b=cuixQJAiUlp4UqP0VyeNhiXtdJ3/EGxb6kbfuvn41lu42SklSSbesuTjnVbMtUjFYh /IqzMjUGFGojJ8B1uv2qH3UuieVdSsKYJ8ixNdw3yCiOzZjk/0KF5VtJgelxUIh/jjaA 6fqIMP+ESfWj8yeayDvlyccVUaerbrbVs/ryg5ED8ph2jRZVoOstLIwsyWniqtTjSsER HbaU1levNW2MZUNcqP1UYWk4kW397fG/v5YWYdIahoropio/T8vUjjG+SBzLofLdihVN XOnRsTiH5vpQHWkzRvP8ovXRVI5sH+g/zGPQElJiPRF/3l5m3sK6UHWl2LjKhrTMp3r+ BHJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030695; x=1780635495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XsdnJ8QU8/mkgWQMKrIoYbBA3H/ZLUxSs+Qt+5roZpU=; b=Pnd8Ox94cGbfycMMt+63xVgillQ6v6nFXRRf+mfwNOk1dB621gn1eIGaZy5Z+mKprS Zf2G5/YxejfFs5bcpAyqhh7UelvjNfbsYe67aFOiV4cUpr9EkFx1Tl9TaazVrS9n08DM nqmwF6LApqYHkC8klJK070BcI1+DuHE/1EzPWmQosupipFuv7VHsCcMb2gMcYcnqC/fL s+TKvI9CDWyKugc0439uvfTYtk9MeWM2TXjRGCwbfQy566lMqBGv7yW6j7JIcdVnHrdS isR8bD2cOMEqvlPNif3mjgnjl5eF7fl4p9xW1h+tbpgSomWn1sJDQZU5xkS3TDxAI5PP xw6Q== X-Gm-Message-State: AOJu0Yz3PhmU+1wS1jZjnYNWN/s7f8bCN0T+3xGPXMCpqPY8UA7xaT2h mK5ibILt9f5sPEev3E38VUA1du+vbOIhsB8cIEbzXoxNsLUIcAsGg+G+JOyE1QTQC042UyvEeuv G/mkAB6QXvPOYo4xphC4N/tpNGGuJKOk04zE6uwpbcf/WU79OcDRkcQlV7f2wlPT1W5yuCLxObQ av2wQdekLIzWHyPVoeneKA3eAcMOpqeAGXHM9e40g4ZEA= X-Gm-Gg: Acq92OGNv7I4Ingx50Qc91muRpbYHGM2eMUZ1WfbCMAbd/ejebgGc4nDFEqm/9/vJPW P6Z9CgdHVKvi5nECwSnM1wqcHYwsAdhHNvyBQ2bA7XlmMZq9i7O9QJmtXZq/RM6n86NTeEiyoaN YkT9TXlu1srLGnk8WrX0Tmklk+uH4TRZKDmVXTXzSn1A3aIeZOWzMQKZCsFy/tVhi/qgPm/QJfH aNZGypwlXHZ+lxd4s/H3S3TywQfcMHY3PlPax0AxNH8Rwb4V8wPvKf8ouiZ719Ft3Hh92Oib2Yo xOFzE9BHYxtil45kUg91lXSvfcqlr7XQ6jN2jjMmV6ii42t7pvjp+4B87328xGxW3SwT5knhtzQ gnOM+PxLd/O5QbwWqBgrNUsRZOPiW7SH6QRBXEDHLGvIn2Ce6pkMgnzrTdtWw5V6nnGGBazkp X-Received: by 2002:a05:7300:dc88:b0:2ea:4228:ab11 with SMTP id 5a478bee46e88-304eb05fc0amr739165eec.3.1780030694707; Thu, 28 May 2026 21:58:14 -0700 (PDT) X-Received: by 2002:a05:7300:dc88:b0:2ea:4228:ab11 with SMTP id 5a478bee46e88-304eb05fc0amr739149eec.3.1780030694048; Thu, 28 May 2026 21:58:14 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 09/15] net/tap: move fds parameters handling to separate functions Date: Fri, 29 May 2026 12:57:24 +0800 Message-ID: <20260529045730.90322-10-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030722309158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy This significantly simplify the code in net_init_tap(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 99 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/net/tap.c b/net/tap.c index 2d4630c350..b794f80e34 100644 --- a/net/tap.c +++ b/net/tap.c @@ -781,6 +781,61 @@ failed: return false; } =20 +static bool unblock_fds(int *fds, int nfds, Error **errp) +{ + for (int i =3D 0; i < nfds; i++) { + if (!qemu_set_blocking(fds[i], false, errp)) { + return false; + } + } + + return true; +} + +static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds, + Error **errp) +{ + int queues =3D 1; + + if (tap->has_queues + !!tap->helper + !!tap->fds + !!tap->fd > 1) { + error_setg(errp, "queues=3D, helper=3D, fds=3D and fd=3D are mutua= l exclusive"); + return -1; + } + + if (tap->has_queues) { + if (tap->queues > INT_MAX) { + error_setg(errp, "queues exceeds maximum %d", INT_MAX); + return -1; + } + queues =3D tap->queues; + *fds =3D NULL; + } else if (tap->fd || tap->fds) { + queues =3D net_parse_fds(tap->fd ?: tap->fds, fds, + tap->fd ? 1 : 0, errp); + if (!*fds) { + return -1; + } + } else if (tap->helper) { + int fd =3D net_bridge_run_helper(tap->helper, + tap->br ?: DEFAULT_BRIDGE_INTERFACE, + errp); + if (fd < 0) { + return -1; + } + + queues =3D 1; + *fds =3D g_new(int, 1); + **fds =3D fd; + } + + if (*fds && !unblock_fds(*fds, queues, errp)) { + net_free_fds(*fds, queues); + return -1; + } + + return queues; +} + int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { @@ -792,7 +847,6 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; - queues =3D tap->has_queues ? tap->queues : 1; =20 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ @@ -829,10 +883,15 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } =20 + queues =3D tap_parse_fds_and_queues(tap, &fds, errp); + if (queues < 0) { + return -1; + } + if (tap->vhostfd) { vhostfd =3D monitor_fd_param(monitor_cur(), tap->vhostfd, errp); if (vhostfd =3D=3D -1) { - return -1; + goto fail; } =20 if (!qemu_set_blocking(vhostfd, false, errp)) { @@ -841,41 +900,23 @@ int net_init_tap(const Netdev *netdev, const char *na= me, } =20 if (tap->fd) { - fd =3D monitor_fd_param(monitor_cur(), tap->fd, errp); - if (fd =3D=3D -1) { - goto fail; - } - - if (!qemu_set_blocking(fd, false, errp)) { - goto fail; - } - - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + vnet_hdr =3D tap_probe_vnet_hdr(fds[0], errp); if (vnet_hdr < 0) { goto fail; } =20 if (!net_init_tap_one(tap, peer, name, NULL, NULL, NULL, - vhostfd, vnet_hdr, fd, errp)) { + vhostfd, vnet_hdr, fds[0], errp)) { goto fail; } } else if (tap->fds) { - queues =3D net_parse_fds(tap->fds, &fds, 0, errp); - if (queues < 0) { - goto fail; - } - if (tap->vhostfds && net_parse_fds(tap->vhostfds, &vhost_fds, queues, errp) < 0) { goto fail; } =20 for (i =3D 0; i < queues; i++) { - if (!qemu_set_blocking(fds[i], false, errp)) { - goto fail; - } - if (vhost_fds && !qemu_set_blocking(vhost_fds[i], false, errp)= ) { goto fail; } @@ -899,24 +940,14 @@ int net_init_tap(const Netdev *netdev, const char *na= me, } } } else if (tap->helper) { - fd =3D net_bridge_run_helper(tap->helper, - tap->br ?: DEFAULT_BRIDGE_INTERFACE, - errp); - if (fd =3D=3D -1) { - goto fail; - } - - if (!qemu_set_blocking(fd, false, errp)) { - goto fail; - } - vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); + vnet_hdr =3D tap_probe_vnet_hdr(fds[0], errp); if (vnet_hdr < 0) { goto fail; } =20 if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, vhostfd, - vnet_hdr, fd, errp)) { + vnet_hdr, fds[0], errp)) { goto fail; } } else { --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030747; cv=none; d=zohomail.com; s=zohoarc; b=kq/ML2UwglbuCafZHVcjg3LdTBEDHfpE1ZbK5gDyThOgVQHEIp6/Cc6yDhUSwDD23mKAftOXlcySNWw1LIhoTo4fXujNZx5w9yTBH+gThU4DvZNSbu4a1zu1aHg0dlHZ77Ew9kfhXGfTe2IBvG6T6cjBSauNWgDV2B23GPWQmbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030747; h=Content-Type: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=dsbGh2yBIgo+8c7UjJ+EVhQzHmVPcUlEdc82aHULM4Q=; b=MppqLl4lxNmEWlBNrXgigcpsp3RLEGjEVdzT2NQrVubKQRkzLva9wKt+NzJEiZrkNd7CUx9vHZs0ycjbYLaKU0nXGTteXnki1BRUWIYoZU3UD4fcWxHbz38lt752HADYT3Y2cRPF+dttENIl/CadJxUZAlqfSPYLqtLhXe1Eq0w= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030747345237.71481097807407; Thu, 28 May 2026 21:59:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIi-00069W-Vy; Fri, 29 May 2026 00:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIf-00068e-Mv for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpId-0008Cc-8L for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:24 -0400 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-DMFVDu7ZOyatLMoxHZdqBw-1; Fri, 29 May 2026 00:58:20 -0400 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-304f1820babso59992eec.1 for ; Thu, 28 May 2026 21:58:20 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dsbGh2yBIgo+8c7UjJ+EVhQzHmVPcUlEdc82aHULM4Q=; b=OHK9Bpr4NygyRqIiu1kHAtyCknOT6XVgOd3EBc4Vr/qRp9x8Nj49DLO5RwuFb/2eAu6mVV 6lUOdhRs3Mmyb71duCl2lv53RV7aPiuHCgBowrKG11JBpqnIFV3vBDT9Dk6jnEEDlbr7uZ TL9BKJ6lhXvQkVlVDZq4JlYSFOQV3ak= X-MC-Unique: DMFVDu7ZOyatLMoxHZdqBw-1 X-Mimecast-MFC-AGG-ID: DMFVDu7ZOyatLMoxHZdqBw_1780030699 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030699; x=1780635499; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dsbGh2yBIgo+8c7UjJ+EVhQzHmVPcUlEdc82aHULM4Q=; b=etxO7bPRc1GIHrVGdchv2O1CRl1yxFglOboRB1zC2/zZjY+QSrSZ4i7fJJvbcDr634 Gy7L6nsNqaeq1l0TvGMKFLpTt1W/0WQRGk6saH/0t0/uSoVNpJKJ1IjzUhzp/8Js3eqG CU6+4Jdl1miKmEP/PbN8hxzpwnxzZsDD4fDSo5hyUS6XJMENpFC+EfQE03fbEcIkif/0 D+fzWxZLDy7Bm8whtjeXvuLQs6mTWGUZsXlOqT0mZPepVooziPo7xbpeedtA4vmyix73 mxqyqzYcoFrQrAeccDysR7SnI7sRZ//69iXVFTz3wJtlIc5f7EYsbvLOlyleQUHZBwSP 0Ygg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030699; x=1780635499; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dsbGh2yBIgo+8c7UjJ+EVhQzHmVPcUlEdc82aHULM4Q=; b=SeHIxBjOaw/JppCzSA2N2J0elRRRgQ3xHONrN7Fd2C3z41qTgi6j5AqI9hZA7nY4Kd 7l2Xy3vDShgNXVFTI+v140ZANruHBTey/vu71AN6KdTF3wEXeCZVlJUj/FDuHpaXEc7/ h8oYYiZN88d+m6UkD+tgiym0gglbQsTdTTTrzN3ik2iZrmn7qxEr9nFaen27FqmSRup9 CFNFkUGYq0XWBCDrJn49GkeUmyXeuZBoXUz1/9rjgNuRNTw6zdID65kNffAJyercnRhG FARmdGSA2u3Pr3BstTB1yN9pOFpSN8fZioI9wiuk+qCUSC8wA2k/RptdQGgLv9Ew8miW qmOg== X-Gm-Message-State: AOJu0YxWNy0LMUAQoIef2q5xLoxpBNIpHAdhFYOJ5+y9gRds7W9Rcg9D iJ9XZt3pRVJNaXk/BzTcvMiWBjWoTb94jGpBHsCESwNH/4aMNA1yIhDvhK8jF3ilxh9h5orxhDJ lmZeoHAYg4jnM1oIMwqISbScm5WvUbW46Axfn1shKMFSQWDp+bsckag36OnjFO/6eiP0Y/7sxei V5uq3pb081Bxrmwhghi1YJceHB+ySlbTepYlO7BI5G0kU= X-Gm-Gg: Acq92OEYI7XF0KeYWz8/7DwrxsJkbpSR9CxVzN99ZtzxsXs4sk1gxL4hVa5IOQVShsi ZGhyotKHc8DbA/Zv+rE/ms2ewfZHyhxQUzdDWHNb4VsE30PoexskQmgmSSKhPmdHEY9B4sw9hWH I3NZ8TMmwa4xPuuvIwmVQX3kCxv5UKfxSbcRimhgbuthd+6/eBXTTAWI3gb0snSPkELnFGlyzah g63fkHeFXQ7xYgfZ8dv/IL1Ttz6FoMJ10v+PeV7Y7jUpZXcTI9OLVHjzwIZPw1lNgqB9VYfA0JW +u8GOa+9C3RD1DzXkjoO6be9+SilYiUq+1YosgMftCdEVAmSlJmP/YMEoxHt//7zhepXS1o9q7r v1MfZjICUpeQ4N/4WyoRrXy14NDfAKE5uL+69dJdj8aWf9vUH1HOe6S4D0JSvV6gFQnP0hAil X-Received: by 2002:a05:7300:430a:b0:304:dfb2:2274 with SMTP id 5a478bee46e88-304eb0f8becmr667872eec.28.1780030698983; Thu, 28 May 2026 21:58:18 -0700 (PDT) X-Received: by 2002:a05:7300:430a:b0:304:dfb2:2274 with SMTP id 5a478bee46e88-304eb0f8becmr667853eec.28.1780030698312; Thu, 28 May 2026 21:58:18 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 10/15] net/tap: fix vhostfds/vhostfd parameters API Date: Fri, 29 May 2026 12:57:25 +0800 Message-ID: <20260529045730.90322-11-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030749806154100 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy There is a bug in the interface: we don't allow vhostfds argument together with queues. But we allow vhostfd, and try use it for all queues of multiqueue TAP. Let's relax the restriction. We already check that number of vhost fds match queues (or number of fds). So, no matter do vhost fds come from vhostfds or vhostfd argument. Let's use correct vhost fds for multiqueue TAP. To achieve this we move vhost fds parsing to separate function and call it earlier in net_init_tap(). Then we have vhost fds available (and already checked) for all further cases. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 63 ++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/net/tap.c b/net/tap.c index b794f80e34..d5a719150b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -836,11 +836,32 @@ static int tap_parse_fds_and_queues(const NetdevTapOp= tions *tap, int **fds, return queues; } =20 +static bool tap_parse_vhost_fds(const NetdevTapOptions *tap, int **vhost_f= ds, + int queues, Error **errp) +{ + if (!(tap->vhostfd || tap->vhostfds)) { + *vhost_fds =3D NULL; + return true; + } + + if (net_parse_fds(tap->vhostfd ?: tap->vhostfds, + vhost_fds, queues, errp) < 0) { + return false; + } + + if (!unblock_fds(*vhost_fds, queues, errp)) { + net_free_fds(*vhost_fds, queues); + return false; + } + + return true; +} + int net_init_tap(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap; - int fd =3D -1, vhostfd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; + int fd =3D -1, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ char ifname[128]; int *fds =3D NULL, *vhost_fds =3D NULL; @@ -873,30 +894,13 @@ int net_init_tap(const Netdev *netdev, const char *na= me, return -1; } =20 - if (tap->vhostfds && !tap->fds) { - error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't specifie= d"); - return -1; - } - - if (tap->vhostfd && tap->fds) { - error_setg(errp, "vhostfd=3D is invalid with fds=3D"); - return -1; - } - queues =3D tap_parse_fds_and_queues(tap, &fds, errp); if (queues < 0) { return -1; } =20 - if (tap->vhostfd) { - vhostfd =3D monitor_fd_param(monitor_cur(), tap->vhostfd, errp); - if (vhostfd =3D=3D -1) { - goto fail; - } - - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto fail; - } + if (!tap_parse_vhost_fds(tap, &vhost_fds, queues, errp)) { + goto fail; } =20 if (tap->fd) { @@ -907,20 +911,12 @@ int net_init_tap(const Netdev *netdev, const char *na= me, =20 if (!net_init_tap_one(tap, peer, name, NULL, NULL, NULL, - vhostfd, vnet_hdr, fds[0], errp)) { + vhost_fds ? vhost_fds[0] : -1, + vnet_hdr, fds[0], errp)) { goto fail; } } else if (tap->fds) { - if (tap->vhostfds && net_parse_fds(tap->vhostfds, &vhost_fds, - queues, errp) < 0) { - goto fail; - } - for (i =3D 0; i < queues; i++) { - if (vhost_fds && !qemu_set_blocking(vhost_fds[i], false, errp)= ) { - goto fail; - } - if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fds[i], errp); if (vnet_hdr < 0) { @@ -946,7 +942,8 @@ int net_init_tap(const Netdev *netdev, const char *name, } =20 if (!net_init_tap_one(tap, peer, name, ifname, - NULL, NULL, vhostfd, + NULL, NULL, + vhost_fds ? vhost_fds[0] : -1, vnet_hdr, fds[0], errp)) { goto fail; } @@ -979,7 +976,8 @@ int net_init_tap(const Netdev *netdev, const char *name, if (!net_init_tap_one(tap, peer, name, ifname, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, - vhostfd, vnet_hdr, fd, errp)) { + vhost_fds ? vhost_fds[i] : -1, + vnet_hdr, fd, errp)) { goto fail; } } @@ -989,7 +987,6 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 fail: close(fd); - close(vhostfd); net_free_fds(fds, queues); net_free_fds(vhost_fds, queues); return -1; --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030735; cv=none; d=zohomail.com; s=zohoarc; b=DYGUMSlr12cgFLKXggNfg1xLma2o9cUMspxMNPrx+UZKbd4rygHaY86PTr7eo91w4zuDx7q49e2fV+FJbX0DLKtu82pGkjO7kCNI7QFbqjYKEml+uvV+k4oL6tG90xsv0Z6eOwG9l6uS9UdnatdlrkVWQnWMEXbCEvWDwo8wk8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030735; h=Content-Type: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=DrFXvSxI0Kk2tcLgzbdAEMmlDq12az4sQ49oefYzYU8=; b=Gsw5hIkZmjn9ztKLIahmFz/WiDIPXF2OLkoa0WiacmOxhe7VG4rDhYstrCyD44WQ+yN7G7zCNwMFXc3HOFcjQYElgcZICtUSnPgugZkXF3TRcM3MqDMp+ao0BRmTNVI7dVli19rvylAkuJvydDHGyz0gDSODNbRTtQ9Ar1rsNRI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17800307350501007.7168892443419; Thu, 28 May 2026 21:58:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIr-0006Kv-BI; Fri, 29 May 2026 00:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIl-0006DN-9v for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIh-0008EZ-Nv for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:30 -0400 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-228-3dLEgBFuMHCc__GoWgJqsw-1; Fri, 29 May 2026 00:58:24 -0400 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-304b8d0ee63so3940328eec.0 for ; Thu, 28 May 2026 21:58:24 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrFXvSxI0Kk2tcLgzbdAEMmlDq12az4sQ49oefYzYU8=; b=K6/s4iry/a1eE7nMIJ5ZcC1mUJyvrvJvPRCz4CkNfZ0Ooa5Sbsiexymr+irRXJNyDissBP Brxa+lkcDuPP0ic0UPfD7kK5i84rac3bJ8Qex2u7z1P3BMKCanoMQMA7uVq8AcrHuQEZ0j FJu2KffogQ5pq0QdaasxRXH8vl0Ut2E= X-MC-Unique: 3dLEgBFuMHCc__GoWgJqsw-1 X-Mimecast-MFC-AGG-ID: 3dLEgBFuMHCc__GoWgJqsw_1780030704 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030704; x=1780635504; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DrFXvSxI0Kk2tcLgzbdAEMmlDq12az4sQ49oefYzYU8=; b=SLDR5X3kdwL3En/EEmfi1uSZodOoD0epJxZ9umaFugtGJ7f7p0ZjrAGKux4VqM9I5I CQXHVzFuodIVIZXSYM8CHpJ+3F9nEW5r5A7Lw9recaOkoEpzDdTMbVM4E75jZPgujt0W w7+4I4rsLwq/HdfWSGrKj58ddwknNGt302QbVpRXDQrh+D2NtL2HhJPJu5ripNpQQX/V ZEYno4OQhmHVDDyBcPvJZ1Bl1Sqfwr8+b5ad4UWpLHze3Frhs+0DmonziP+vZ2naQeQw vi2NC87gVDzy+4tY3af9MEU/MImHqBypkNQ9IO9DODw85n1iHhTymQ6N540z9v/HLt9d vKIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030704; x=1780635504; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DrFXvSxI0Kk2tcLgzbdAEMmlDq12az4sQ49oefYzYU8=; b=c8hI8CFUIsxTrY3kgEua9sPC7VFeSEZ+8UGGmKr3Olu5kGOoP+2dLtV/fPjRdL0zUD eZP6foxEh1QnwAbSwz7O4HM7MGEMePRcAYYZPfg+YJwrjdOG+FwKCmUsmO3bAd/kAQmb +MJoewWBibcUUDQ93BHHC+vG0BlrWRDPUUU4objAGUmFI8p06YIOKIZzi/ONCwNtfp3s +zMFoXwIl9YmJ8IQr3IeS28PGEv5pE/BhklmyYLDOrSikStOEvXROEa5HNdvF55orhRx oM6CslT95q0VFWsfvr1ncgAb7EPlPPLqE5hwMI8PFaEclFWXS64rb0vPN3jS/pz9AAQx FEDg== X-Gm-Message-State: AOJu0Yybfyu4zv0Naou+mBQAkO3Q9A2KM9awCcKZcLVLHMzY08axJhyY jBsmb19IzuQew01D94RZvB2a7oHI95fB/itAq8pH6BM9Xper23O9cw40rDQ4byTaFgYlSDLWW8w AaqzfrS1lxbfJNu6yN3PIdFl+JkA8Hg6Q2SrsFAs2YsfnEWt/kVxKl+WwlhX78vcoQtMDBrX2VY aDI7TXe8TIJWbrClEUx9N2Vywg/N/vOXDSLi3O3kWxqXg= X-Gm-Gg: Acq92OEhJEYiJWLMu+iSo/eueGXP/fNFnXxcqvIKrL05f6UHfWYIDUlbPTOTf6r1iJA pM4Tgr+CnjimoQq6YMqQDmgz6EH8qsHW4/I9/4lYdCVj3pcGHeNm+tvLTXqQkk0oOY6+YGY9waD Kw9MfOeDFICcDnqBxfZFS9Hrzdb24Okr6JYo1sG7cmv1rmcYTHVgxXhGQBV2jp4pxNisACAyEs7 lYOMgMzUvwJRx7CnWsfV98FBzGza4FpjzuHz8mtyRsesJ45RXphdt5iocTnJBPl70GKBgfX8uP5 dGu2SawM2yPHespm5hcy77wZJAkSbtPIgMgJTV3DH8v53X7T4djVJVLPF1P2CAtGn2c/uqpzHWb ygiQBDVYd87AZBBB6d7bFRFlHhCf0NOWB95ue9fVIINo3GPCHoRxVZ3F4N0b16rksNxTTwvwL X-Received: by 2002:a05:7300:8ca7:b0:2ed:e14:42e9 with SMTP id 5a478bee46e88-304eb231ec2mr642908eec.34.1780030703617; Thu, 28 May 2026 21:58:23 -0700 (PDT) X-Received: by 2002:a05:7300:8ca7:b0:2ed:e14:42e9 with SMTP id 5a478bee46e88-304eb231ec2mr642898eec.34.1780030702909; Thu, 28 May 2026 21:58:22 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 11/15] net/tap: net_init_tap(): merge fd=, fds= and helper= cases into one Date: Fri, 29 May 2026 12:57:26 +0800 Message-ID: <20260529045730.90322-12-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030736672158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Now fd=3D and helper=3D cases are just a duplication of fds=3D case with queues=3D1. Let's merge them all. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/net/tap.c b/net/tap.c index d5a719150b..c6bf8a7042 100644 --- a/net/tap.c +++ b/net/tap.c @@ -903,19 +903,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, goto fail; } =20 - if (tap->fd) { - vnet_hdr =3D tap_probe_vnet_hdr(fds[0], errp); - if (vnet_hdr < 0) { - goto fail; - } - - if (!net_init_tap_one(tap, peer, name, NULL, - NULL, NULL, - vhost_fds ? vhost_fds[0] : -1, - vnet_hdr, fds[0], errp)) { - goto fail; - } - } else if (tap->fds) { + if (fds) { for (i =3D 0; i < queues; i++) { if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fds[i], errp); @@ -935,18 +923,6 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, goto fail; } } - } else if (tap->helper) { - vnet_hdr =3D tap_probe_vnet_hdr(fds[0], errp); - if (vnet_hdr < 0) { - goto fail; - } - - if (!net_init_tap_one(tap, peer, name, ifname, - NULL, NULL, - vhost_fds ? vhost_fds[0] : -1, - vnet_hdr, fds[0], errp)) { - goto fail; - } } else { g_autofree char *script =3D tap_parse_script(tap->script, DEFAULT_NETWORK_SCRIPT); --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030788; cv=none; d=zohomail.com; s=zohoarc; b=LZruLRJHPLKBUB/3wEYH3YLdKARiI+e4XaDrCWEauiTJNK08nHI+GViRGi+XYMU6pQpm81/XdIzqlW9V+0F0Oe/QFrnbpaC01Qn89R5lq7rDEtiLfxf95vy6m54UptW5ieN6BiSAd/WRgm626HxQiP/GQ+QAhIIaOz1JP9uoEQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030788; h=Content-Type: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=R30LUVTxAYk4BwKAO0Omq+7KzeofNUrPyd+QTxsv7Os=; b=iothg31Bi3evs72x+B//Ar8BOHM3mU7/By67nOwf6CQ1iCaYV/F9gUoFHyE0M/EPhcxs0AWA/7zYGYYZqHPwzHQMseFvpWQWjvl4kwkp+D8D/uHLIak4Bw93Z6Hyg2SinLbAMIAADUyBPPXi4e9Goa3du8Swu/z3+qbcW4DAEQo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030787917125.39597222799978; Thu, 28 May 2026 21:59:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIt-0006SZ-BK; Fri, 29 May 2026 00:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIq-0006Jq-Nb for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIo-0008FE-55 for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:36 -0400 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-Vd8CPRzJMSWtU977td8RzA-1; Fri, 29 May 2026 00:58:28 -0400 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-304ee7d1368so116036eec.0 for ; Thu, 28 May 2026 21:58:27 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R30LUVTxAYk4BwKAO0Omq+7KzeofNUrPyd+QTxsv7Os=; b=ZbX7S+1aAKIJtorwzibHuYQz+RidnDskGgPtL6yCWzZD+wdhxo7WRjL0YvMunDHvbmg5C4 IXkFn32Q+I8pUF0m7sblCiNfeHVJeOSDjjXTPzKt9Gm4jLHA0xfZwHR3Eon/XsGrUl0Xl2 itO7ntTD8sEo4VCRCcYVC8TvlpOtFG4= X-MC-Unique: Vd8CPRzJMSWtU977td8RzA-1 X-Mimecast-MFC-AGG-ID: Vd8CPRzJMSWtU977td8RzA_1780030707 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030707; x=1780635507; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R30LUVTxAYk4BwKAO0Omq+7KzeofNUrPyd+QTxsv7Os=; b=acK5BdxGluHrsO+dTNK/XpAwx8Wjw3d5FFtkgd9pxwI+qobbrsRIGERH1POGR8LVi3 CMEzTb9Tm64VwU5BwLn6gXDom0HybKQEYYZKFTsihIB6jwJ0GlQso3Vmwhh5dOypD81X YIcKlhZO5TMSu2R/f7/RDnPxz/mkvIQpWxmGj7Fmj/krvKmlHIU5O+O9/uzMoickirjD G2ARx6bXfhNS6or1kNVeZxpgfKfdeH/e2Z+F7AvLYpHI0llFEJLGxaSoXIzbR4xsUhyX 7TwHVCbiDltt7yNunO2L/KV0wXFTorVuwADuJ9Vt53B3+Qg8EVqEIh6dbrTxnoT1zK/p ii+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030707; x=1780635507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R30LUVTxAYk4BwKAO0Omq+7KzeofNUrPyd+QTxsv7Os=; b=FpbRmpC3tO5XIrOPfePd04zQQQtYeoIsb1t7oKOe206xjo/BRuArJxSoI30dK1R0jy szTVLyfzrR1bLY/1X70x5M2/Amt628sUn5ZU/2e+IiIhmFRxQsY33tl4JR0rJcqgMojR Q9WHo5Jm1fZ8Zw/5C+OMJYwF4bHth8TYbNFEzMpxJKJdgR8hzH1ocsBO5+1xsHL0ybji e4F5gJLpJSHzcz695UwtFacdzOLy3C/mgVYiSYrDKMqvO/pmfcOMaQxRZJFrDmj+l0wD qPV8JKkHZqPG6czvR2q/TC7i+rKd8515nLaGinDyh2YhhEB1Xazc/2Q+5WY0M3pC1ec8 /VqQ== X-Gm-Message-State: AOJu0YxCJHA/zbPDcmt62mqYpa6BmCTR6iJmFEoCoQTL1P36LADUcdio VE+4PY+DQLosB9FZVnOauZwplYdwIIsh4OWGfvU1hZbV4pTNo68ajAUuDkuMM5aTTb0gHZLkOZB /9mvpCaWUpXOKpYBbwIata9KHfg9ltx9VUTAZbq1xFJokq3vaW1qlvIcsCHBSfYFnjm/Cq4nPXz kqv4b1jv2bgUn1tQmbBuzCym386mfMj6ENWOtbiV1kWnQ= X-Gm-Gg: Acq92OFK92tXBH0sGV6ysp2AwSiWIVb1qZ/iBUMp0GDALqS6NeibhR6PcCtWmSYaSJe vgoUD3C3q9BqNhAFv5R8k6tHabch5GVpzTqUoyxw52kPDvJbZX3EsygoTc6YMY7QCi3aZm0/4XP nbo+RHIaMyMKzF7Tpc1lPpA69d0pjQtmSe8mTrWzMCVQ+0JxGRo/YPD897zWSUixG6Jz1PgvhY5 y2tyxt7U6mxQom5LqQ12EO/V6MCOzKv2fmXnGJZ4gDSoOqGLgtnzt1uK0TXfMJ/G+Cg7luboJpT V5lkymQBMMwbVCx5T+nEv7RRhWXEO3/rcbDV9nO8Z8CVzJ8Kv4c7bUtipQiCrTY5JwR7B6lPHTo wZtQ1bEgT9Q+yqieNn6X2z3ANFuvXP0Zh72VlWcX/d6LMGIhkkQnPOcFUmQzVGVXkVjhSciaN X-Received: by 2002:a05:7300:ec07:b0:304:d92a:e60a with SMTP id 5a478bee46e88-304eb241113mr556422eec.31.1780030706786; Thu, 28 May 2026 21:58:26 -0700 (PDT) X-Received: by 2002:a05:7300:ec07:b0:304:d92a:e60a with SMTP id 5a478bee46e88-304eb241113mr556413eec.31.1780030706133; Thu, 28 May 2026 21:58:26 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 12/15] net/tap: net_init_tap(): relax QEMU hubs check Date: Fri, 29 May 2026 12:57:27 +0800 Message-ID: <20260529045730.90322-13-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030788581158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy queues may be set to 1, as well as fds may contain only one fd. No reason to block such cases. Let's check exactly number of queues. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Signed-off-by: Jason Wang --- net/tap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/net/tap.c b/net/tap.c index c6bf8a7042..e464f62b47 100644 --- a/net/tap.c +++ b/net/tap.c @@ -869,13 +869,6 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; =20 - /* QEMU hubs do not support multiqueue tap, in this case peer is set. - * For -netdev, peer is always NULL. */ - if (peer && (tap->has_queues || tap->fds || tap->vhostfds)) { - error_setg(errp, "Multiqueue tap cannot be used with hubs"); - return -1; - } - if (tap->has_vhost && !tap->vhost && (tap->vhostfds || tap->vhostfd)) { error_setg(errp, "vhostfd(s)=3D is not valid without vhost"); return -1; @@ -899,6 +892,15 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, return -1; } =20 + /* + * QEMU hubs do not support multiqueue tap, in this case peer is set. + * For -netdev, peer is always NULL. + */ + if (peer && queues > 1) { + error_setg(errp, "Multiqueue tap cannot be used with hubs"); + goto fail; + } + if (!tap_parse_vhost_fds(tap, &vhost_fds, queues, errp)) { goto fail; } --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030750; cv=none; d=zohomail.com; s=zohoarc; b=NJq0AYYsDwRN4algfID67Q0ARWVz/m14y6dhc+Xh+LU252GmvfuW2icN0/VuqdGOojydOLXubAy8eAgwIB727C9twAkk5YaCmPophE1av5Xwj+q5XXStwR4micPmI2bW971z8Mq0Hc17VLZhmKeMpt5D6dJzmzOKxP2z2qP6BA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030750; h=Content-Type: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=a7RFZipe/z2ZS40s0zyaVC+5GC6QzmqglvkKCyJm4m0=; b=RFhhoPK5tEBu5pQ23jQB/wVyvIxa7Cf+y6yeBBtugu92grbdmU4uWojv+5mh29+ULIYFhQCRNBXdYre9yZRf/EIN8fZ5AE35IdWWEjGiq/7HaUMQJvxhsSQV3XREbyjhElTDcatL5K0YA7Y3T5rY0j7SHV21Pj67I2W3hz+oG0M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030750108328.24815458206365; Thu, 28 May 2026 21:59:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIr-0006Lq-P1; Fri, 29 May 2026 00:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIp-0006Ik-Ls for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIn-0008F4-Hf for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:35 -0400 Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-BQ89JhDZOe-Fk6_z3SONtA-1; Fri, 29 May 2026 00:58:31 -0400 Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-304d8613efbso1751167eec.1 for ; Thu, 28 May 2026 21:58:30 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a7RFZipe/z2ZS40s0zyaVC+5GC6QzmqglvkKCyJm4m0=; b=RaIVG5SfoSHWzVMztuQAOfL4/UenXH+jUlevKm3hb11NWRv4t08/eVeHLr09G82q5KINa8 Bxtzl5qQ8XtbFR/EfHAVaZ2T7+QBABNkWslIEz7wePE4TT/B6LaB1cLQgntFLvzNf5+T19 QXAwgX4APf1yHeY8IMmjIMCIeXPy7FU= X-MC-Unique: BQ89JhDZOe-Fk6_z3SONtA-1 X-Mimecast-MFC-AGG-ID: BQ89JhDZOe-Fk6_z3SONtA_1780030710 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030710; x=1780635510; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a7RFZipe/z2ZS40s0zyaVC+5GC6QzmqglvkKCyJm4m0=; b=CXZ32NSG68n5a68LhH7Q0qmexh+gAetpN0gRhOv6VEf68D2j9pqncYY7XP79j9A7IV s+DFUOdVMpdsXZTdInPcHN0cmix73oGqcCt9amGWggHq4swmhLZmbKwfxlSScx6kWEpG 4pU3XyOeNGsoiRU0n5RNasnLX3+4nNg5egLc7W9KF8KjOLiKFDs/FgVYvJnR4QMirOT4 oc87tuQD2kV/DOQe6BTeH+3mZg6FOXE5k88SCtzyh1fcJAfexm9nJRSn972+wGBQALNJ YdUnTs5aj3gZ+ef18X8qKn41tkIM2lCZX2qnAu5iz1AvohTqZFvTh34PNJ2FJalf/CxI qDDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030710; x=1780635510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=a7RFZipe/z2ZS40s0zyaVC+5GC6QzmqglvkKCyJm4m0=; b=VdBxWHiAJfIgHvyyEsmeC/tJC2mbhvkwl/qFoIDbmGzWJmnOrpFR9jGqDJ8C/lGHGG WPn8YQQy9R2PkIgg1OwzJOl9cPaoEaqJixPDHY2wX5GLuOGnps+YnaI/uDV9wwvAqGFF 3QdUC5rGIw2l028rjnaaKsm4s8glQz7hY8qNv6AKsulTYKffcUG1C09R0ctxHJ0lBHZq lNqyZ8YtgdPaxf+dXtvNG9boHEd97RaN36mogffhalXbWMORJrvM2vPs+IAh8iusds+U AnV/GxX4yCvdX1hEbZXITWDzfiwefKw/7I8cp3PZE9JeOyM2nRuGx9g+ch4iRrYIWnis 9xsg== X-Gm-Message-State: AOJu0YyXlnuRIQUXbXHnpUxnP5dgTAJAE2tuX4AlEm7GGQHkDnwKIlEd ogirLvYvJ4KZm8c0qKqO0+pXuLp7SXbZhMz/f7FHZHxTUjU/X5XLF4eWKJQMckEcy4INisVt4qE q/EjmSxfigwjDwqKcmCLHikJuEQOAERA3zPa8W6yn1kcVNzoOlZjgYnOIq7vL1Sk7T9dxFmbesU 0TG7A0yHrP0i3QRbBBEEVS0DChC20z0TneBETDWKbku7A= X-Gm-Gg: Acq92OHArMf2P4svLnqy0WSFDuhKxsuz+xqQEMDbmT1uFtOCsgt0LQUI3657yQ8uEzA OOG3N9DFP75pxHdCcuoXfg6amCnjOPp9mLqHJuiM8StXUIPH24sD+fWT+Utw9vzRXN68r1O5q9R xcPBv07KOi8YCMgqn9vGHVXCiyO88n/biiujpqCGwfTGmn0iqLE9ce4OVrSrTD88/YQg05qTO2d XvxZEfCq8onbPQLg0uXdsBd41D9D2A/vsQk7yarFR4gRDhnbI90lnyG23ISS67wweGnIiK3ntes dZGWfyyAIuQgnUmlVt4unnTZ9mzMoinuUQB0AEpeHqrYn9oUNhKz0UvISp/e55og+bt5iE0QTkB jUIXZ5mSvJkS7TY6p6HeBFAt/3E/ewVCsyVJdv8Ip2tpfqNEvqoR+qZ7lEsUN6yT0OUAkuH4h X-Received: by 2002:a05:7300:a584:b0:304:de94:1c2c with SMTP id 5a478bee46e88-304eb2875bbmr695958eec.34.1780030709756; Thu, 28 May 2026 21:58:29 -0700 (PDT) X-Received: by 2002:a05:7300:a584:b0:304:de94:1c2c with SMTP id 5a478bee46e88-304eb2875bbmr695946eec.34.1780030709131; Thu, 28 May 2026 21:58:29 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Vladimir Sementsov-Ogievskiy , Jason Wang Subject: [PULL 13/15] net/tap: check that user tries to define zero queues Date: Fri, 29 May 2026 12:57:28 +0800 Message-ID: <20260529045730.90322-14-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030750414158500 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add check for queues parameter to be non-zero, and for fd/fds parameters to be non-empty. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Jason Wang --- net/tap.c | 4 ++++ net/util.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/net/tap.c b/net/tap.c index e464f62b47..57ffb09885 100644 --- a/net/tap.c +++ b/net/tap.c @@ -807,6 +807,10 @@ static int tap_parse_fds_and_queues(const NetdevTapOpt= ions *tap, int **fds, error_setg(errp, "queues exceeds maximum %d", INT_MAX); return -1; } + if (tap->queues =3D=3D 0) { + error_setg(errp, "queues must be greater than zero"); + return -1; + } queues =3D tap->queues; *fds =3D NULL; } else if (tap->fd || tap->fds) { diff --git a/net/util.c b/net/util.c index 1998a6554e..8265f15548 100644 --- a/net/util.c +++ b/net/util.c @@ -94,6 +94,11 @@ int net_parse_fds(const char *fds_param, int **fds, int = expected_nfds, return -1; } =20 + if (nfds =3D=3D 0) { + error_setg(errp, "no fds passed"); + return -1; + } + *fds =3D g_new(int, nfds); =20 for (i =3D 0; i < nfds; i++) { --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030791; cv=none; d=zohomail.com; s=zohoarc; b=Ra7fvQQx5TqX5qcToeFuXJekmrMJxahVAjbFkvFGE1ncHA1042UmqBZfH9VzWFPzOepUq8Bin4ojPCKwztdjNpgYkfdINpfr7P2e7evV5CLzFHqri1MpIEKEpTmMjiOUozuxDtPpFFlIxrLeSfDIPNeZhzA2Fcl4bzZQSdKS1Co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030791; h=Content-Type: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=AeDqljhGetjIjsOuSvY7RejNRG8txoyWC7EVFVdHKNs=; b=oLOJBSzqM7yYObz91jBm2/Ku4I19p1wt0x9Y5/kUMO85rNcM3fu/bku1bk97kfQlVDTL13+Q9yK7As3nyt42+h5BxSBzTRcU/IZb17Vcpfat3caikLjLPbIIwdqeKF5+9JfMBQg45s8PekaROBERw8XMztpyUob0AxXcGqlbUbg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030791419572.636374426854; Thu, 28 May 2026 21:59:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIu-0006YU-Lo; Fri, 29 May 2026 00:58:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIs-0006Pf-Aa for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIq-0008Fe-Dl for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:37 -0400 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-uCEYnhurNN65UQpIpf5Z2g-1; Fri, 29 May 2026 00:58:33 -0400 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-304ec73b015so845649eec.1 for ; Thu, 28 May 2026 21:58:33 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AeDqljhGetjIjsOuSvY7RejNRG8txoyWC7EVFVdHKNs=; b=fh/EmA0BMzEgIaRATi6enqSv3cmamQqAHu5/e32/GK65T+aLeUZFuIoHRs7sN8XeCtICcG y5TpAkmnV52jFEqnxvEFGlcCkLsnw55Gcl0iV31jC4a1u9f/p/D6b6EImPL1lZvht1c8Te gtf8nFvOs9KdDNCAVPvkBpM7AudoNnA= X-MC-Unique: uCEYnhurNN65UQpIpf5Z2g-1 X-Mimecast-MFC-AGG-ID: uCEYnhurNN65UQpIpf5Z2g_1780030713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030713; x=1780635513; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AeDqljhGetjIjsOuSvY7RejNRG8txoyWC7EVFVdHKNs=; b=kqyhAoLPTcSI0RrM0fltp7CmHFpfu800ScZPNsexv08zpULZ5SRh8JaNRFgB/cVjr3 qNk+EEaE/IvPEfqhs0BLVexDfdEDkAhXggii/WsZ0lqD2dMOVNtbBZc4or6FFrBmJNCz WVC8/EsJw0ky1fr19B9fqawyyQEO2PyghSBvfAkS3cpVPel2on1wRTEBIyuY60APpLLf UF3D7PtZ+caZbDJAoG/P8YaelOCSQh/TJQvOZEHE2yIRVEYwZOwhz5s5GUNiTuMXVr3W fFmvTwRz/Ji47IVvtB/GQOAWMTHIhQgy3YI5ty7XtvAq38f5/yc4WHEmKtt+vyrlbloj x4cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030713; x=1780635513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AeDqljhGetjIjsOuSvY7RejNRG8txoyWC7EVFVdHKNs=; b=JzqIQTZ4ds2oKfZIKvh3A5QG05xu99ArlceoO+v75KutRtorZjQQe0y8rAMZgx/Yu3 9EmpM/cp92qRNtbm69gTRyXpN8B7oOc/s0+9+zRnUFcZ2OqlcMwx/Se9jJQZ9PacGAjf hLx7nxmp0SjzOD/D+7t0Kp6rPT/FB+aB4k2WrAQyGzX0rWgGCuBA2YkfjK6iWuX9/6wC 1ytQVe4EWNFPzALGoKSQx190DD7JlGaakUvNTn42LPQgug9mO4j5LLoBf0Bhmn97YTDo uEFsNC2ImdODfRYi/gesyeO92lT8fs1E0DV8QXDbYzeqzCunghAOf7wG55neqMenfOGx WMeg== X-Gm-Message-State: AOJu0Yxmnk1XypFDJBd2pMwtkN5ZRZxrvEjdqFLdWgxKttz+zbLuVtHm w9FQz2zWfLL2k9KnIulCZTbwAPjS26Kz6v+370uO9GUfRpUgaqags+YVMMHaIK1pfGBvWQtButC 8/JsnEOqPCaQHzLsY7/6awCdTYMfRFFYO4u/7v9P00lhawHdQMj3D8J+2oJMc0RdRpag39HLoy3 LvGZ/tX6Ft1kEBGRi6/NBwUtXFv/64TWzU8+0wzi5+1W4= X-Gm-Gg: Acq92OFerdheOnjPflvUuZ4n3hQuIJrqbMATpM0PdwFyVVFFyTfZekCqWvrmXmmx7tz YZCMS+rjP1/BxWT9tDEaeC1SswExzP5n6lv94wS7IN/W+UTGimG9mA61NEaloxpnZZf8Jv1Me99 GIG0p01YAAzvnvo1i9Am6SL6OO8KzDovS3TsQjZ5IfpXAwKssmLXIw8mVPXWy4fxI6KsgE8HUnw VtlT1d3bmuLNxDo/hWI1RkJYYTDoXjjarEPebAYdsJ0H7Nu4bG0PFEb2TtJc0b1Bn4aY/g/ECnC d7qa0ObHkQqnTyxcjFLhZx+gcxPoo1fE9nRT2BEprq4OHppGzLxMTRzZimEjaI/6X6s9clos1TR /xYr14QlwGazLFTjUZYIGSAnlKrItJJjLBWDAotEcE5MDaalMGbFthJ9eAIBOf9ZL179x18I4 X-Received: by 2002:a05:7301:1e84:b0:304:cd60:b6a6 with SMTP id 5a478bee46e88-304eb24c642mr576531eec.30.1780030712715; Thu, 28 May 2026 21:58:32 -0700 (PDT) X-Received: by 2002:a05:7301:1e84:b0:304:cd60:b6a6 with SMTP id 5a478bee46e88-304eb24c642mr576514eec.30.1780030712081; Thu, 28 May 2026 21:58:32 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-stable@nongnu.org, Jason Wang Subject: [PULL 14/15] hw/net/rocker_of_dpa: Check group ID pointers are not NULL Date: Fri, 29 May 2026 12:57:29 +0800 Message-ID: <20260529045730.90322-15-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030792389154100 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In of_dpa_cmd_add_l2_flood(), we use rocker_tlv_parse_nested() to fill in a tlvs[] array. If the guest command is valid then the entries should be pointers to TLV data items with group IDs. However, if the guest gives us bogus data then rocker_tlv_parse_nested() indicates this by leaving the tlvs[] entries NULL. In the other places that use this function, we check for this before using the value, but here we forgot, and the result is that QEMU can crash: #0 __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-v= ec-unaligned-erms.S:331 #1 0x00005555574f7137 in __asan_memcpy () #2 0x0000555558106792 in ldl_he_p (ptr=3D0x8) at /home/pm215/qemu/include/= qemu/bswap.h:278 #3 0x0000555558106755 in ldl_le_p (ptr=3D0x8) at /home/pm215/qemu/include/= qemu/bswap.h:311 #4 0x00005555580f85ed in rocker_tlv_get_le32 (tlv=3D0x0) at ../../hw/net/r= ocker/rocker_tlv.h:114 #5 0x000055555810a8ad in of_dpa_cmd_add_l2_flood (of_dpa=3D0x506000082e38,= group=3D0x503000b4e440, group_tlvs=3D0x7fff68702c20) at ../../hw/net/rocker/rocker_of_dpa.c:2032 #6 0x0000555558108a74 in of_dpa_cmd_group_do (of_dpa=3D0x506000082e38, gro= up_id=3D1073741824, group=3D0x503000b4e440, group_tlvs=3D0x7fff68702c20) at ../../hw/net/rocker/rocker_of_dpa.c:2115 #7 0x0000555558108730 in of_dpa_cmd_group_add (of_dpa=3D0x506000082e38, gr= oup_id=3D1073741824, group_tlvs=3D0x7fff68702c20) at ../../hw/net/rocker/rocker_of_dpa.c:2135 #8 0x00005555580f66ec in of_dpa_group_cmd (of_dpa=3D0x506000082e38, info=3D0x514000072e40, buf=3D0x5070002356c0 "= \001", cmd=3D7, group_tlvs=3D0x7fff68702c20) at ../../hw/net/rocker/rocker_of_dpa.c:2194 Check for NULL values and return an error. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1851 Signed-off-by: Peter Maydell Signed-off-by: Jason Wang --- hw/net/rocker/rocker_of_dpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index 3190a0e75c..958f3006c1 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -2029,6 +2029,10 @@ static int of_dpa_cmd_add_l2_flood(OfDpa *of_dpa, Of= DpaGroup *group, group_tlvs[ROCKER_TLV_OF_DPA_GROUP_IDS]); =20 for (i =3D 0; i < group->l2_flood.group_count; i++) { + if (!tlvs[i + 1]) { + err =3D -ROCKER_EINVAL; + goto err_out; + } group->l2_flood.group_ids[i] =3D rocker_tlv_get_le32(tlvs[i + 1]); } =20 --=20 2.54.0 From nobody Sat May 30 17:44:05 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1780030778; cv=none; d=zohomail.com; s=zohoarc; b=E00vrA0nbU1LRV2xBVoCLsO9U4vBg+665NC29p2ghlz2qg6zLUOlmDqedtknddXFUF4sSvgaQCZpyX6WNsf0dRn/UcBzjXFt8aSI3sBGc7B6MErs4tFMxQRLhYBJT72bW/aDDgk11ROJEXEp8SC9DsCvmmDKqK/MZFG11+sbWcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780030778; h=Content-Type: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=zp5LvdVtoFOJ0xQQHzcR7UQuvdngw5szwUJi+GkhgiE=; b=ixAXvmpBAiPJ6snd7/i5ELcCS4d9v2gzuu7xakYazmzedkEka6Vseo6rinxwxWKkBARDvyYg7Pxdmo34OcM7YAWMcyH7f3mE8+uyfT2r49aa2dN7T7BIYTcAvNlv07pdqLuaH01lmnmHVb2pAkoIudfTfvdq0scs1eyRq8LnLAE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780030778971671.0762347335057; Thu, 28 May 2026 21:59:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wSpIz-0006sT-93; Fri, 29 May 2026 00:58:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIw-0006fO-Dp for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wSpIu-0008GV-Rt for qemu-devel@nongnu.org; Fri, 29 May 2026 00:58:42 -0400 Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-Mql47QBuPySZLvZHrKBEYQ-1; Fri, 29 May 2026 00:58:37 -0400 Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1361d52b3a0so13224704c88.0 for ; Thu, 28 May 2026 21:58:37 -0700 (PDT) Received: from localhost.localdomain ([107.172.97.67]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed3358b1sm562865eec.13.2026.05.28.21.58.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 28 May 2026 21:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780030720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zp5LvdVtoFOJ0xQQHzcR7UQuvdngw5szwUJi+GkhgiE=; b=S4j6eY/dUUFtAHtAfCvIJiLCv2XOmU6PCziAQiz1n60Za3/xVVogaKvpBq+64lO3sGxmYl 8g5/1GbdqKHj7vwm64CKUmesfSK03mp0tboYhiW//PdB1ypRkuBKUJOQUMYQ6z+9iY7+55 86aaFYBAJCOCVo4kKJ4W2xHp/dUqgoQ= X-MC-Unique: Mql47QBuPySZLvZHrKBEYQ-1 X-Mimecast-MFC-AGG-ID: Mql47QBuPySZLvZHrKBEYQ_1780030716 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780030716; x=1780635516; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zp5LvdVtoFOJ0xQQHzcR7UQuvdngw5szwUJi+GkhgiE=; b=nlWAjvbyPxfCqj1mt8deCKh/nXrFvqNihwAEBtNE5NmZYYgbmr/xE8cM6nff7fH4q+ wkIBLsM4t0OrJd3kgvZbr+VXMYipkyl/7XBmziNZeOs5v/XdKnuLHjxW2zfq/SQbwASo jZU7GImhlsLNF8N8S0OcQbicB9mKzYx3KSnweVkplmgzOVGO0kr0yQx8ex5jEaRug8QR ZBswsDA0q2hzBqCTXYqIlGxoXS9KM8O0skyZrrTM9f9a256/VpmpnoeMKY0KSOhfzo0Y du7KTPJdMf/Mxdv1AJhAK1GX5IOPyXYRzUQcMK4/Quh7xmxZx1beGiEhFfOuTEnIlh8l uN6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780030716; x=1780635516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zp5LvdVtoFOJ0xQQHzcR7UQuvdngw5szwUJi+GkhgiE=; b=TF41ulXvJZsXehTt6Xq/4Dp2yV8Q91NvLz15XrcjEzgJOqaFIEqejZ91zaNRwfADmZ f9fYqoCxLPtdbTBqCxvBjHh7PBoFYk2yTsjcLYJMv8ynRfZoO2brq0aMtngKR6mO7tnO OrBuziT1yFTRNzzMNU8DruvPt+LVJZ4LBP7lDszgPqpgMwbJ8C/V3bS8m9hS+nU1P+E3 oWPOqVAugrgMUf6ok7+Jvync/9qxap+BuIoClMggwxmYpSGKCQLoBYithLwLDkYmxYwd +ZEvOrpkIKCqHHdNPDHOeN64Cjpx9s+kaiMb0/ERks2etl78JUjo1RndJmInmktf7pMD Y25g== X-Gm-Message-State: AOJu0Yyi9hOtmK4T9qzqPUgnstEalaP6gtO0lirQ59fr+ctuX9eimq7X 8aKy1ych+0EZjhLbJPrKFXJnAoJlISbuaCtrnvpiOu4JDY0RC8ZKP5DhEj6phpox9ShodH+MGjA IyvF2+7+R0e+0dMdz6LI1sA7twTj9S0pyX5Q7Td8yZhD8rRLJIiV3W7J6cvD0eCq5ZGUWSD81YD XaBpWRxtOufDXNTyXT6mCY0PHMJQivgoVkqrJAdCxiRtk= X-Gm-Gg: Acq92OHXz93GXATh1uMBge22pLslUL3EuHXY+++PB1yafQ35Mc/Xoivu5g7LK2EIdAA nQhZ1lOY8isFZDiiGvIjld4XPCMTgo8S63Q8sNeeuVoKgD0Gt2ehz2rUI3oX/SaFfQglissY+lh Ku9iKktT8Jl7dceo9okRsxfiqrsqBQhtYyxvzBSfTPsli+3WmPvilxpB1bt/ciZm0xh5pc+waQv xZZjaUOGjp7SzAW8MKHTWYHv3HS9k6LUDOy+5xxNCuM6tKJ0KzvPkjasDZUhglt9xb74j+2OLre Yuw0jTcvooxIdbwuYsJn2nfjdB4WuQhZHj+HQfmHtK8jLvMlOMRuCYgGQO/TBvKVsNQfDuiGhrY HqYRiQ93FVMv+JCxNni/OGKUSHK3CRITe681w+xl5AiEb6Qa/PIaxE4sBa4vY3o6qHEz2FsYB X-Received: by 2002:a05:7022:4590:b0:12d:ea6a:1d33 with SMTP id a92af1059eb24-137aedd0859mr503942c88.33.1780030716392; Thu, 28 May 2026 21:58:36 -0700 (PDT) X-Received: by 2002:a05:7022:4590:b0:12d:ea6a:1d33 with SMTP id a92af1059eb24-137aedd0859mr503928c88.33.1780030715639; Thu, 28 May 2026 21:58:35 -0700 (PDT) From: Jason Wang To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-stable@nongnu.org, Jason Wang Subject: [PULL 15/15] hw/net/rocker_of_dpa: Avoid unaligned accesses in _of_dpa_flow_match() Date: Fri, 29 May 2026 12:57:30 +0800 Message-ID: <20260529045730.90322-16-jasowang@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260529045730.90322-1-jasowang@redhat.com> References: <20260529045730.90322-1-jasowang@redhat.com> 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1780030780602158500 Content-Type: text/plain; charset="utf-8" From: Peter Maydell _of_dpa_flow_match() tries to do masked comparisons of OfDpaFlowkey structs by casting pointers to them to uint64_t* and then doing the memory accesses as 64-bit. This is undefined behaviour because the pointers might not be 64-bit aligned, and the UB sanitizer spots this: ../../hw/net/rocker/rocker_of_dpa.c:321:20: runtime error: load of misalign= ed address 0x512000164044 for type 'uint64_t' (aka 'unsigned long'), which = requires 8 byte alignment 0x512000164044: note: pointer points here 02 00 00 00 00 00 ff ff 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00= 00 00 00 00 00 00 00 00 ^ We do know that OfDpaFlowKey structs must be at least aligned enough for uint32_t accesses, because that's the type of the first field. Switch to using uint32_t accesses in the loop. Because the "width" field is always set via the FLOW_KEY_WIDTH macro and not exposed to the guest, we can adjust the macro to store the number of uint32_t to be checked rather than needing to change the loop boundary in the match function. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Signed-off-by: Jason Wang --- hw/net/rocker/rocker_of_dpa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index 958f3006c1..3d6f55b512 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -99,13 +99,13 @@ typedef struct of_dpa_flow_key { } nd; } ipv6; }; - int width; /* how many uint64_t's in key? */ + int width; /* how many uint32_t's in key? */ } OfDpaFlowKey; =20 -/* Width of key which includes field 'f' in u64s, rounded up */ +/* Width of key which includes field 'f' in u32s, rounded up */ #define FLOW_KEY_WIDTH(f) \ DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof_field(OfDpaFlowKey, f)= , \ - sizeof(uint64_t)) + sizeof(uint32_t)) =20 typedef struct of_dpa_flow_action { uint32_t goto_tbl; @@ -304,9 +304,9 @@ static void _of_dpa_flow_match(void *key, void *value, = void *user_data) { OfDpaFlow *flow =3D value; OfDpaFlowMatch *match =3D user_data; - uint64_t *k =3D (uint64_t *)&flow->key; - uint64_t *m =3D (uint64_t *)&flow->mask; - uint64_t *v =3D (uint64_t *)&match->value; + uint32_t *k =3D (uint32_t *)&flow->key; + uint32_t *m =3D (uint32_t *)&flow->mask; + uint32_t *v =3D (uint32_t *)&match->value; int i; =20 if (flow->key.tbl_id =3D=3D match->value.tbl_id) { --=20 2.54.0