From nobody Mon Feb 9 11:47:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581913433184313.5123340660017; Sun, 16 Feb 2020 20:23:53 -0800 (PST) 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-229-6aMAR_57MwyiQW_QHhp40g-1; Sun, 16 Feb 2020 23:23:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7517A100DFC1; Mon, 17 Feb 2020 04:23:40 +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 4AFEE5C10D; Mon, 17 Feb 2020 04:23:40 +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 036AC18089D0; Mon, 17 Feb 2020 04:23:40 +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 01H4NB8O002323 for ; Sun, 16 Feb 2020 23:23:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 259DD90F55; Mon, 17 Feb 2020 04:23:11 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-126.phx2.redhat.com [10.3.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC23C5C10D for ; Mon, 17 Feb 2020 04:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581913432; 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=aNU4mfHR81ywWc/3Sn+Y4KlivnCeteXwQVjHMPq2fuw=; b=UmJOXjXaojuJayhE89dD+SShhxWMfwSCfIZNvh1sSiudMVfHnhsPvzX5rTWSc8DOgWCttJ GHB0KoyduEhremXslsI40gTkIqi3FbFmpc4QpgrTFuO+EhUBsHn0Zr1WuiC/WwSNrW0xto XpbOzD0pIvWSj2nVJ1p4V7oUe/d8R0A= From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] conf: extra validation for Date: Sun, 16 Feb 2020 23:22:58 -0500 Message-Id: <20200217042259.1066479-10-laine@redhat.com> In-Reply-To: <20200217042259.1066479-1-laine@redhat.com> References: <20200217042259.1066479-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 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.15 X-MC-Unique: 6aMAR_57MwyiQW_QHhp40g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" During the hypervisor-agnostic validation of network devices, verify that the interface type is either "network" or "bridge", and that if there is any , that it doesn't have any type associated with it. This needs to be done both for the parse-time validation and for runtime validation (after a port has been acquired from any associated network), because an interface with type=3D'network' could have an actual type at runtime of "hostdev" or "direct", neither of which support isolated=3D'true' (yet). Likewise, if an interface is type=3D'network', then at runtime a with a type that doesn't support isolated=3D'yes' (e.g. "openvswitch", "802.1Qbh" - currently *none* of the available virtualport types support it) Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 30b2a53b83..f8ce7d519d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6239,6 +6239,47 @@ virDomainRedirdevDefValidate(const virDomainDef *def, } =20 =20 +static int +virDomainNetDefValidatePortOptions(const char *macstr, + virDomainNetType type, + const virNetDevVPortProfile *vport, + virTristateBool isolatedPort) +{ + /* + * This function can be called for either a config interface + * object (NetDef) or a runtime interface object (ActualNetDef), + * by calling it with either, e.g., the "type" (what is in the + * config) or the "actualType" (what is determined at runtime by + * acquiring a port from the network). + */ + /* + * port isolation can only be set for an interface that is + * connected to a Linux host bridge (either a libvirt-managed + * network, or plain type=3D'bridge') + */ + if (isolatedPort =3D=3D VIR_TRISTATE_BOOL_YES) { + if (!(type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || + type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("interface %s - is not supported for network interfaces with type=3D'%s'"), + macstr, virDomainNetTypeToString(type)); + return -1; + } + /* + * also not allowed for anything with setting + * (openvswitch or 802.11Qb[gh]) + */ + if (vport && vport->virtPortType !=3D VIR_NETDEV_VPORT_PROFILE_NON= E) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("interface %s - is not supported for network interfaces with virtualport type=3D'%s'"), + macstr, virNetDevVPortTypeToString(vport->virtP= ortType)); + return -1; + } + } + return 0; +} + + int virDomainActualNetDefValidate(const virDomainNetDef *net) { @@ -6291,6 +6332,11 @@ virDomainActualNetDefValidate(const virDomainNetDef = *net) return -1; } =20 + if (virDomainNetDefValidatePortOptions(macstr, actualType, vport, + virDomainNetGetActualPortOption= sIsolated(net)) < 0) { + return -1; + } + return 0; } =20 @@ -6298,6 +6344,10 @@ virDomainActualNetDefValidate(const virDomainNetDef = *net) static int virDomainNetDefValidate(const virDomainNetDef *net) { + char macstr[VIR_MAC_STRING_BUFLEN]; + + virMacAddrFormat(&net->mac, macstr); + if ((net->hostIP.nroutes || net->hostIP.nips) && net->type !=3D VIR_DOMAIN_NET_TYPE_ETHERNET) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -6331,6 +6381,12 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } } + + if (virDomainNetDefValidatePortOptions(macstr, net->type, net->virtPor= tProfile, + net->isolatedPort) < 0) { + return -1; + } + return 0; } =20 --=20 2.24.1