From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739596895764710.7499432101782; Fri, 14 Feb 2025 21:21:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A7CD51C69; Sat, 15 Feb 2025 00:21:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A73F31CEC; Sat, 15 Feb 2025 00:20:28 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0EEF01B27; Sat, 15 Feb 2025 00:20:23 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6E2641BE0 for ; Sat, 15 Feb 2025 00:20:22 -0500 (EST) Received: from mx-prod-mc-05.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-473-cOiDkXB3Py2BzoctCrWAug-1; Sat, 15 Feb 2025 00:20:20 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A17E119560B5 for ; Sat, 15 Feb 2025 05:20:19 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 107DC180087D; Sat, 15 Feb 2025 05:20:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596822; 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=nhkSulclojc/+GIFHDhkAbz5ZU4GwVhFeBfMtABlwcQ=; b=FKFs7MvWdrc3nn5h24TNhsaITjkSkEL977ksdt22ABN31h/dnNaTfLObt17x/t2rTBFt1H jTiyk/3swrJfH0HHsKYo4lc15/nUkLhgfRbHHQIBYY36dWbobgBnZkdAzQYoUCUWJEkILX +IeaZhD8YZgd0b3ED0dmWUdV8SW+aYg= X-MC-Unique: cOiDkXB3Py2BzoctCrWAug-1 X-Mimecast-MFC-AGG-ID: cOiDkXB3Py2BzoctCrWAug_1739596819 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 01/12] conf: change virDomainHostdevInsert() to return void Date: Sat, 15 Feb 2025 00:20:06 -0500 Message-ID: <20250215052017.1241417-2-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tzWiXlYyzphP1dgAYlzeQuLHgfh8P1q-kDmLF_M6b54_1739596819 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5CAATREBZNDZCX6HKLNVV66DV5BQFU4Z X-Message-ID-Hash: 5CAATREBZNDZCX6HKLNVV66DV5BQFU4Z X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739596896986019100 Content-Type: text/plain; charset="utf-8"; x-default="true" We haven't checked for memalloc failure in many years, and that was the only reason this function would have ever failed. Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 15 +++++---------- src/conf/domain_conf.h | 2 +- src/libxl/libxl_domain.c | 5 +---- src/libxl/libxl_driver.c | 3 +-- src/lxc/lxc_driver.c | 3 +-- src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_process.c | 3 +-- 7 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 87f87bbe56..50dc4a33a6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14465,12 +14465,10 @@ virDomainChrTargetTypeToString(int deviceType, return type; } =20 -int +void virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev) { VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); - - return 0; } =20 virDomainHostdevDef * @@ -14886,9 +14884,8 @@ virDomainDiskRemoveByName(virDomainDef *def, const = char *name) int virDomainNetInsert(virDomainDef *def, virDomainNetDef *net) { /* hostdev net devices must also exist in the hostdevs array */ - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) - return -1; + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) + virDomainHostdevInsert(def, &net->data.hostdev.def); =20 VIR_APPEND_ELEMENT(def->nets, def->nnets, net); return 0; @@ -19281,10 +19278,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt, * where the actual network type is already known to be * hostdev) must also be in the hostdevs array. */ - if (virDomainNetGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_HOST= DEV && - virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net))= < 0) { - return NULL; - } + if (virDomainNetGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_HOST= DEV) + virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)); } VIR_FREE(nodes); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e51c74b6d1..9da6586e66 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3994,7 +3994,7 @@ virDomainNetDef *virDomainNetRemove(virDomainDef *def= , size_t i); virDomainNetDef *virDomainNetRemoveByObj(virDomainDef *def, virDomainNetDe= f *net); void virDomainNetRemoveHostdev(virDomainDef *def, virDomainNetDef *net); =20 -int virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev= ); +void virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostde= v); virDomainHostdevDef * virDomainHostdevRemove(virDomainDef *def, size_t i); int virDomainHostdevFind(virDomainDef *def, virDomainHostdevDef *match, diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index a049cdb30f..6805160923 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1014,10 +1014,7 @@ libxlNetworkPrepareDevices(virDomainDef *def) /* Each type=3D'hostdev' network device must also have a * corresponding entry in the hostdevs array. */ - virDomainHostdevDef *hostdev =3D virDomainNetGetActualHostdev(= net); - - if (virDomainHostdevInsert(def, hostdev) < 0) - return -1; + virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)); } } =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index bd858d8127..edf7b37581 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3574,8 +3574,7 @@ libxlDomainAttachDeviceConfig(virDomainDef *vmdef, vi= rDomainDeviceDef *dev) return -1; } =20 - if (virDomainHostdevInsert(vmdef, hostdev) < 0) - return -1; + virDomainHostdevInsert(vmdef, hostdev); dev->data.hostdev =3D NULL; break; =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index e63732dbea..22266c1ab6 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2993,8 +2993,7 @@ lxcDomainAttachDeviceConfig(virDomainDef *vmdef, _("device is already in the domain configuratio= n")); return -1; } - if (virDomainHostdevInsert(vmdef, hostdev) < 0) - return -1; + virDomainHostdevInsert(vmdef, hostdev); dev->data.hostdev =3D NULL; ret =3D 0; break; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 772cb405d6..1d0da1028f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6732,8 +6732,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, _("device is already in the domain configuratio= n")); return -1; } - if (virDomainHostdevInsert(vmdef, hostdev)) - return -1; + virDomainHostdevInsert(vmdef, hostdev); dev->data.hostdev =3D NULL; break; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d015285b0d..910229a616 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5928,8 +5928,7 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm) if (qemuDomainPrepareHostdev(hostdev, priv) < 0) return -1; =20 - if (virDomainHostdevInsert(def, hostdev) < 0) - return -1; + virDomainHostdevInsert(def, hostdev); } } return 0; --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739597011087523.2807872555688; Fri, 14 Feb 2025 21:23:31 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6BDFD15A4; Sat, 15 Feb 2025 00:23:30 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E9CF91C34; Sat, 15 Feb 2025 00:20:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1B3441CA5; Sat, 15 Feb 2025 00:20:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 42ABC1C2B for ; Sat, 15 Feb 2025 00:20:27 -0500 (EST) 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-665-Rzuf2WeoPAqtIY21Rj9-HA-1; Sat, 15 Feb 2025 00:20:24 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 7B38B1955F28 for ; Sat, 15 Feb 2025 05:20:20 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DFC16180087D; Sat, 15 Feb 2025 05:20:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596826; 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=V8U7ybZc7Gqr4s2AM+bFjZfIPImHcI+/B3fZdh4fLpA=; b=JFxKtdqT/CoLo5hdl9SIWRZRdyC1cs+mWhJ+jdgfMS9wlU+TGR+kDD7xacAHTzzbk3RMA4 cSspW9WEzs31rdgcYKU02jCiS6NyM9CVB1t9NscWYCYvdGakdEyot0Qi1/lVC3EwRMaAn5 PkawfeRdO3UiSeGijQObyH92AlaFDIw= X-MC-Unique: Rzuf2WeoPAqtIY21Rj9-HA-1 X-Mimecast-MFC-AGG-ID: Rzuf2WeoPAqtIY21Rj9-HA_1739596820 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 02/12] qemu: fix qemu validation to forbid guest-side IP address for type='vdpa' Date: Sat, 15 Feb 2025 00:20:07 -0500 Message-ID: <20250215052017.1241417-3-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 0PiXQFjAq3GsYOweaihf9G4R3CdAgQttqG2S6MATgCM_1739596820 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EMYIJOXHLD7FWNXIKIS5SYNALMHWFKVK X-Message-ID-Hash: EMYIJOXHLD7FWNXIKIS5SYNALMHWFKVK X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739597011987019000 Content-Type: text/plain; charset="utf-8"; x-default="true" Because all the checks for VIR_DOMAIN_NET_TYPE_VDPA were inside an else-if clause that was immediately followed by another else-if clause that forbid setting guestIP.ips or guestIP.routes, we've been allowing users to set guestIP.* for vdpa interfaces (but then not doing validation of the attributes that should have been done if we *did* support setting IPs for vdpa (but we don't anyway, so :shrug:.) This can be fixed by turning the vdpa else-if clause into a top-level if - this way vdpa interfaces will hit the "else if (net->guestIP.nips)" clause and reject guest-side IP address setting. Also, since there are currently *no* interface types for QEMU that support adding guest-side routes, we put that check by itself (I think it may be possible to set some guest routes for passt interfaces, but we don't do that) Signed-off-by: Laine Stump --- src/qemu/qemu_validate.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 76f2eafe49..06093bc42b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1745,6 +1745,12 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNe= tDef *net, bool hasIPv6 =3D false; size_t i; =20 + if (net->guestIP.nroutes) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid attempt to set network interface guest-s= ide IP route, not supported by QEMU")); + return -1; + } + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER) { virDomainCapsDeviceNet netCaps =3D { }; =20 @@ -1758,12 +1764,6 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNe= tDef *net, return -1; } =20 - if (net->guestIP.nroutes) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Invalid attempt to set network interface gue= st-side IP route, not supported by QEMU")); - return -1; - } - for (i =3D 0; i < net->guestIP.nips; i++) { const virNetDevIPAddr *ip =3D net->guestIP.ips[i]; =20 @@ -1811,7 +1811,13 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNe= tDef *net, } } } - } else if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) { + } else if (net->guestIP.nips) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid attempt to set network interface guest-s= ide IP address info, not supported by QEMU")); + return -1; + } + + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_VHOST_VDPA)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vDPA devices are not supported with this QEM= U binary")); @@ -1825,10 +1831,6 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNe= tDef *net, virDomainNetModelTypeToString(net->model)); return -1; } - } else if (net->guestIP.nroutes || net->guestIP.nips) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Invalid attempt to set network interface guest-s= ide IP route and/or address info, not supported by QEMU")); - return -1; } =20 if (virDomainNetIsVirtioModel(net)) { --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739596923850775.2542262162074; Fri, 14 Feb 2025 21:22:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3FCA41268; Sat, 15 Feb 2025 00:22:03 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 16BCB1D65; Sat, 15 Feb 2025 00:20:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 721CB1BE6; Sat, 15 Feb 2025 00:20:24 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F06EA1555 for ; Sat, 15 Feb 2025 00:20:23 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-jrxylfb_MQOHbTmXSB4RaQ-1; Sat, 15 Feb 2025 00:20:22 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 74D471800374 for ; Sat, 15 Feb 2025 05:20:21 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BAA1A180087D; Sat, 15 Feb 2025 05:20:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596823; 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=YADdZp0RXhDSr8DAic1nCEtTddyEWmA2opyFRDGNGI4=; b=VVXMu/i4GzYJafUBeuVoVf+JqjNCi7voS8/lJ0aOj09NWZYtTQj/HMwjyZK91zh+LPiOhu 7F8fr3kZEx5RNSK4/ZlGW4HmIBxbRj4+tMptSMKAz0zSHGc010Fvvjkz6PCjHO2lQkPtBC NUQhfattat3kcohY1tD0hFhD6AmdayU= X-MC-Unique: jrxylfb_MQOHbTmXSB4RaQ-1 X-Mimecast-MFC-AGG-ID: jrxylfb_MQOHbTmXSB4RaQ_1739596821 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 03/12] qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same place Date: Sat, 15 Feb 2025 00:20:08 -0500 Message-ID: <20250215052017.1241417-4-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zLT2KPgm-yQ4WdlHiTPj3Q2NePULlojtOBGaqCJDHVg_1739596821 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 45F3LEVVLOWD4RLN4JWWFYFCAUSNAKHQ X-Message-ID-Hash: 45F3LEVVLOWD4RLN4JWWFYFCAUSNAKHQ X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739596925760019000 Content-Type: text/plain; charset="utf-8"; x-default="true" Both vhostuser and vdpa interface types must use the virtio model in the guest (because part of the functionality is implemented in the guest virtio driver). Due to ["because that's the way it happened"] this has been validated for vhostuser in the hypervisor-agnostic validate function, but for vdpa it has been done in the QEMU-specific validate. Since these interface models are only supported by QEMU anyway, validate for both of them in the QEMU validation function. Take advantage of this change to switch to using virDomainNetIsVirtioModel(net) instead of "net->model =3D=3D VIR_DOMAIN_NET_MODEL_VIRTIO" (the former also matches ...VIRTIO_TRANSITIONAL and ...VIRTIO_NON_TRANSITIONAL, so is more correct). Signed-off-by: Laine Stump --- src/conf/domain_validate.c | 6 ------ src/qemu/qemu_validate.c | 11 ++++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index eb5e764c02..d0e2bcaccf 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2186,12 +2186,6 @@ virDomainNetDefValidate(const virDomainNetDef *net) =20 switch (net->type) { case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (!virDomainNetIsVirtioModel(net)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Wrong or no 'type' attribute specifi= ed with . vhostuser requires the virtio-net*= frontend")); - return -1; - } - if (net->data.vhostuser->data.nix.listen && net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 06093bc42b..243c499a33 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1823,17 +1823,18 @@ qemuValidateDomainDeviceDefNetwork(const virDomainN= etDef *net, _("vDPA devices are not supported with this QEM= U binary")); return -1; } + } =20 - if (net->model !=3D VIR_DOMAIN_NET_MODEL_VIRTIO) { + if (!virDomainNetIsVirtioModel(net)) { + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA || + net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid model for interface of type '%1$s': = '%2$s'"), + _("invalid model for interface of type '%1$s': = '%2$s' - must be 'virtio'"), virDomainNetTypeToString(net->type), virDomainNetModelTypeToString(net->model)); return -1; } - } - - if (virDomainNetIsVirtioModel(net)) { + } else { if (net->driver.virtio.rx_queue_size) { if (!VIR_IS_POW2(net->driver.virtio.rx_queue_size)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 173959696261219.58790728682095; Fri, 14 Feb 2025 21:22:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 89BAD15AA; Sat, 15 Feb 2025 00:22:41 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D0E601C56; Sat, 15 Feb 2025 00:20:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id F19C11BE0; Sat, 15 Feb 2025 00:20:25 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7D4D51555 for ; Sat, 15 Feb 2025 00:20:25 -0500 (EST) 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-434-Q2woHiUtMAGrAs5sjDtF0A-1; Sat, 15 Feb 2025 00:20:23 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 3DF7B19373D8 for ; Sat, 15 Feb 2025 05:20:22 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97436180087D; Sat, 15 Feb 2025 05:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596825; 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=5IDOA2r5Wy3JibKXLwzpJeGtkz1gudse+t7rSSJ1zcE=; b=Jn2Z2XdbSzcyF57P4a4sx+RJVSqaoHaQAUZQmKeQSps6Aeum1y0TSHu7NppTwgkraOIICP Smm56IDDJp8ko3HRJpy9gG/tegmAfKzS6khpjSUW17lufJWDe15gcG+bqB7bRFvlqYuiNO CVItLNrFkg0A7s7r6lE6Iap3cZNO8/w= X-MC-Unique: Q2woHiUtMAGrAs5sjDtF0A-1 X-Mimecast-MFC-AGG-ID: Q2woHiUtMAGrAs5sjDtF0A_1739596822 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 04/12] qemu: automatically set model type='virtio' for interface type='vhostuser' Date: Sat, 15 Feb 2025 00:20:09 -0500 Message-ID: <20250215052017.1241417-5-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9L___Hv4ZvwLACeDajbONHoQmVpyuXsi8zsXAPUvl-M_1739596822 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: K4ZDXPGUUMLDBG3C7LG5VE7LI427OYNK X-Message-ID-Hash: K4ZDXPGUUMLDBG3C7LG5VE7LI427OYNK X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739596964834019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Both vdpa and vhostuser require that the guest device be virtio, and for interface type=3D'vdpa', we already set if it is unspecified in the input XML, so let's be just as courteous for interface type=3D'vhostuser'. Signed-off-by: Laine Stump --- src/qemu/qemu_postparse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_postparse.c b/src/qemu/qemu_postparse.c index 20ee333e0d..49009ae2e4 100644 --- a/src/qemu/qemu_postparse.c +++ b/src/qemu/qemu_postparse.c @@ -100,7 +100,8 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDef *net, const virDomainDef *def, virQEMUCaps *qemuCaps) { - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA && + if ((net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA || + net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) && !virDomainNetGetModelString(net)) { net->model =3D VIR_DOMAIN_NET_MODEL_VIRTIO; } else if (net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739596945497366.1555630142228; Fri, 14 Feb 2025 21:22:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 53D771C8E; Sat, 15 Feb 2025 00:22:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0E37C1D69; Sat, 15 Feb 2025 00:20:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id F30C11555; Sat, 15 Feb 2025 00:20:25 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 88A271BE0 for ; Sat, 15 Feb 2025 00:20:25 -0500 (EST) 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-629-RzuR2MIdPj2HjU9Lw29-rg-1; Sat, 15 Feb 2025 00:20:23 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 2402C19560BC for ; Sat, 15 Feb 2025 05:20:23 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 85D601800940; Sat, 15 Feb 2025 05:20:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596825; 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=X5qdVSVBa0jMCfQoJWkZdg6bEWv/+wqtCOp7qrnE25Q=; b=f+CvhUuITraHzKncQdoMwQqW4Vq0aE8JRaUxAuD9Iq6Pc0iMLQejjBYi0evLqHfN+SxtJ6 QMStREhm8oadi8Svzr+iqGvqVtXmsLG9TwyU+dMS+vokpwq0ju3XO0dCGg91HMzGF/XD+W VPlv4i+v30Rcqao0X1Xr6XGA33IOSs4= X-MC-Unique: RzuR2MIdPj2HjU9Lw29-rg-1 X-Mimecast-MFC-AGG-ID: RzuR2MIdPj2HjU9Lw29-rg_1739596823 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 05/12] qemu: do all vhostuser attribute validation in qemu driver Date: Sat, 15 Feb 2025 00:20:10 -0500 Message-ID: <20250215052017.1241417-6-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DGi1phpodoDP0cbuxy1sePZGTCHyldc6o7_GyN1BF3g_1739596823 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JFH2RWQCGYXI4J33U3OSQP7YMKHDMOLS X-Message-ID-Hash: JFH2RWQCGYXI4J33U3OSQP7YMKHDMOLS X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739596946923019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Since vhostuser is only used/supported by the QEMU driver, and all the rest of the vhostuser-specific validation is done in QEMU's validation, lets move the final check (to see if they've tried to enable auto-reconnect when this interface is on the server side of the vhostuser socket) to the QEMU validate. Signed-off-by: Laine Stump --- src/conf/domain_validate.c | 10 +--------- src/qemu/qemu_validate.c | 8 ++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index d0e2bcaccf..577dbab0af 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2185,15 +2185,6 @@ virDomainNetDefValidate(const virDomainNetDef *net) } =20 switch (net->type) { - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (net->data.vhostuser->data.nix.listen && - net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'reconnect' attribute unsupported 'server' m= ode for ")); - return -1; - } - break; - case VIR_DOMAIN_NET_TYPE_USER: if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { size_t p; @@ -2217,6 +2208,7 @@ virDomainNetDefValidate(const virDomainNetDef *net) } break; =20 + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_VDPA: case VIR_DOMAIN_NET_TYPE_BRIDGE: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 243c499a33..351fe38830 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1825,6 +1825,14 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNe= tDef *net, } } =20 + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER && + net->data.vhostuser->data.nix.listen && + net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRISTAT= E_BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute is not supported when sour= ce mode=3D'server' for ")); + return -1; + } + if (!virDomainNetIsVirtioModel(net)) { if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA || net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739596987290251.98356640808095; Fri, 14 Feb 2025 21:23:07 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B0B061E5D; Sat, 15 Feb 2025 00:23:06 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ABB091D70; Sat, 15 Feb 2025 00:20:37 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0FC6A1C03; Sat, 15 Feb 2025 00:20:29 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E28C41BFF for ; Sat, 15 Feb 2025 00:20:26 -0500 (EST) Received: from mx-prod-mc-04.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-494-v4hzM6bwNoGu2F5ypjtydw-1; Sat, 15 Feb 2025 00:20:24 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0173619039C5 for ; Sat, 15 Feb 2025 05:20:24 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 62C901800352; Sat, 15 Feb 2025 05:20:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596826; 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=Ld32ExPDw4FFm9e+ax/UzTVnAy0SWuo8zgJrE6VfQS8=; b=buQj/Fqt+ce6ZeKIEsBVPp5yhgYo2VMg9A7qDAd+/LNIxCkkZxI1iqYhSmMusk6kEtB6M5 jwV6DNGcA0RFRKTo6M7t/1aHi5SS6nzva+62T+TdIDB921y8gMKkANIXEGychdqYcYnHTq QSKqhmqfR+6ja5u4Bg9kAtx/CvSDSYc= X-MC-Unique: v4hzM6bwNoGu2F5ypjtydw-1 X-Mimecast-MFC-AGG-ID: v4hzM6bwNoGu2F5ypjtydw_1739596824 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 06/12] conf/qemu: make element *almost* optional for type=vhostuser Date: Sat, 15 Feb 2025 00:20:11 -0500 Message-ID: <20250215052017.1241417-7-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: XQtHsttgzkuFJq2S54X7S5E3GCnJxo74_UquTiEa82A_1739596824 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SD5ZZZI7AR7GCKFANLYTTYBSKH5GVDSU X-Message-ID-Hash: SD5ZZZI7AR7GCKFANLYTTYBSKH5GVDSU X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739596988020019000 Content-Type: text/plain; charset="utf-8"; x-default="true" For some reason, when vhostuser interface support was added in 2014, the parser required that the XML for the have a element with type, mode, and path, all 3 also required. This in spite of the fact that 'unix' is the only possible valid setting for type, and 95% of the time the mode is set to 'client' (as I understand from comments in the code, normally a guest will use mode=3D'client' to connect to an existing socket that is precreated (by OVS?), and the only use for mode=3D'server' is for test setups where one guest is setup with a listening vhostuser socket (i.e. 'server') and another guest connects to that socket (i.e. 'client')). (or maybe one guest connects to OVS in server mode, and all the others connect in client mode, not sure - I don't claim to be an expert on vhost-user.) So from the point of view of existing vhost-user functionality, it seems reasonable to make 'type' and 'mode' optional, and by default fill in the vhostuser part of the NetDef as if they were 'unix' and 'client'. In theory, the element itself is also not *directly* required after this patch, however, the path attribute of *is* required (for now), so effectively the element is still required. Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 56 ++++++++++++------------------- src/conf/schemas/domaincommon.rng | 4 ++- src/qemu/qemu_validate.c | 20 +++++++---- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 50dc4a33a6..6b382eb63f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9776,50 +9776,38 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_type =3D NULL; virDomainNetVhostuserMode vhostuser_mode; =20 - if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) - return NULL; - - if (!(vhostuser_type =3D virXMLPropStringRequired(source_node, "ty= pe"))) - return NULL; - - if (STRNEQ_NULLABLE(vhostuser_type, "unix")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Type=3D'%1$s' unsupported for "), - vhostuser_type); - return NULL; - } - if (!(def->data.vhostuser =3D virDomainChrSourceDefNew(xmlopt))) return NULL; =20 + /* Default (and only valid) value of type is "unix". + * Everything else's default value is 0/NULL. + */ def->data.vhostuser->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; =20 - if (!(def->data.vhostuser->data.nix.path =3D virXMLPropStringRequi= red(source_node, "path"))) - return NULL; + if (source_node) { + if ((vhostuser_type =3D virXMLPropString(source_node, "type"))= ) { + if (STRNEQ(vhostuser_type, "unix")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Type=3D'%1$s' unsupported for "), + vhostuser_type); + return NULL; + } + } =20 - if (virXMLPropEnum(source_node, "mode", - virDomainNetVhostuserModeTypeFromString, - VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, - &vhostuser_mode) < 0) - return NULL; + def->data.vhostuser->data.nix.path =3D virXMLPropString(source= _node, "path"); =20 - switch (vhostuser_mode) { - case VIR_DOMAIN_NET_VHOSTUSER_MODE_CLIENT: - def->data.vhostuser->data.nix.listen =3D false; - break; + if (virXMLPropEnum(source_node, "mode", virDomainNetVhostuserM= odeTypeFromString, + VIR_XML_PROP_NONZERO, &vhostuser_mode) < 0)= { + return NULL; + } =20 - case VIR_DOMAIN_NET_VHOSTUSER_MODE_SERVER: - def->data.vhostuser->data.nix.listen =3D true; - break; + if (vhostuser_mode =3D=3D VIR_DOMAIN_NET_VHOSTUSER_MODE_SERVER) + def->data.vhostuser->data.nix.listen =3D true; =20 - case VIR_DOMAIN_NET_VHOSTUSER_MODE_NONE: - case VIR_DOMAIN_NET_VHOSTUSER_MODE_LAST: - break; + if (virDomainChrSourceReconnectDefParseXML(&def->data.vhostuse= r->data.nix.reconnect, + source_node, ctxt) = < 0) + return NULL; } - - if (virDomainChrSourceReconnectDefParseXML(&def->data.vhostuser->d= ata.nix.reconnect, - source_node, ctxt) < 0) - return NULL; } break; =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 96cedb85e8..e5da550e45 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3485,7 +3485,9 @@ vhostuser - + + + diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 351fe38830..b0cf5e866c 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1825,12 +1825,20 @@ qemuValidateDomainDeviceDefNetwork(const virDomainN= etDef *net, } } =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER && - net->data.vhostuser->data.nix.listen && - net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRISTAT= E_BOOL_YES) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'reconnect' attribute is not supported when sour= ce mode=3D'server' for ")); - return -1; + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { + if (!net->data.vhostuser->data.nix.path) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing required attribute '%1$s' in element= '%2$s'"), + "path", "source"); + return -1; + } + + if (net->data.vhostuser->data.nix.listen && + net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute is not supported when = source mode=3D'server' for ")); + return -1; + } } =20 if (!virDomainNetIsVirtioModel(net)) { --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739597041467616.3162760685049; Fri, 14 Feb 2025 21:24:01 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D4DD91C17; Sat, 15 Feb 2025 00:24:00 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 772B81DCA; Sat, 15 Feb 2025 00:20:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6E3501D21; Sat, 15 Feb 2025 00:20:38 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4CC7C1C34 for ; Sat, 15 Feb 2025 00:20:27 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-wuXoy2hmNXGVguxnnQDNOA-1; Sat, 15 Feb 2025 00:20:25 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D8BEC1800374 for ; Sat, 15 Feb 2025 05:20:24 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4A76E180087D; Sat, 15 Feb 2025 05:20:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596827; 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=NfuTjIiosru5WoBJSFw4bGIeRacgPQ5SiLw5kdoqysI=; b=G8hmuDdTt0xPXoNEDg3Aw0wl1a+4uDfwLofM/xZxzftRPTh3r14CVyTPgzv2OHzEHyvDmm L7U8nuamCz/MPj7/S5bU7ic/Np2UD62tD64RJL4vYS2+IojZYRSQlgx3lpLOcwPpzN9Ek0 M/LBxaoKLwrfkB+XNSDi0GNJ0T7kpdY= X-MC-Unique: wuXoy2hmNXGVguxnnQDNOA-1 X-Mimecast-MFC-AGG-ID: wuXoy2hmNXGVguxnnQDNOA_1739596825 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 07/12] qemu: use switch instead of if in qemuProcessPrepareDomainNetwork() Date: Sat, 15 Feb 2025 00:20:12 -0500 Message-ID: <20250215052017.1241417-8-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: fhbqqbkbtje9fvUezdcurUkt2B35U328yrkz_Oyqvy8_1739596825 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: D2CIEC3IINOBSXINZBUJK2A6TSGHHUA5 X-Message-ID-Hash: D2CIEC3IINOBSXINZBUJK2A6TSGHHUA5 X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739597042085019000 Content-Type: text/plain; charset="utf-8"; x-default="true" qemuProcessPrepareDomain()'s comments say that it should be the only place to change the "live XML" of a domain (i.e. the public parts of the virDomainDef object that is shown in the domain's status XML), and that seems like a reasonable idea (although there aren't many users of it to date). qemuProcessPrepareDomainNetwork() is called by the aforementioned qemuProcessPrepareDomain() - this patch changes the "if (type =3D=3D HOSTDEV)" in that function to a "switch(type)" so it's simpler to add DomainDef modifications for various other types of virDomainNetDef, and also so that anyone who adds a new interface type is forced to look at the code and decide if anything needs to be done here for the new type. Signed-off-by: Laine Stump --- src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 910229a616..963d090963 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5887,7 +5887,6 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm) =20 for (i =3D 0; i < def->nnets; i++) { virDomainNetDef *net =3D def->nets[i]; - virDomainNetType actualType; =20 /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name @@ -5900,36 +5899,56 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm) return -1; } =20 - actualType =3D virDomainNetGetActualType(net); - if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - /* Each type=3D'hostdev' network device must also have a - * corresponding entry in the hostdevs array. For netdevs - * that are hardcoded as type=3D'hostdev', this is already - * done by the parser, but for those allocated from a - * network / determined at runtime, we need to do it - * separately. - */ - virDomainHostdevDef *hostdev =3D virDomainNetGetActualHostdev(= net); - virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.subsys.= u.pci; - - if (virDomainHostdevFind(def, hostdev, NULL) >=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("PCI device %1$04x:%2$02x:%3$02x.%4$x all= ocated from network %5$s is already in use by domain %6$s"), - pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function, - net->data.network.name, def->name); - return -1; - } + switch (virDomainNetGetActualType(net)) { + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { + /* Each type=3D'hostdev' network device must also have a + * corresponding entry in the hostdevs array. For netdevs + * that are hardcoded as type=3D'hostdev', this is already + * done by the parser, but for those allocated from a + * network / determined at runtime, we need to do it + * separately. + */ + virDomainHostdevDef *hostdev =3D virDomainNetGetActualHost= dev(net); + virDomainHostdevSubsysPCI *pcisrc =3D &hostdev->source.sub= sys.u.pci; + + if (virDomainHostdevFind(def, hostdev, NULL) >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("PCI device %1$04x:%2$02x:%3$02x.%4$x= allocated from network %5$s is already in use by domain %6$s"), + pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.functio= n, + net->data.network.name, def->name); + return -1; + } =20 - /* For hostdev present in qemuProcessPrepareDomain() phase thi= s was - * done already, but this code runs after that, so we have to = call - * it ourselves. */ - if (qemuDomainPrepareHostdev(hostdev, priv) < 0) - return -1; + /* For hostdev present in qemuProcessPrepareDomain() phase= this was + * done already, but this code runs after that, so we have= to call + * it ourselves. */ + if (qemuDomainPrepareHostdev(hostdev, priv) < 0) + return -1; =20 - virDomainHostdevInsert(def, hostdev); + virDomainHostdevInsert(def, hostdev); + } + break; + + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_BRIDGE: + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_NULL: + case VIR_DOMAIN_NET_TYPE_VDS: + case VIR_DOMAIN_NET_TYPE_LAST: + break; } + } return 0; } --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739597058711427.63403698812033; Fri, 14 Feb 2025 21:24:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id AA71D1CE1; Sat, 15 Feb 2025 00:24:17 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4E3241DEA; Sat, 15 Feb 2025 00:20:46 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 701311C3F; Sat, 15 Feb 2025 00:20:39 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6057C1CD1 for ; Sat, 15 Feb 2025 00:20:28 -0500 (EST) Received: from mx-prod-mc-01.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-546-lY1wAnsNPJ2mygZTO0HzBw-1; Sat, 15 Feb 2025 00:20:26 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 07D6219373DC for ; Sat, 15 Feb 2025 05:20:26 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 25D0F1800352; Sat, 15 Feb 2025 05:20:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596828; 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=cknBXuFJUcnNVtMRbWODWkbI40lR18P3ElYl0I22ONE=; b=P+sJw0Id/0DCYz0dvOo1HyRrJjzRCTwR7qvFKV6RM87ajcKay55LydY3i9ElK2wKV+zL+q z+qYQOYoDDBxU/5XSFYLOy8TKZglbRnnOtcweozzf3dZkJSy7cFvCVaPThC/8E1M7B3Y9C VDw0F/1RZt5WhRY3i2alRRKLnUCjaIk= X-MC-Unique: lY1wAnsNPJ2mygZTO0HzBw-1 X-Mimecast-MFC-AGG-ID: lY1wAnsNPJ2mygZTO0HzBw_1739596826 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 08/12] qemu: make qemuPasstCreateSocketPath() public Date: Sat, 15 Feb 2025 00:20:13 -0500 Message-ID: <20250215052017.1241417-9-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: xzsmqpgmXZzkAVWCffcyhGeRsHJCY-FWWnwYRQlebQE_1739596826 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: N4N3XTKNLRQNLEEPRXM5OFTJMP5U4RXP X-Message-ID-Hash: N4N3XTKNLRQNLEEPRXM5OFTJMP5U4RXP X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739597061117019100 Content-Type: text/plain; charset="utf-8"; x-default="true" When passt is used with vhostuser, the vhostuser code that builds the qemu commandline will need to have the same socket path that is given to the passt command, so this patch makes it visible outside of qemu_passt.c. Signed-off-by: Laine Stump --- src/qemu/qemu_passt.c | 2 +- src/qemu/qemu_passt.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index dd4a8bb997..8a3ac4e988 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -54,7 +54,7 @@ qemuPasstCreatePidFilename(virDomainObj *vm, } =20 =20 -static char * +char * qemuPasstCreateSocketPath(virDomainObj *vm, virDomainNetDef *net) { diff --git a/src/qemu/qemu_passt.h b/src/qemu/qemu_passt.h index 623b494b7a..e0b9aaac8d 100644 --- a/src/qemu/qemu_passt.h +++ b/src/qemu/qemu_passt.h @@ -36,3 +36,6 @@ void qemuPasstStop(virDomainObj *vm, int qemuPasstSetupCgroup(virDomainObj *vm, virDomainNetDef *net, virCgroup *cgroup); + +char *qemuPasstCreateSocketPath(virDomainObj *vm, + virDomainNetDef *net); --=20 2.47.1 From nobody Fri Dec 19 04:32:25 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739597151877894.7932673808991; Fri, 14 Feb 2025 21:25:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4E0141F06; Sat, 15 Feb 2025 00:25:51 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CE9101E4E; Sat, 15 Feb 2025 00:20:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 32DB11CFE; Sat, 15 Feb 2025 00:20:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E26931D48 for ; Sat, 15 Feb 2025 00:20:29 -0500 (EST) 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-683-oE7sAxhXNH6RLaaecO5iXQ-1; Sat, 15 Feb 2025 00:20:27 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 DCECC19373D8 for ; Sat, 15 Feb 2025 05:20:26 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 09CDC1800352; Sat, 15 Feb 2025 05:20:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739596829; 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=3jE9qxWLNXB2tIKHrGt8Qy//UXmy9egpavzIYOxIMyo=; b=guBt12xPlv1Io1zLn3TE+n1TkiDJ1GztK8Byco12YxDzOFpXm2Ft6D6XNrM/uCo4bUDSST wEr0toLfZQBd84qaQD82jWrLx7LcjJNMHiczl5TzLXMOa0QYB3tYfyxZmh+Uajoy2m+iVG fgEiNiixcEwugo4zdTrEh9oR6vFfL2U= X-MC-Unique: oE7sAxhXNH6RLaaecO5iXQ-1 X-Mimecast-MFC-AGG-ID: oE7sAxhXNH6RLaaecO5iXQ_1739596827 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 09/12] qemu: complete vhostuser + passt support Date: Sat, 15 Feb 2025 00:20:14 -0500 Message-ID: <20250215052017.1241417-10-laine@redhat.com> In-Reply-To: <20250215052017.1241417-1-laine@redhat.com> References: <20250215052017.1241417-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: KrAMdnF0OQUnKoga9Lf9Sp_xFmOsSNQGSnASGlm9m4o_1739596827 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XCK5LN3DHVSBBW47HBNPSGAWSZICLAX4 X-Message-ID-Hash: XCK5LN3DHVSBBW47HBNPSGAWSZICLAX4 X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739597152694019000 Content-Type: text/plain; charset="utf-8"; x-default="true" needs to run the passt command just as is done for interface type=3D'user', but then add vhostuser bits to the qemu commandline/monitor command. There are some changes to the parsing/validation along with changes to the vhostuser codepath do do the extra stuff for passt. I tried keeping them separated into different patches, but then the unit test failed in a strange way deep down in the bowels of the commandline generation, so this patch both 1) makes the final changes to parsing/formatting and 2) adds passt stuff at appropriate places for vhostuser (as well as making a couple of things *not* happen when the passt backend is chosen). The result is that you can now have: ... Then as long as you also have the following as a subelement of : your passt interfaces will benefit from the greatly improved efficiency of a vhost-user data path, and all without requiring special privileges or capabilities *anywhere* (i.e. it works for unprivileged libvirt (qemu:///session) as well as privileged libvirt). Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 36 ++++++--- src/conf/domain_validate.c | 77 +++++++------------ src/conf/schemas/domaincommon.rng | 32 +++++++- src/qemu/qemu_command.c | 7 +- src/qemu/qemu_extdevice.c | 6 +- src/qemu/qemu_hotplug.c | 21 ++++- src/qemu/qemu_passt.c | 3 + src/qemu/qemu_process.c | 15 +++- src/qemu/qemu_validate.c | 7 +- ...t-user-slirp-portforward.x86_64-latest.err | 2 +- .../net-vhostuser-passt.x86_64-latest.args | 42 ++++++++++ .../net-vhostuser-passt.x86_64-latest.xml | 72 +++++++++++++++++ tests/qemuxmlconfdata/net-vhostuser-passt.xml | 70 +++++++++++++++++ tests/qemuxmlconftest.c | 1 + 14 files changed, 317 insertions(+), 74 deletions(-) create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest= .args create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest= .xml create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6b382eb63f..49555efc56 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9457,9 +9457,25 @@ virDomainNetBackendParseXML(xmlNodePtr node, g_autofree char *tap =3D virXMLPropString(node, "tap"); g_autofree char *vhost =3D virXMLPropString(node, "vhost"); =20 - /* The VIR_DOMAIN_NET_BACKEND_DEFAULT really means 'use hypervisor's - * builtin SLIRP'. It's reported in domain caps and thus we need to ac= cept - * it. Hence VIR_XML_PROP_NONE instead of VIR_XML_PROP_NONZERO. */ + /* In the case of NET_TYPE_USER, backend type can be unspecified + * (i.e. VIR_DOMAIN_NET_BACKEND_DEFAULT) and that means 'use + * hypervisor's builtin SLIRP (or if that isn't available, use + * passt)'. Similarly, it can also be left unspecified in the case + * of NET_TYPE_VHOSTUSER, and then it means "use the traditional + * vhost-user backend (which auto-detects between connecting to a + * socket created by OVS, or connecting to a standalone socket + * used (mostly in testing) to connect the vhost-user interface of + * one guest directly to the vhost-user interface of another + * guest. + * + * If backend type is set to 'passt', then in both cases a passt + * process will be started, and libvirt will connect that to the + * guest interface (either communicating everything over the + * socket created by passt using a specific-to-passt protocol + * (interface type=3D'user'>), or by using the socket for control + * plane messages and shared memory for data using the vhost-user + * protocol ()). + */ if (virXMLPropEnum(node, "type", virDomainNetBackendTypeFromString, VIR_XML_PROP_NONE, &def->backend.type) < 0) { return -1; @@ -24616,7 +24632,11 @@ virDomainNetDefFormat(virBuffer *buf, break; =20 case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (def->data.vhostuser->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX)= { + if (def->data.vhostuser->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX = && + def->backend.type !=3D VIR_DOMAIN_NET_BACKEND_PASST) { + /* in the case of BACKEND_PASST, the values of all of thes= e are either + * fixed (type, mode, reconnect), or derived from elsewher= e (path) + */ virBufferAddLit(&sourceAttrBuf, " type=3D'unix'"); virBufferEscapeString(&sourceAttrBuf, " path=3D'%s'", def->data.vhostuser->data.nix.path); @@ -24627,7 +24647,6 @@ virDomainNetDefFormat(virBuffer *buf, virDomainChrSourceReconnectDefFormat(&sourceChildBuf, &def->data.vhostu= ser->data.nix.reconnect); } - } break; =20 @@ -24689,15 +24708,14 @@ virDomainNetDefFormat(virBuffer *buf, } =20 case VIR_DOMAIN_NET_TYPE_USER: - if (def->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) - virBufferEscapeString(&sourceAttrBuf, " dev=3D'%s'", def->= sourceDev); - break; - case VIR_DOMAIN_NET_TYPE_NULL: case VIR_DOMAIN_NET_TYPE_LAST: break; } =20 + if (def->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) + virBufferEscapeString(&sourceAttrBuf, " dev=3D'%s'", def->sour= ceDev); + if (def->hostIP.nips || def->hostIP.nroutes) { if (virDomainNetIPInfoFormat(&sourceChildBuf, &def->hostIP) < = 0) return -1; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 577dbab0af..563558d920 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2163,67 +2163,46 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } =20 - if (net->type !=3D VIR_DOMAIN_NET_TYPE_USER) { + if (net->type !=3D VIR_DOMAIN_NET_TYPE_USER && + net->type !=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The 'passt' backend can only be used with in= terface type=3D'user'")); + _("The 'passt' backend can only be used with in= terface type=3D'user' or type=3D'vhostuser'")); return -1; } } =20 - if (net->nPortForwards > 0 && - (net->type !=3D VIR_DOMAIN_NET_TYPE_USER || - (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && - net->backend.type !=3D VIR_DOMAIN_NET_BACKEND_PASST))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("The element can only be used with = and its 'passt' backend")); - return -1; - } + if (net->nPortForwards > 0) { + size_t p; =20 - if (!virNetDevBandwidthValidate(net->bandwidth)) { - return -1; - } + if ((net->type !=3D VIR_DOMAIN_NET_TYPE_USER && + net->type !=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) || + net->backend.type !=3D VIR_DOMAIN_NET_BACKEND_PASST) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The element can only be used w= ith the 'passt' backend of interface type=3D'user' or type=3D'vhostuser'")); + return -1; + } =20 - switch (net->type) { - case VIR_DOMAIN_NET_TYPE_USER: - if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { - size_t p; - - for (p =3D 0; p < net->nPortForwards; p++) { - size_t r; - virDomainNetPortForward *pf =3D net->portForwards[p]; - - for (r =3D 0; r < pf->nRanges; r++) { - virDomainNetPortForwardRange *range =3D pf->ranges[r]; - - if (!range->start - && (range->end || range->to - || range->exclude !=3D VIR_TRISTATE_BOOL_ABSEN= T)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("The 'range' of a 'portForward' r= equires 'start' attribute if 'end', 'to', or 'exclude' is specified")); - return -1; - } + for (p =3D 0; p < net->nPortForwards; p++) { + size_t r; + virDomainNetPortForward *pf =3D net->portForwards[p]; + + for (r =3D 0; r < pf->nRanges; r++) { + virDomainNetPortForwardRange *range =3D pf->ranges[r]; + + if (!range->start + && (range->end || range->to + || range->exclude !=3D VIR_TRISTATE_BOOL_ABSENT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The 'range' of a 'portForward' requi= res 'start' attribute if 'end', 'to', or 'exclude' is specified")); + return -1; } } } - break; + } =20 - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - case VIR_DOMAIN_NET_TYPE_NETWORK: - case VIR_DOMAIN_NET_TYPE_VDPA: - case VIR_DOMAIN_NET_TYPE_BRIDGE: - case VIR_DOMAIN_NET_TYPE_CLIENT: - case VIR_DOMAIN_NET_TYPE_SERVER: - case VIR_DOMAIN_NET_TYPE_MCAST: - case VIR_DOMAIN_NET_TYPE_UDP: - case VIR_DOMAIN_NET_TYPE_INTERNAL: - case VIR_DOMAIN_NET_TYPE_DIRECT: - case VIR_DOMAIN_NET_TYPE_HOSTDEV: - case VIR_DOMAIN_NET_TYPE_VDS: - case VIR_DOMAIN_NET_TYPE_ETHERNET: - case VIR_DOMAIN_NET_TYPE_NULL: - case VIR_DOMAIN_NET_TYPE_LAST: - break; + if (!virNetDevBandwidthValidate(net->bandwidth)) { + return -1; } =20 return 0; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index e5da550e45..3328a63205 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3486,8 +3486,36 @@ - - + + + + unix + + + + + + + + + + + server + client + + + + + + + + + + + + + + diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7370711918..54130ac4f0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8649,11 +8649,12 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuInterfaceVhostuserConnect(cmd, net, qemuCaps) < 0) goto cleanup; =20 - if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->da= ta.nix.path, + if (net->backend.type !=3D VIR_DOMAIN_NET_BACKEND_PASST && + virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->da= ta.nix.path, net->data.vhostuser->da= ta.nix.listen, - &net->ifname) < 0) + &net->ifname) < 0) { goto cleanup; - + } break; =20 case VIR_DOMAIN_NET_TYPE_VDPA: diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 954cb323a4..2384bab7a6 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -212,13 +212,15 @@ 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) + if (net->type !=3D VIR_DOMAIN_NET_TYPE_USER && + net->type !=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { continue; + } =20 if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { if (qemuPasstStart(vm, net) < 0) return -1; - } else { + } else if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER) { if (qemuSlirpStart(vm, net, incomingMigration) < 0) return -1; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6c224c9793..28ca321c5c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1262,10 +1262,23 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (!(charDevAlias =3D qemuAliasChardevFromDevAlias(net->info.alia= s))) goto cleanup; =20 - if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->da= ta.nix.path, - net->data.vhostuser->da= ta.nix.listen, - &net->ifname) < 0) - goto cleanup; + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { + + /* vhostuser needs socket path in this location, and when + * backend is passt, the path is derived from other info, + * not taken from config. + */ + g_free(net->data.vhostuser->data.nix.path); + net->data.vhostuser->data.nix.path =3D qemuPasstCreateSocketPa= th(vm, net); + + if (qemuPasstStart(vm, net) < 0) + goto cleanup; + } else { + if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser= ->data.nix.path, + net->data.vhostuser= ->data.nix.listen, + &net->ifname) < 0) + goto cleanup; + } =20 if (qemuSecuritySetNetdevLabel(driver, vm, net) < 0) goto cleanup; diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 8a3ac4e988..b9616d1c63 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -180,6 +180,9 @@ qemuPasstStart(virDomainObj *vm, =20 virCommandClearCaps(cmd); =20 + if (virDomainNetGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSE= R) + virCommandAddArg(cmd, "--vhost-user"); + virCommandAddArgList(cmd, "--one-off", "--socket", passtSocketName, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 963d090963..0d9b8bcb93 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -64,6 +64,7 @@ #include "qemu_backup.h" #include "qemu_dbus.h" #include "qemu_snapshot.h" +#include "qemu_passt.h" =20 #include "cpu/cpu.h" #include "cpu/cpu_x86.h" @@ -5931,12 +5932,23 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm) } break; =20 + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + if (net->backend.type =3D=3D VIR_DOMAIN_NET_BACKEND_PASST) { + /* when using the passt backend, the path of the + * unix socket is always derived from other info + * *not* manually given in the config, but all the + * vhostuser code looks for it there. + */ + g_free(net->data.vhostuser->data.nix.path); + net->data.vhostuser->data.nix.path =3D qemuPasstCreateSock= etPath(vm, net); + } + break; + case VIR_DOMAIN_NET_TYPE_DIRECT: case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_USER: - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_CLIENT: case VIR_DOMAIN_NET_TYPE_MCAST: @@ -5948,7 +5960,6 @@ qemuProcessPrepareDomainNetwork(virDomainObj *vm) case VIR_DOMAIN_NET_TYPE_LAST: break; } - } return 0; } diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index b0cf5e866c..92e745cea1 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1751,7 +1751,9 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNet= Def *net, return -1; } =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER) { + 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)) { virDomainCapsDeviceNet netCaps =3D { }; =20 virQEMUCapsFillDomainDeviceNetCaps(qemuCaps, &netCaps); @@ -1826,7 +1828,8 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNet= Def *net, } =20 if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { - if (!net->data.vhostuser->data.nix.path) { + if (!net->data.vhostuser->data.nix.path && + net->backend.type !=3D VIR_DOMAIN_NET_BACKEND_PASST) { virReportError(VIR_ERR_XML_ERROR, _("Missing required attribute '%1$s' in element= '%2$s'"), "path", "source"); diff --git a/tests/qemuxmlconfdata/net-user-slirp-portforward.x86_64-latest= .err b/tests/qemuxmlconfdata/net-user-slirp-portforward.x86_64-latest.err index eaa934742e..e231677e57 100644 --- a/tests/qemuxmlconfdata/net-user-slirp-portforward.x86_64-latest.err +++ b/tests/qemuxmlconfdata/net-user-slirp-portforward.x86_64-latest.err @@ -1 +1 @@ -unsupported configuration: The element can only be used with= and its 'passt' backend +unsupported configuration: The element can only be used with= the 'passt' backend of interface type=3D'user' or type=3D'vhostuser' diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args b= /tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args new file mode 100644 index 0000000000..21d78d6072 --- /dev/null +++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args @@ -0,0 +1,42 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","read-only":false}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-stor= age","id":"ide0-0-0","bootindex":1}' \ +-chardev socket,id=3Dcharnet0,path=3D/var/run/libvirt/qemu/passt/-1-QEMUGu= est1-net0.socket \ +-netdev '{"type":"vhost-user","chardev":"charnet0","id":"hostnet0"}' \ +-device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":= "00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \ +-chardev socket,id=3Dcharnet1,path=3D/var/run/libvirt/qemu/passt/-1-QEMUGu= est1-net1.socket \ +-netdev '{"type":"vhost-user","chardev":"charnet1","id":"hostnet1"}' \ +-device '{"driver":"virtio-net-pci","netdev":"hostnet1","id":"net1","mac":= "00:11:22:33:44:11","bus":"pci.0","addr":"0x3"}' \ +-chardev socket,id=3Dcharnet2,path=3D/var/run/libvirt/qemu/passt/-1-QEMUGu= est1-net2.socket \ +-netdev '{"type":"vhost-user","chardev":"charnet2","id":"hostnet2"}' \ +-device '{"driver":"virtio-net-pci","netdev":"hostnet2","id":"net2","mac":= "00:11:22:33:44:11","bus":"pci.0","addr":"0x4"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml b/= tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml new file mode 100644 index 0000000000..26aa4c8d05 --- /dev/null +++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml @@ -0,0 +1,72 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + +