From nobody Wed Apr 15 07:00:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775828488; cv=none; d=zohomail.com; s=zohoarc; b=TDV7Oisg7N4ORHCbbW2FcNqEYzolTHWS+nz3BCSDZn5YbPu0KPcCHAVbDTM/wdS2ysMTfyRBcBBVHZGCOtXKtP2R1ptjklSxtWbZ8yWJWRAi/KZ8tV+cQiqZLAhI91VVLZ7pkH61fFCS9VTRpFsWfulPjdp47NUd7lkGSvrtXw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775828488; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=8dTB1YYE99oDfXAkIyNegEg4ybKQ2ztiIK2taCeM5Do=; b=PP+fsYswlthyd2TDUpYS0GprC2ROm+Op429UZYXAYhEWcIlTBEp9AReSqX5epfSdTtaag1U11p9/Wyjz1oQri18KLCr52blIE9BztZb8A+soBb+sqmGqtOESeCxpUzX/dr8G7D0MMPnBZ/pUQCKudSragqEfAmbZSUpWnD+dDtw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775828487996168.27025075061715; Fri, 10 Apr 2026 06:41:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id AF8FC3F2FD; Fri, 10 Apr 2026 09:41:25 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 8E18E41827; Fri, 10 Apr 2026 09:39:40 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 581083F2F7; Fri, 10 Apr 2026 09:39:25 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D4B7E3F872 for ; Fri, 10 Apr 2026 09:39:23 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-571-5jOoAXF8MHucAiiz8AVdTQ-1; Fri, 10 Apr 2026 09:39:22 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1E95E19560BB for ; Fri, 10 Apr 2026 13:39:21 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7B007195608E for ; Fri, 10 Apr 2026 13:39:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775828363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dTB1YYE99oDfXAkIyNegEg4ybKQ2ztiIK2taCeM5Do=; b=fCokQNthLx6OKROKB5SqvAJ1ngBdLge6PNu+/JOm0yrjnwbMLtCNTMLj79dwogEgRTimN+ 1zDEAAI3Mzzo/Cgka177+BzYyrCJF5BHS94Qa7nNuicaPfoGRhjq1UbE2+jztSeJ8lnR+N jCzmpx+NJi4mgYuKRXulIbhIzERiMq4= X-MC-Unique: 5jOoAXF8MHucAiiz8AVdTQ-1 X-Mimecast-MFC-AGG-ID: 5jOoAXF8MHucAiiz8AVdTQ_1775828361 To: devel@lists.libvirt.org Subject: [PATCH v2 1/2] virnetdevmacvlan: Wait for udev to settle after creating macvtap Date: Fri, 10 Apr 2026 15:39:16 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: otGrdFxkWNfZb0Bu2a99hWLPGYnNU6XX_f4AC__qmr8_1775828361 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NBP7HCJPR4DQWKPLFAPTQ7TV3DQXMJ2I X-Message-ID-Hash: NBP7HCJPR4DQWKPLFAPTQ7TV3DQXMJ2I X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775828490789158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik When a macvtap interface is created (e.g. during domain startup or on device hotplug) libvirt then open corresponding /dev/tapNN in order to pass FDs to the hypervisor. These FDs are labelled before passing, but if creating the interface and open() happen in quick succession, i.e. when udev did not had chance to run, then the /dev/tapNN node might have default SELinux label (device_t) instead of correct one (tun_tap_device_t). This then leads to AVC messages, like the following: type=3DAVC msg=3Daudit(1774535384.365:1238): avc: denied { open } for = pid=3D6765 comm=3D"rpc-virtqemud" path=3D"/dev/tap33" dev=3D"devtmpfs" ino=3D805 scontext=3Dsystem_u:system_r:virtqemud_t:s0 tcontext=3Dsystem_u:object_r:device_t:s0 tclass=3Dchr_file permissive=3D1 Therefore, allow udev to settle down after macvtap is created (by calling virWaitForDevices()). Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/866 Tested-by: Johannes Segitz Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump --- src/util/virnetdevmacvlan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index cde9d70eef..436f8479a9 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -119,6 +119,11 @@ virNetDevMacVLanCreate(const char *ifname, return -1; } =20 + if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) { + /* Allow udev to process newly created macvtap. */ + virWaitForDevices(); + } + VIR_INFO("created device: '%s'", ifname); return 0; } --=20 2.52.0 From nobody Wed Apr 15 07:00:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775828537; cv=none; d=zohomail.com; s=zohoarc; b=V2a4slyN59KTbg9jMFwgUbpT1enq9R7qZBzMukd6h1yFJdYKPqiUiEOgX26wUAVSwew3PR2rUeeL0bTmhk1yZ0+ts1aRqQHVFr7K2PXTXmEieKTNc4c7na5BWzc1xNBG780pHE/dRRHXt1MwEm5dQ5vEZL6efaUkG2jt/sBDT5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775828537; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=mtW2qma/VuWVM5ZcI3z1iPE77gH+Z1fSbjuvxZTktyU=; b=glSqM7kJNH35RzJF9SxZb25JxYV9laUArd2reXprKkBtK8bfvzyQqEoxQXC4q1S3rjPmyDc33yfIoa4UqrHj468n/0gwscBPhfC2S0+at0w9rUWsJefJMxk6572c9h+YOsh1Nw/uj7eAmYfLA38i9eK5DcdZ97TQ49f+/0Ly5WQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775828537737937.0730888201948; Fri, 10 Apr 2026 06:42:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D74263F2F7; Fri, 10 Apr 2026 09:42:16 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 682F541992; Fri, 10 Apr 2026 09:39:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B0CE83F2F7; Fri, 10 Apr 2026 09:39:25 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 99AB03F87D for ; Fri, 10 Apr 2026 09:39:24 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-sSlaBVJlM26C30732A639Q-1; Fri, 10 Apr 2026 09:39:23 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1E1801956048 for ; Fri, 10 Apr 2026 13:39:22 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 79D30195608E for ; Fri, 10 Apr 2026 13:39:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775828364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mtW2qma/VuWVM5ZcI3z1iPE77gH+Z1fSbjuvxZTktyU=; b=XQJmxLaqmC3eCx7YhXDayQpeBT37iYGDNqRGqOan/XNvqOMcKk7hMWUIZ0w5rOg8M15CAR yGkLTrMgokYGSoT9pEVoGEcPqEINSlcjRtgWI3tXkrdaEox+spT9V26Tx2nTGA7drO4SM0 wokVL3c0kcEZSKQKwfaUNNT3v93zLPA= X-MC-Unique: sSlaBVJlM26C30732A639Q-1 X-Mimecast-MFC-AGG-ID: sSlaBVJlM26C30732A639Q_1775828362 To: devel@lists.libvirt.org Subject: [PATCH v2 2/2] virnetdevmacvlan: Drop udev busy loop from virNetDevMacVLanTapOpen() Date: Fri, 10 Apr 2026 15:39:17 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -wmtuN0tcG6ICZl9d2n4RG50CAPm41N8TLbS8Wlpacw_1775828362 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UJK5NADWWDA6AOAQQCL6IADN5K5HAP5J X-Message-ID-Hash: UJK5NADWWDA6AOAQQCL6IADN5K5HAP5J X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775828540438154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Now that after previous commit the wait for udev to settle down is done right after device creation, there's no need to have additional wait in virNetDevMacVLanTapOpen(). It's effectively a dead code. Remove it. Tested-by: Johannes Segitz Reviewed-by: Laine Stump Signed-off-by: Michal Privoznik --- src/util/virnetdevmacvlan.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 436f8479a9..e6f4e1ab0e 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -159,7 +159,6 @@ virNetDevMacVLanTapOpen(const char *ifname, int *tapfd, size_t tapfdSize) { - int retries =3D 10; int ret =3D -1; int ifindex; size_t i =3D 0; @@ -173,20 +172,13 @@ virNetDevMacVLanTapOpen(const char *ifname, for (i =3D 0; i < tapfdSize; i++) { int fd =3D -1; =20 - while (fd < 0) { - if ((fd =3D open(tapname, O_RDWR)) >=3D 0) { - tapfd[i] =3D fd; - } else if (retries-- > 0) { - /* may need to wait for udev to be done */ - g_usleep(20000); - } else { - /* However, if haven't succeeded, quit. */ - virReportSystemError(errno, - _("cannot open macvtap tap device %1$= s"), - tapname); - goto cleanup; - } + if ((fd =3D open(tapname, O_RDWR)) < 0) { + virReportSystemError(errno, + _("cannot open macvtap tap device %1$s"), + tapname); + goto cleanup; } + tapfd[i] =3D fd; } =20 ret =3D 0; --=20 2.52.0