]> xenbits.xensource.com Git - libvirt.git/commitdiff
vmx: Do not require all ID data for VMWare Distributed Switch
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 8 Jul 2024 11:04:13 +0000 (13:04 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 8 Jul 2024 13:18:22 +0000 (15:18 +0200)
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 <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/conf/domain_conf.c
src/conf/schemas/domaincommon.rng
src/vmx/vmx.c
tests/vmx2xmldata/ethernet-vds-no-params.vmx [new file with mode: 0644]
tests/vmx2xmldata/ethernet-vds-no-params.xml [new file with mode: 0644]
tests/vmx2xmldata/ethernet-vds-no-portid.vmx [deleted file]
tests/vmx2xmldata/ethernet-vds-no-portid.xml [deleted file]

index 6080f4f90a540dee06bea2a203242b026e1449bf..bfef89e1beae7b4bd4f24f4c1d6fdbb9511b545c 100644 (file)
@@ -9593,15 +9593,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;
index b163e4eece0939ab2554bfb6ac06a01bbbf8e204..2d23fcf12375a2c800626cd8c658c998b36808d3 100644 (file)
               <attribute name="switchid">
                 <ref name="UUID"/>
               </attribute>
-              <attribute name="portid">
-                <data type="long"/>
-              </attribute>
-              <attribute name="portgroupid">
-                <data type="string"/>
-              </attribute>
-              <attribute name="connectionid">
-                <data type="long"/>
-              </attribute>
+              <optional>
+                <attribute name="portid">
+                  <data type="long"/>
+                </attribute>
+              </optional>
+              <optional>
+                <attribute name="portgroupid">
+                  <data type="string"/>
+                </attribute>
+              </optional>
+              <optional>
+                <attribute name="connectionid">
+                  <data type="long"/>
+                </attribute>
+              </optional>
             </element>
             <ref name="interface-options"/>
           </interleave>
index d082a0766010e0f54800c492784d9c88e2576afb..e5bc2d793c6631cf34550ba530f85bc1c7eb77c3 100644 (file)
@@ -2896,7 +2896,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,
@@ -2906,7 +2906,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;
@@ -4038,14 +4038,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-params.vmx b/tests/vmx2xmldata/ethernet-vds-no-params.vmx
new file mode 100644 (file)
index 0000000..90afbda
--- /dev/null
@@ -0,0 +1,8 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+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"
+displayName = "test"
diff --git a/tests/vmx2xmldata/ethernet-vds-no-params.xml b/tests/vmx2xmldata/ethernet-vds-no-params.xml
new file mode 100644 (file)
index 0000000..0011ba4
--- /dev/null
@@ -0,0 +1,24 @@
+<domain type='vmware'>
+  <name>test</name>
+  <uuid>00000000-0000-0000-0000-000000000000</uuid>
+  <memory unit='KiB'>32768</memory>
+  <currentMemory unit='KiB'>32768</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <interface type='vds'>
+      <mac address='00:50:56:87:65:43' type='generated'/>
+      <source switchid='503426b2-94e9-3b16-1d68-87bfff4a5440'/>
+      <model type='e1000e'/>
+    </interface>
+    <video>
+      <model type='vmvga' vram='4096' primary='yes'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmldata/ethernet-vds-no-portid.vmx b/tests/vmx2xmldata/ethernet-vds-no-portid.vmx
deleted file mode 100644 (file)
index 7761acc..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-config.version = "8"
-virtualHW.version = "4"
-ethernet0.present = "true"
-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-portid.xml
deleted file mode 100644 (file)
index 60fd9c9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<domain type='vmware'>
-  <name>test</name>
-  <uuid>00000000-0000-0000-0000-000000000000</uuid>
-  <memory unit='KiB'>32768</memory>
-  <currentMemory unit='KiB'>32768</currentMemory>
-  <vcpu placement='static'>1</vcpu>
-  <os>
-    <type arch='i686'>hvm</type>
-  </os>
-  <clock offset='utc'/>
-  <on_poweroff>destroy</on_poweroff>
-  <on_reboot>restart</on_reboot>
-  <on_crash>destroy</on_crash>
-  <devices>
-    <interface type='vds'>
-      <mac address='00:50:56:87:65:43' type='generated'/>
-      <source switchid='503426b2-94e9-3b16-1d68-87bfff4a5440' portid='0' portgroupid='dvportgroup-1285' connectionid='408217997'/>
-      <model type='e1000e'/>
-    </interface>
-    <video>
-      <model type='vmvga' vram='4096' primary='yes'/>
-    </video>
-  </devices>
-</domain>