From nobody Sat Feb 7 15:15:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1558627725; cv=none; d=zoho.com; s=zohoarc; b=QH9kz7EEE/T2kPtFrGjpxmZBSX2A1JVfKqzIRkXtkqHXYEuuW5EYI4Cm6/+2V1EFUxTlQiGSN0J8FwguFpK9OUIImuYe8W/pSg6zET9PrE0Xe3PCtk5I2jw621R73qIuVLq7MjAY/Ey33C1M3ii78Y6cZtbFE8ORCKiIrC5wSEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558627725; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=9jnEFI8suMMBMKX16OMSFE6RxazzSU9BI2NaLjeZ+rw=; b=l7DsfVeeD1FhAQ6aRihrvkyUG/InXmbVrR2q69Azdx8QgT4o/K4LBZiESiUfA+HDxr1bVj4PMFtArMcP5qTbCPsg4IjPekCmCChz/SbTxPfl9FXvrG331Stwg27ydnd1QjyS7bYy9aBcYOoySO40z6R6Vt/GzUVtLsL+6c31yEM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155862772581269.6479592730841; Thu, 23 May 2019 09:08:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 14B59C0A4F7D; Thu, 23 May 2019 16:08: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 D0D095B685; Thu, 23 May 2019 16:08:36 +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 91FC81806B1B; Thu, 23 May 2019 16:08:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4NFXqGT007072 for ; Thu, 23 May 2019 11:33:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74A0F7BE71; Thu, 23 May 2019 15:33:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59260620CA; Thu, 23 May 2019 15:33:51 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 23 May 2019 16:33:01 +0100 Message-Id: <20190523153302.28526-23-berrange@redhat.com> In-Reply-To: <20190523153302.28526-1-berrange@redhat.com> References: <20190523153302.28526-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Laine Stump Subject: [libvirt] [PATCH v6 22/23] conf: record a portid against the domain conf 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 May 2019 16:08:44 +0000 (UTC) The portid will be the UUID of the virNetworkPort object associated with the network interface when a guest is running. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Laine Stump --- docs/formatdomain.html.in | 8 +++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 21 +++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ .../net-virtio-network-portgroup.xml | 6 +++--- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c843b1d667..ec4ff0cedc 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5309,6 +5309,14 @@ information for different classes of network connections. Since 0.9.4.

+

+ When a guest is running and interface of type network + may include a portid attribute. This provides the UUID + of an associated virNetworkPortPtr object that records the associati= on + between the domain interface and the network. This attribute is + read-only since port objects are create and deleted automatically + during startup and shutdown. Since 5.1.0/ +

Also, similar to direct network connections (described below), a connection of type network may diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 111b85c36f..ecdde43c3a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2591,6 +2591,11 @@ + + + + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 12e6ca8c35..7ca76120c3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11397,6 +11397,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_AUTOFREE(char *) type =3D NULL; VIR_AUTOFREE(char *) network =3D NULL; VIR_AUTOFREE(char *) portgroup =3D NULL; + VIR_AUTOFREE(char *) portid =3D NULL; VIR_AUTOFREE(char *) bridge =3D NULL; VIR_AUTOFREE(char *) dev =3D NULL; VIR_AUTOFREE(char *) ifname =3D NULL; @@ -11474,6 +11475,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, virXMLNodeNameEqual(cur, "source")) { network =3D virXMLPropString(cur, "network"); portgroup =3D virXMLPropString(cur, "portgroup"); + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + portid =3D virXMLPropString(cur, "portid"); } else if (!internal && def->type =3D=3D VIR_DOMAIN_NET_TYPE_INTERNAL && virXMLNodeNameEqual(cur, "source")) { @@ -11687,6 +11690,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, "specified with = ")); goto error; } + if (portid && + virUUIDParse(portid, def->data.network.portid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse port id '%s'"), portid); + goto error; + } + VIR_STEAL_PTR(def->data.network.name, network); VIR_STEAL_PTR(def->data.network.portgroup, portgroup); VIR_STEAL_PTR(def->data.network.actual, actual); @@ -24975,6 +24985,11 @@ virDomainActualNetDefContentsFormat(virBufferPtr b= uf, def->data.network.name); virBufferEscapeString(buf, " portgroup=3D'%s'", def->data.network.portgroup); + if (virUUIDIsValid(def->data.network.portid)) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(def->data.network.portid, uuidstr); + virBufferAsprintf(buf, " portid=3D'%s'", uuidstr); + } } if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -25278,6 +25293,12 @@ virDomainNetDefFormat(virBufferPtr buf, def->data.network.name); virBufferEscapeString(buf, " portgroup=3D'%s'", def->data.network.portgroup); + if (virUUIDIsValid(def->data.network.portid) && + !(flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE))) { + char portidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(def->data.network.portid, portidstr); + virBufferEscapeString(buf, " portid=3D'%s'", portidstr); + } sourceLines++; break; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a584925fc7..41fadbeb49 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -969,6 +969,7 @@ struct _virDomainNetDef { struct { char *name; char *portgroup; + unsigned char portid[VIR_UUID_BUFLEN]; /* actual has info about the currently used physical * device (if the network is of type * bridge/private/vepa/passthrough). This is saved in the @@ -976,6 +977,9 @@ struct _virDomainNetDef { * since it needs to be re-allocated whenever the domain * is restarted. It is also never shown to the user, and * the user cannot specify it in XML documents. + * + * This information is populated from the virNetworkPort + * object associated with the portid UUID above. */ virDomainActualNetDefPtr actual; } network; diff --git a/tests/qemuxml2argvdata/net-virtio-network-portgroup.xml b/test= s/qemuxml2argvdata/net-virtio-network-portgroup.xml index 54a0eb7229..3d6cd02a73 100644 --- a/tests/qemuxml2argvdata/net-virtio-network-portgroup.xml +++ b/tests/qemuxml2argvdata/net-virtio-network-portgroup.xml @@ -24,7 +24,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -43,7 +43,7 @@ - + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list