From db622081e0fa55b481da1fc7fb81279224a60f88 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Mon, 8 Jul 2024 13:04:13 +0200 Subject: [PATCH] vmx: Do not require all ID data for VMWare Distributed Switch Similarly to commit 2482801608b8 we can safely ignore connectionId, portId and portgroupId in both XML and VMX as they are only a blind pass-through between XML and VMX and an ethernet without such parameters was spotted in the wild. On top of that even our documentation says the whole VMWare Distrubuted Switch configuration is a best-effort. Resolves: https://issues.redhat.com/browse/RHEL-46099 Signed-off-by: Martin Kletzander Reviewed-by: Jiri Denemark --- src/conf/domain_conf.c | 11 ++++----- src/conf/schemas/domaincommon.rng | 24 ++++++++++++------- src/vmx/vmx.c | 24 ++++++++++++------- ...-portid.vmx => ethernet-vds-no-params.vmx} | 2 -- ...-portid.xml => ethernet-vds-no-params.xml} | 2 +- 5 files changed, 37 insertions(+), 26 deletions(-) rename tests/vmx2xmldata/{ethernet-vds-no-portid.vmx => ethernet-vds-no-params.vmx} (76%) rename tests/vmx2xmldata/{ethernet-vds-no-portid.xml => ethernet-vds-no-params.xml} (82%) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6080f4f90a5..bfef89e1bea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9536,15 +9536,14 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->data.vds.switch_id) < 0) return NULL; - if (virXMLPropLongLong(source_node, "portid", 0, VIR_XML_PROP_REQUIRED, - &def->data.vds.port_id, def->data.vds.port_id) < 0) + if (virXMLPropLongLong(source_node, "portid", 0, VIR_XML_PROP_NONE, + &def->data.vds.port_id, 0) < 0) return NULL; - if (!(def->data.vds.portgroup_id = virXMLPropStringRequired(source_node, "portgroupid"))) - return NULL; + def->data.vds.portgroup_id = virXMLPropString(source_node, "portgroupid"); - if (virXMLPropLongLong(source_node, "connectionid", 0, VIR_XML_PROP_REQUIRED, - &def->data.vds.connection_id, def->data.vds.connection_id) < 0) + if (virXMLPropLongLong(source_node, "connectionid", 0, VIR_XML_PROP_NONE, + &def->data.vds.connection_id, 0) < 0) return NULL; break; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index b163e4eece0..2d23fcf1237 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -3621,15 +3621,21 @@ - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index d082a076601..e5bc2d793c6 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2849,7 +2849,7 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def) if (virVMXGetConfigString(conf, portgroupId_name, &(*def)->data.vds.portgroup_id, - false) < 0 || + true) < 0 || virVMXGetConfigLong(conf, portId_name, &(*def)->data.vds.port_id, @@ -2859,7 +2859,7 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def) connectionId_name, &(*def)->data.vds.connection_id, 0, - false) < 0) + true) < 0) goto cleanup; } else if (connectionType == NULL && networkName == NULL) { (*def)->type = VIR_DOMAIN_NET_TYPE_NULL; @@ -3980,14 +3980,22 @@ virVMXFormatEthernet(virDomainNetDef *def, int controller, uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); - virBufferAsprintf(buffer, "ethernet%d.dvs.portId = \"%lld\"\n", - controller, def->data.vds.port_id); + if (def->data.vds.port_id) { + virBufferAsprintf(buffer, "ethernet%d.dvs.portId = \"%lld\"\n", + controller, def->data.vds.port_id); + } + + if (def->data.vds.portgroup_id) { + virBufferAsprintf(buffer, "ethernet%d.dvs.", controller); + virBufferEscapeString(buffer, "portgroupId = \"%s\"\n", + def->data.vds.portgroup_id); + } - virBufferAsprintf(buffer, "ethernet%d.dvs.", controller); - virBufferEscapeString(buffer, "portgroupId = \"%s\"\n", def->data.vds.portgroup_id); + if (def->data.vds.connection_id) { + virBufferAsprintf(buffer, "ethernet%d.dvs.connectionId = \"%lld\"\n", + controller, def->data.vds.connection_id); + } - virBufferAsprintf(buffer, "ethernet%d.dvs.connectionId = \"%lld\"\n", - controller, def->data.vds.connection_id); break; } diff --git a/tests/vmx2xmldata/ethernet-vds-no-portid.vmx b/tests/vmx2xmldata/ethernet-vds-no-params.vmx similarity index 76% rename from tests/vmx2xmldata/ethernet-vds-no-portid.vmx rename to tests/vmx2xmldata/ethernet-vds-no-params.vmx index 7761accb3ab..90afbdac30c 100644 --- a/tests/vmx2xmldata/ethernet-vds-no-portid.vmx +++ b/tests/vmx2xmldata/ethernet-vds-no-params.vmx @@ -5,6 +5,4 @@ ethernet0.virtualDev = "e1000e" ethernet0.addressType = "vpx" ethernet0.generatedAddress = "00:50:56:87:65:43" ethernet0.dvs.switchId = "50 34 26 b2 94 e9 3b 16-1d 68 87 bf ff 4a 54 40" -ethernet0.dvs.portgroupId = "dvportgroup-1285" -ethernet0.dvs.connectionId = "408217997" displayName = "test" diff --git a/tests/vmx2xmldata/ethernet-vds-no-portid.xml b/tests/vmx2xmldata/ethernet-vds-no-params.xml similarity index 82% rename from tests/vmx2xmldata/ethernet-vds-no-portid.xml rename to tests/vmx2xmldata/ethernet-vds-no-params.xml index 60fd9c99feb..0011ba471a5 100644 --- a/tests/vmx2xmldata/ethernet-vds-no-portid.xml +++ b/tests/vmx2xmldata/ethernet-vds-no-params.xml @@ -14,7 +14,7 @@ - +