+ 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 association
+ 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 4bd75e3055..3661f0a556 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2591,6 +2591,11 @@
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 85b374572c..fe8001cb4f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11399,6 +11399,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_AUTOFREE(char *) type = NULL;
VIR_AUTOFREE(char *) network = NULL;
VIR_AUTOFREE(char *) portgroup = NULL;
+ VIR_AUTOFREE(char *) portid = NULL;
VIR_AUTOFREE(char *) bridge = NULL;
VIR_AUTOFREE(char *) dev = NULL;
VIR_AUTOFREE(char *) ifname = NULL;
@@ -11476,6 +11477,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
virXMLNodeNameEqual(cur, "source")) {
network = virXMLPropString(cur, "network");
portgroup = virXMLPropString(cur, "portgroup");
+ if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
+ portid = virXMLPropString(cur, "portid");
} else if (!internal &&
def->type == VIR_DOMAIN_NET_TYPE_INTERNAL &&
virXMLNodeNameEqual(cur, "source")) {
@@ -11689,6 +11692,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
"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);
@@ -24977,6 +24987,11 @@ virDomainActualNetDefContentsFormat(virBufferPtr buf,
def->data.network.name);
virBufferEscapeString(buf, " portgroup='%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='%s'", uuidstr);
+ }
}
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
@@ -25280,6 +25295,12 @@ virDomainNetDefFormat(virBufferPtr buf,
def->data.network.name);
virBufferEscapeString(buf, " portgroup='%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='%s'", portidstr);
+ }
sourceLines++;
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6ba0643cd1..467b72a977 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -968,6 +968,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
@@ -975,6 +976,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/tests/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 @@
-
+
--
GitLab