From nobody Tue Nov 26 16:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571793975; cv=none; d=zoho.com; s=zohoarc; b=mlNhQysBzNKGSuBrS49JwcAaSfRdkPNJnxscZELtCY6geqfwAAHrcUmjdC7eqmL4zHM2MA+I41sDx7r6RRrgVszR6ge5etLj/SaQPnVUD3g4MHTJj/A+TmAbhUglBsPEpcxlsFMUUN/feU82nct/kpXPBI6QoE+6c630OwJCJbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571793975; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQy0/WNTbTgPOKEU+NRi2YbBaNCdutaFlmCEFrhJ6Go=; b=OgpDPGAA3soPdEFZiDyblSqm5TKGj2WpcAxVGtcrxZbob0Pw1ZCojaHFKr2fvEA58TvwgWeHf3w0SoKOZGiB8q9zCq8PUTa08treXeD5KBhttmE8fSTWzt5Cf5eWCFmhfgXV5/MYD35qi5LkjNd1HfJyju9O8+8mmM86qQQhz9E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571793975147251.59030588934274; Tue, 22 Oct 2019 18:26:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314-72Y4enPfMmSYlBB4gzQh_A-1; Tue, 22 Oct 2019 21:26:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D951B801E52; Wed, 23 Oct 2019 01:26:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B024D60619; Wed, 23 Oct 2019 01:26:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 43F541803B49; Wed, 23 Oct 2019 01:26:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9N1OUCg030910 for ; Tue, 22 Oct 2019 21:24:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4B8E5D6C8; Wed, 23 Oct 2019 01:24:30 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-114.phx2.redhat.com [10.3.117.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 721DF5D6B2 for ; Wed, 23 Oct 2019 01:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571793974; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hQy0/WNTbTgPOKEU+NRi2YbBaNCdutaFlmCEFrhJ6Go=; b=TgPSq6ra/55CKebKKX0DhBj8oyOHXy1bH3S7NtMGg2m9xKvWy+/oKQcyE1ZJ+JUI2asLIF ENWsS3ktRB5R+3TYvj/pgNgxg5ooLOPAlANO7VpL8j4XOUwpLN+5GY0u5U9oDasdVoWtKx 2g7qzuGPVqD4zjCwbMS5xroK/DxFdNg= From: Laine Stump To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 21:24:20 -0400 Message-Id: <20191023012420.21128-8-laine@redhat.com> In-Reply-To: <20191023012420.21128-1-laine@redhat.com> References: <20191023012420.21128-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] net/qemu: move vlan/bandwidth validation out of network driver X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 72Y4enPfMmSYlBB4gzQh_A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In the past the network driver was (mistakenly) being called for all interfaces, not just those of type=3D'network', and so it had a chance to validate all interface configs after the actual type of the interface was known. But since the network driver has been more completely/properly separated from qemu, the network driver isn't called during the startup of any interfaces except those with type=3D'network', so this validation no longer takes place for, e.g. (or direct, etc). This in turn meant that a config could erroneously specify a vlan tag, or bandwidth settings, for a type of interface that didn't support it, and the domain would start without complaint, just silently ignoring those settings. This patch moves those validation checks out of the network driver, and into virDomainNetDefRuntimeValidate() so they will be done for all interfaces, not just type=3D'network'. https://bugzilla.redhat.com/1741121 Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 36 +++++++++++++++++++++++++++++++++++- src/network/bridge_driver.c | 37 ------------------------------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c063f40a4c..59a75e67ed 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6110,9 +6110,43 @@ virDomainNetDefRuntimeValidate(const virDomainNetDef= *net G_GNUC_UNUSED) * is allowed for a type of interface), but *not* * hypervisor-specific things. */ + char macstr[VIR_MAC_STRING_BUFLEN]; + virDomainNetType actualType =3D virDomainNetGetActualType(net); + const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(net); + const virNetDevBandwidth *bandwidth =3D virDomainNetGetActualBandwidth= (net); =20 - return 0; + virMacAddrFormat(&net->mac, macstr); =20 + if (virDomainNetGetActualVlan(net)) { + /* vlan configuration via libvirt is only supported for PCI + * Passthrough SR-IOV devices (hostdev or macvtap passthru + * mode) and openvswitch bridges. Otherwise log an error and + * fail + */ + if (!(actualType =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV || + (actualType =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT && + virDomainNetGetActualDirectMode(net) =3D=3D VIR_NETDEV_MACV= LAN_MODE_PASSTHRU) || + (actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE && + vport && vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFI= LE_OPENVSWITCH))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("interface %s - vlan tag not supported for th= is connection type"), + macstr); + return -1; + } + } + + /* bandwidth configuration via libvirt is not supported for + * hostdev network devices + */ + if (bandwidth && actualType =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("interface %s - bandwidth settings are not suppor= ted " + "for hostdev interfaces"), + macstr); + return -1; + } + + return 0; } =20 =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 85e568e888..1c47485b9d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4793,43 +4793,6 @@ networkAllocatePort(virNetworkObjPtr obj, if (virNetDevVPortProfileCheckComplete(port->virtPortProfile, true) < = 0) goto cleanup; =20 - /* make sure that everything now specified for the device is - * actually supported on this type of network. NB: network, - * netdev, and iface->data.network.actual may all be NULL. - */ - VIR_DEBUG("Sanity check port config"); - - if (port->vlan.nTags) { - /* vlan configuration via libvirt is only supported for PCI - * Passthrough SR-IOV devices (hostdev or macvtap passthru - * mode) and openvswitch bridges. Otherwise log an error and - * fail - */ - if (!(port->plugtype =3D=3D VIR_NETWORK_PORT_PLUG_TYPE_HOSTDEV_PCI= || - (port->plugtype =3D=3D VIR_NETWORK_PORT_PLUG_TYPE_DIRECT && - port->plug.direct.mode =3D=3D VIR_NETDEV_MACVLAN_MODE_PASST= HRU) || - (port->plugtype =3D=3D VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE && - port->virtPortProfile && - port->virtPortProfile->virtPortType =3D=3D VIR_NETDEV_VPORT= _PROFILE_OPENVSWITCH))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("an interface connecting to network '%s' " - "is requesting a vlan tag, but that is not " - "supported for this type of network"), - netdef->name); - goto cleanup; - } - } - - /* bandwidth configuration via libvirt is not supported for - * hostdev network devices - */ - if (port->bandwidth && port->plugtype =3D=3D VIR_NETWORK_PORT_PLUG_TYP= E_HOSTDEV_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("bandwidth settings are not supported " - "for hostdev interfaces")); - goto cleanup; - } - netdef->connections++; if (dev) dev->connections++; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list