From nobody Sun Sep 7 23:49:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 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=1756098583; cv=none; d=zohomail.com; s=zohoarc; b=X2j/Qi6sj1bx7UQPXIyhtpKSOeQHORXJc8nhBK0kNdzNcO3vme1DIoEOF1b+/PpNbs0U68PzMi3LYpTz/rfKXDJy+1F4mqVlLXCvSysFwly3kIVdcsCCDk783DS+892ARWh37Gt2y/0NN4admAsNugHbN/7KeOyOVBelv0pOO9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756098583; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=BEGbV7xzT6DLq5h6tNNSREMM+GJN/MzuU8HopQsTrSA=; b=Vp6Lz37SJ27NBqRjLmgJo6ZufAKexEXvyrrszvcPoTYJEeZR/P+e9UrA7rXW7v934fUYw3Pg6bjvim1JwbE08y/TLvV+auX7t1Q3xBoX5ORUiC9W4Ao7NG85iIcnLzbXAnEv0H2ZsWasZJ+mg+mwsmkZCFCTAuNj5IVKZmIr8pY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 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 [8.43.85.245]) by mx.zohomail.com with SMTPS id 1756098583178578.9057878910068; Sun, 24 Aug 2025 22:09:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B4104417DB; Mon, 25 Aug 2025 01:09:41 -0400 (EDT) Received: from [172.19.199.4] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 90098417E2; Mon, 25 Aug 2025 01:08:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C6B853F953; Mon, 25 Aug 2025 01:08:17 -0400 (EDT) Received: from mx1.osci.io (polly.osci.io [8.43.85.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1C36C3F318 for ; Mon, 25 Aug 2025 01:08:17 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 995) id 3D95123D31; Sun, 24 Aug 2025 23:49:17 -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 ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mx1.osci.io (Postfix) with ESMTPS id 5576C23D2E for ; Sun, 24 Aug 2025 23:49:16 -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-327-335JGWHuMf6jvVSwKw2vLA-1; Sun, 24 Aug 2025 23:49:13 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 1B93319560B4 for ; Mon, 25 Aug 2025 03:49:12 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.88.108]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8779A18003FC for ; Mon, 25 Aug 2025 03:49:11 +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=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756093755; 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; bh=BEGbV7xzT6DLq5h6tNNSREMM+GJN/MzuU8HopQsTrSA=; b=SDbIWkWMvYfgzyMiN2qNb8kaH2hf5VXtyJHF77NM26xd6IOAzfW+Mw2NLy1NcyxRxvss5K +6oZACRjSUgd1/PN18KyFt3Vt8GrsvMjdvMw/IuG61olU+q+CSnf3DbsnqnLO1Md4J8/Xb HmYQNPgIU7G7/3cjfhaowiRGSmcaiUE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756093755; 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; bh=BEGbV7xzT6DLq5h6tNNSREMM+GJN/MzuU8HopQsTrSA=; b=SDbIWkWMvYfgzyMiN2qNb8kaH2hf5VXtyJHF77NM26xd6IOAzfW+Mw2NLy1NcyxRxvss5K +6oZACRjSUgd1/PN18KyFt3Vt8GrsvMjdvMw/IuG61olU+q+CSnf3DbsnqnLO1Md4J8/Xb HmYQNPgIU7G7/3cjfhaowiRGSmcaiUE= X-MC-Unique: 335JGWHuMf6jvVSwKw2vLA-1 X-Mimecast-MFC-AGG-ID: 335JGWHuMf6jvVSwKw2vLA_1756093752 To: devel@lists.libvirt.org Subject: [PATCH] qemu: fix multiple missing setup/teardown of passt process for interface type='vhostuser' Date: Sun, 24 Aug 2025 23:49:10 -0400 Message-ID: <20250825034910.20582-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lQcwO1eSoVaydicFLyiu5MX9cpXWn_fnVcZ03d161k0_1756093752 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: X3JTYA3TQ75U6QI653Y34LUF7VPGQIUW X-Message-ID-Hash: X3JTYA3TQ75U6QI653Y34LUF7VPGQIUW X-MailFrom: SRS0=GM6U=3F=redhat.com=laine@osci.io 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: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1756098588018124100 Content-Type: text/plain; charset="utf-8"; x-default="true" passt networking support was originally added only for , and all of the codepaths leading to qemuPasst*() functions were protected with if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) When support was later added to use a vhost-user socket to connect between the passt process and qemu process, *some* of the conditionals similar to the above were changed to be if ((net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER || net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) && net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) As a matter of fact, enough of these places were changed to make passt+vhostuser work. However I missed a few places that resulted in the passt process not being properly shutdown/cleaned up when the interface type was vhostuser, and also as far as I can see from examining the code, the passt process wasn't being added to the cgroup for the domain. We could fix these problems by adding the extra condition to all the missing places (checking for either 'user' or 'vhostuser' as well as for backend type of 'passt'), but since validation already guarantees that if backend type=3D'passt' then the interface type MUST be either 'user' or 'vhostuser', it's really just adding extra code for no good purpose (and would leave open the possibility of the same problem recurring in the future if a different interface type begins using passt as well). So the better solution is to not bother checking net->type at all in those locations - if backend type is 'passt' then we call the passt-related code. Resolves: https://issues.redhat.com/browse/RHEL-80285 Resolves: https://issues.redhat.com/browse/RHEL-92842 Fixes: 1e9054b9c79d721a55f413c2983c5370044f8f60 Signed-off-by: Laine Stump Reviewed-by: Martin Kletzander --- src/qemu/qemu_extdevice.c | 15 +++------------ src/qemu/qemu_hotplug.c | 23 ++++++++--------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 8df93a77ce..28cea52980 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -213,11 +213,6 @@ qemuExtDevicesStart(virQEMUDriver *driver, for (i =3D 0; i < def->nnets; i++) { virDomainNetDef *net =3D def->nets[i]; =20 - if (net->type !=3D VIR_DOMAIN_NET_TYPE_USER && - net->type !=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { - continue; - } - if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { if (qemuPasstStart(vm, net) < 0) return -1; @@ -310,10 +305,8 @@ qemuExtDevicesStop(virQEMUDriver *driver, if (slirp) qemuSlirpStop(slirp, vm, driver, net); =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) qemuPasstStop(vm, net); - } =20 if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && net->downscr= ipt) virNetDevRunEthernetScript(net->ifname, net->downscript); @@ -373,8 +366,7 @@ qemuExtDevicesHasDevice(virDomainDef *def) if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) return true; =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) return true; } =20 @@ -455,8 +447,7 @@ qemuExtDevicesSetupCgroup(virQEMUDriver *driver, if (slirp && qemuSlirpSetupCgroup(slirp, cgroup) < 0) return -1; =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST && + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST && qemuPasstSetupCgroup(vm, net, cgroup) < 0) { return -1; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e9568af125..866dbace90 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1298,8 +1298,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, =20 qemuPasstPrepareVhostUser(vm, net); =20 - if (qemuPasstStart(vm, net) < 0) - goto cleanup; } else { if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser= ->data.nix.path, net->data.vhostuser= ->data.nix.listen, @@ -1313,13 +1311,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, break; =20 case VIR_DOMAIN_NET_TYPE_USER: - if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { - - if (qemuPasstStart(vm, net) < 0) - goto cleanup; - - } else if (!priv->disableSlirp && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE))= { + if (!priv->disableSlirp && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { =20 if (qemuInterfacePrepareSlirp(driver, net) < 0) goto cleanup; @@ -1356,6 +1349,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, goto cleanup; } =20 + /* both NET_TYPE_USER and NET_TYPE_VHOSTUSER might use passt */ + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST && qemuPasst= Start(vm, net) < 0) + goto cleanup; + /* Set device online immediately */ if (virDomainInterfaceStartDevice(net) < 0) goto cleanup; @@ -1539,10 +1536,8 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver,= net); =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) qemuPasstStop(vm, net); - } =20 qemuDomainObjEnterMonitor(vm); if (charDevPlugged && @@ -5112,10 +5107,8 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver,= net); =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) qemuPasstStop(vm, net); - } =20 virDomainAuditNet(vm, net, NULL, "detach", true); =20 --=20 2.51.0