From nobody Fri Dec 19 04:30:55 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 1739470862283536.040986874595; Thu, 13 Feb 2025 10:21:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2AA7F1A2A; Thu, 13 Feb 2025 13:21:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8EDD118A1; Thu, 13 Feb 2025 13:20:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C0AA1728; Thu, 13 Feb 2025 13:20:01 -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 6DBBE14A0 for ; Thu, 13 Feb 2025 13:20:00 -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-407-EN7PdtoLMtmAWgAZW0LuGw-1; Thu, 13 Feb 2025 13:19:58 -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 F026019783B7 for ; Thu, 13 Feb 2025 18:19:57 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3B7B218004A7; Thu, 13 Feb 2025 18:19:55 +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=1739470800; 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=A8AZRB24p2OALk+Q1Is1znwIJWZlaOhSvHMNRVF53FUDaKOJmMTTb+Aeo6gjC25fzmC85M /e0mi/t/TEE0RBmTjPgJivnoHoyN+CQwWmlDhrZndl9lZ2ibPT3nilooZoq16Fw/perbi7 VPC+HS00QWJ5VDHLWkU8mcaXvMHqJJo= X-MC-Unique: EN7PdtoLMtmAWgAZW0LuGw-1 X-Mimecast-MFC-AGG-ID: EN7PdtoLMtmAWgAZW0LuGw From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 1/9] conf: change virDomainHostdevInsert() to return void Date: Thu, 13 Feb 2025 13:19:45 -0500 Message-ID: <20250213181953.922499-2-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: O-tdK1XXnRixu_-XHrsKcD5EKEJcK-MCVNjFIJ1z4wU_1739470798 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 2NWVQ2LOAEDAEDPOZEZSZYMOSIROVKVL X-Message-ID-Hash: 2NWVQ2LOAEDAEDPOZEZSZYMOSIROVKVL 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: 1739470864021019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739470895925404.64943862447456; Thu, 13 Feb 2025 10:21:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5383218A1; Thu, 13 Feb 2025 13:21:35 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 19CF814FB; Thu, 13 Feb 2025 13:20:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id EAFD71741; Thu, 13 Feb 2025 13:20:08 -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 10F9916EC for ; Thu, 13 Feb 2025 13:20:01 -0500 (EST) Received: from mx-prod-mc-06.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-693-q1wmqzxwPQacMepkF0SD6A-1; Thu, 13 Feb 2025 13:19:59 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AB4C6180087B for ; Thu, 13 Feb 2025 18:19:58 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1D2E918004A7; Thu, 13 Feb 2025 18:19:57 +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=1739470800; 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=Z/dJJFGlFDTAIzm748a3Ph7+4l8jvzTLiONn9N9jg/wZAvxWRgLyU5mtIf/p4i3V+GoC/y WRoQpbJRe0oQJo8IwUH9XsyV0pGvHyK+hFHsJJWGETqHI9JPd5JeRaUJep4xWROuOMwS3d b2U204+gOtV6pFEn1KxTgAvcrDL+EYY= X-MC-Unique: q1wmqzxwPQacMepkF0SD6A-1 X-Mimecast-MFC-AGG-ID: q1wmqzxwPQacMepkF0SD6A From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 2/9] qemu: fix qemu validation to forbid guest-side IP address for type='vdpa' Date: Thu, 13 Feb 2025 13:19:46 -0500 Message-ID: <20250213181953.922499-3-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: 7E4ZvcSZpo_r-CpLRa8svyXZTqwQ_ZUF2f9TmTS96uM_1739470798 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5SCLIOY43O7GZUV4BBE5DGOIL2GX2SQC X-Message-ID-Hash: 5SCLIOY43O7GZUV4BBE5DGOIL2GX2SQC 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: 1739470896537019000 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739470917487380.89614281517413; Thu, 13 Feb 2025 10:21:57 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 74722177F; Thu, 13 Feb 2025 13:21:56 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DB95C192D; Thu, 13 Feb 2025 13:20:15 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CA6961728; Thu, 13 Feb 2025 13:20:11 -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 E4C8B1790 for ; Thu, 13 Feb 2025 13:20:01 -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-39-vf8AW9juMD-RquaBkGyYTg-1; Thu, 13 Feb 2025 13:20:00 -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 86EA5190F9EA for ; Thu, 13 Feb 2025 18:19:59 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EBB43180034D; Thu, 13 Feb 2025 18:19:58 +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=1739470801; 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=jOVAMCdPKki3nw/hfrhyAbGWj+9GEy8IYF6vVC3S2taSCK5ZDH4HJBQhIg2RaTsA/g9XGJ 909itUfAPvJvtrQdtK566zVursr3Wazf8BnSDeKRM141lw124viT/5qbDtXafP6TOYs+nw s7leFpE4dAyD6WOboaBJ4qf4ecvlRHE= X-MC-Unique: vf8AW9juMD-RquaBkGyYTg-1 X-Mimecast-MFC-AGG-ID: vf8AW9juMD-RquaBkGyYTg_1739470799 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 3/9] qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same place Date: Thu, 13 Feb 2025 13:19:47 -0500 Message-ID: <20250213181953.922499-4-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: 4rO1W5PCgjlr5-XAVi7NubbSFm83sZCELs90bpm8oDw_1739470799 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UE52T23Z3LHNRD4GTIFNHZP5SWNKNDYZ X-Message-ID-Hash: UE52T23Z3LHNRD4GTIFNHZP5SWNKNDYZ 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: 1739470921071019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739470934422921.2008593753353; Thu, 13 Feb 2025 10:22:14 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D7B741527; Thu, 13 Feb 2025 13:22:13 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C3E4B157C; Thu, 13 Feb 2025 13:20:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id DC9FD195D; Thu, 13 Feb 2025 13:20:15 -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 AFECB17F0 for ; Thu, 13 Feb 2025 13:20:02 -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-360-zmJ56Q-ANnettrOQhIqJ4Q-1; Thu, 13 Feb 2025 13:20:01 -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 742AB19783BA for ; Thu, 13 Feb 2025 18:20:00 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDC9318004A7; Thu, 13 Feb 2025 18:19:59 +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=1739470802; 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=SFAvWDxDQQs0Bp4qYpn/1q5gTL7PS0oudOtoe/7sEBiAdDVjnHJ8TFf4i3s6Ft0pNbQoZs uFOFyAw4qa4mnQiTYWE8Rp+jNske8n3x0msx5KruHGmcVb0oq6VMsHbjqPri0yARMpRbkv khEjPftQ9CQQ9np+heku6DqlF6hrqzY= X-MC-Unique: zmJ56Q-ANnettrOQhIqJ4Q-1 X-Mimecast-MFC-AGG-ID: zmJ56Q-ANnettrOQhIqJ4Q From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 4/9] qemu: automatically set model type='virtio' for interface type='vhostuser' Date: Thu, 13 Feb 2025 13:19:48 -0500 Message-ID: <20250213181953.922499-5-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: yeq7Mu3jd8oMsSY6-oLRf7KIpOlTpxWTh_e-xY-ztXQ_1739470800 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SZOTSP5C42N5NYIK5GCXLBWRC2ANOL3C X-Message-ID-Hash: SZOTSP5C42N5NYIK5GCXLBWRC2ANOL3C 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: 1739470936558019000 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739470955063694.4780113055048; Thu, 13 Feb 2025 10:22:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 030BC17E7; Thu, 13 Feb 2025 13:22:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D8A041892; Thu, 13 Feb 2025 13:20:22 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 277AE1555; Thu, 13 Feb 2025 13:20:17 -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 B54E01555 for ; Thu, 13 Feb 2025 13:20:03 -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-10-sIwb3RVwNmm8HpWFrBs7zg-1; Thu, 13 Feb 2025 13:20:02 -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 5575A1801A1A for ; Thu, 13 Feb 2025 18:20:01 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B1438180034D; Thu, 13 Feb 2025 18:20:00 +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=1739470803; 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=Lvw+HnNLFRCt1Kj3yABVqbY8cX6mvfDlXc8UK5bYs69v3v+3JQcZ7AcpTur2qrgvODtSyw xdasGuzfSx38tTCW8L9vgkTZqQ6MPFtcWKffV/1d/sX6U1KMvTjwzqaOBtx2XPS5h2J0db zFnc19IubI7dkpFuL5NOwOGHs5DqKSo= X-MC-Unique: sIwb3RVwNmm8HpWFrBs7zg-1 X-Mimecast-MFC-AGG-ID: sIwb3RVwNmm8HpWFrBs7zg_1739470801 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 5/9] qemu: do all vhostuser attribute validation in qemu driver Date: Thu, 13 Feb 2025 13:19:49 -0500 Message-ID: <20250213181953.922499-6-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: yk58TResjFP9f72pJSyoCNPs5wvWTrVZ-eV7c6tN-iU_1739470801 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JEOQGGC6SWZ52II5RYM64GBJP4JZJZP4 X-Message-ID-Hash: JEOQGGC6SWZ52II5RYM64GBJP4JZJZP4 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: 1739470956488019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739470982891994.0120175201491; Thu, 13 Feb 2025 10:23:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id ACF291A76; Thu, 13 Feb 2025 13:23:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1F3341983; Thu, 13 Feb 2025 13:20:25 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3B86516C2; Thu, 13 Feb 2025 13:20:18 -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 AC8ED1872 for ; Thu, 13 Feb 2025 13:20:04 -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-nekG4bmjNoSW43bvZt5wgg-1; Thu, 13 Feb 2025 13:20:03 -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 3370618D95EE for ; Thu, 13 Feb 2025 18:20:02 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 964A61800352; Thu, 13 Feb 2025 18:20:01 +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=1739470804; 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=Xj9Yd361e56VQ/icRuo/360MpX6ffEXl8nACMW3Z43C5WRWNESLemao/ktw+3JGc56C0XV W+6tQXa2JATQCuAzQOkPa4x7ZrN2vJcKaOLpvcSaBEyyHFU0vdeX81lYN6IgM9ngn8C4Ye CWRywUJq8/Ie/EX5CWpm4hxnnbJrbVY= X-MC-Unique: nekG4bmjNoSW43bvZt5wgg-1 X-Mimecast-MFC-AGG-ID: nekG4bmjNoSW43bvZt5wgg From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 6/9] conf/qemu: make element *almost* optional for type=vhostuser Date: Thu, 13 Feb 2025 13:19:50 -0500 Message-ID: <20250213181953.922499-7-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: LCA1JUySNS1i4P2dDUSIM06hJ4MZRL6GkqfrPixmNao_1739470802 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IILXQAODJNZH2DDGH24R6MBM3QFYVQYM X-Message-ID-Hash: IILXQAODJNZH2DDGH24R6MBM3QFYVQYM 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: 1739470984632019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 173947100565915.541737825123391; Thu, 13 Feb 2025 10:23:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7E3E3178F; Thu, 13 Feb 2025 13:23:24 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7D416179D; Thu, 13 Feb 2025 13:20:27 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9DA9116B2; Thu, 13 Feb 2025 13:20:18 -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 8E82E189A for ; Thu, 13 Feb 2025 13:20:05 -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-373-Dr8ChivtP9Si4F_b7zcumw-1; Thu, 13 Feb 2025 13:20:03 -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 0B17718D95F5 for ; Thu, 13 Feb 2025 18:20:03 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7181618004A7; Thu, 13 Feb 2025 18:20:02 +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=1739470805; 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=Y2x5OXfg618NNTrKKGegk2hIjTqhYCvtXFii3k8AtECnVt8Jt4GzFO2LduEkXjIK8ofMXJ aciVPkWjjkPQHNO328TsDCrnVe29RLV2qtYixXNRFEbTIxVrL6KWlJoeErrfFAWXkYzbg8 PXmh6n4ZJ2MuysBTLjBLgwd4NDYvxpw= X-MC-Unique: Dr8ChivtP9Si4F_b7zcumw-1 X-Mimecast-MFC-AGG-ID: Dr8ChivtP9Si4F_b7zcumw From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 7/9] qemu: use switch instead of if in qemuProcessPrepareDomainNetwork() Date: Thu, 13 Feb 2025 13:19:51 -0500 Message-ID: <20250213181953.922499-8-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: IO0iJDuWna2tc2JpJ0E2N6sqD9-xkGptKlgK8ESdZVw_1739470803 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZYQLCGE7CWHTEZ7GZMXM5JJTIA3OJW2M X-Message-ID-Hash: ZYQLCGE7CWHTEZ7GZMXM5JJTIA3OJW2M 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: 1739471008583019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739471028138285.5365486142681; Thu, 13 Feb 2025 10:23:48 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2456D18A4; Thu, 13 Feb 2025 13:23:47 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6D40017B1; Thu, 13 Feb 2025 13:20:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A154F1725; Thu, 13 Feb 2025 13:20:22 -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 4D56B168D for ; Thu, 13 Feb 2025 13:20:06 -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-140-NQYowkjEOyCCpsaEordGeg-1; Thu, 13 Feb 2025 13:20:04 -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 E342E19039C5 for ; Thu, 13 Feb 2025 18:20:03 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4AA60180034D; Thu, 13 Feb 2025 18:20:03 +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=1739470806; 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=NC55qj3tTSQMeO5TrZNfpRITD5JRp9RYTyGYNVTqLUPQ3RXgU+fiFEYw0xtq/pLoHkgjdm YQqH8TSYgrhCxRIC2AfXm7L52e6DRy9WZRyBzF70I6xd/PKQFi4UTQ7O4Vayj4e2au4pEC 0tCuin6diCVHzZ1pjLrGbn0Yc5MqxoI= X-MC-Unique: NQYowkjEOyCCpsaEordGeg-1 X-Mimecast-MFC-AGG-ID: NQYowkjEOyCCpsaEordGeg_1739470804 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 8/9] qemu: make qemuPasstCreateSocketPath() public Date: Thu, 13 Feb 2025 13:19:52 -0500 Message-ID: <20250213181953.922499-9-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: 1UtbMZs4kuzNKpqgy8PtMM4B9aktrpI4nLru_1MAWJU_1739470804 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6OLN3N5Y6T76OC6CTI3SICGTGVNSWM2C X-Message-ID-Hash: 6OLN3N5Y6T76OC6CTI3SICGTGVNSWM2C 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: 1739471030533019100 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 Reviewed-by: J=C3=A1n Tomko --- 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:30:55 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 1739471088396317.3351593201178; Thu, 13 Feb 2025 10:24:48 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4BAF61261; Thu, 13 Feb 2025 13:24:47 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2505D1962; Thu, 13 Feb 2025 13:20:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 23B7A14AD; Thu, 13 Feb 2025 13:20:29 -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 D552218CA for ; Thu, 13 Feb 2025 13:20:07 -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-327-0P0D1K3JNnOSyx4NpCHpFQ-1; Thu, 13 Feb 2025 13:20:05 -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 DECDC1800877 for ; Thu, 13 Feb 2025 18:20:04 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.63]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2EDC41800352; Thu, 13 Feb 2025 18:20:04 +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=1739470807; 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=RrFn/g9Gsd/s+16XhF5A/Wsa9owBuumGclDTlnICY8g=; b=PePURaAPkd/WKFU2JcxGEB9EG5mCuCAxwdokMfvkiIWSdk1iOtS+acIawC52DV8yU8b/Pv BAc6eKX+AioPLa0RQPUquBu3UYR0hc4/NVUICoAjnZxVZsOMkQDKPp8dLi/HvKLSTPBVv2 JISCecc+SnYF7v/W2+O2VfcwZZ7lQeQ= X-MC-Unique: 0P0D1K3JNnOSyx4NpCHpFQ-1 X-Mimecast-MFC-AGG-ID: 0P0D1K3JNnOSyx4NpCHpFQ_1739470805 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 9/9] qemu: complete vhostuser + passt support Date: Thu, 13 Feb 2025 13:19:53 -0500 Message-ID: <20250213181953.922499-10-laine@redhat.com> In-Reply-To: <20250213181953.922499-1-laine@redhat.com> References: <20250213181953.922499-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: dj3zyX9khPzkmxdIzowiCR7ejZ5WVPN4BnZJ1pq1bQw_1739470805 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3PDROB7AVQDSKCSX53RTF32YBZ3WBT5L X-Message-ID-Hash: 3PDROB7AVQDSKCSX53RTF32YBZ3WBT5L 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: 1739471091111019100 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 | 75 +++++++------------ 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 | 14 +++- 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, 315 insertions(+), 73 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..d38a77aa22 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2163,7 +2163,8 @@ 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'")); @@ -2171,59 +2172,37 @@ virDomainNetDefValidate(const virDomainNetDef *net) } } =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..be8e32fbc3 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,22 @@ 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. + */ + 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 +5959,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 + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + +