]> xenbits.xensource.com Git - libvirt.git/commitdiff
vmx: Add support for dummy network interface
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 4 Aug 2022 08:27:40 +0000 (10:27 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 5 Aug 2022 12:37:54 +0000 (14:37 +0200)
Also map it to an ethernet without connectionType and networkName.

https://bugzilla.redhat.com/show_bug.cgi?id=1988211

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/vmx/vmx.c
tests/vmx2xmldata/ethernet-unmanaged-nodev.vmx [new file with mode: 0644]
tests/vmx2xmldata/ethernet-unmanaged-nodev.xml [new file with mode: 0644]
tests/vmx2xmltest.c
tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.vmx [new file with mode: 0644]
tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.xml [new file with mode: 0644]
tests/xml2vmxtest.c

index 95e2d4ae249c8b6274824e335321514f67a546ce..49eef12e3ea7c4ce1337a2e33e6e71760af07ce3 100644 (file)
@@ -2826,7 +2826,7 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def)
         STRCASEEQ(connectionType, "bridged") ||
         STRCASEEQ(connectionType, "custom")) {
         if (virVMXGetConfigString(conf, networkName_name, &networkName,
-                                  false) < 0)
+                                  true) < 0)
             goto cleanup;
     }
 
@@ -2837,7 +2837,20 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def)
     }
 
     /* Setup virDomainNetDef */
-    if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
+    if (connectionType == NULL && networkName == NULL) {
+        /*
+         * Having neither a connectionType nor a network name can mean two
+         * things:
+         *
+         * 1) there is no connection of that nic
+         * 2) the nic is connected to VMWare Distributed Switch
+         *
+         * But we do not see any difference between these and hence we report
+         * the closest thing to at least make virt-v2v and others work when they
+         * read the domain XML.
+         */
+        (*def)->type = VIR_DOMAIN_NET_TYPE_DUMMY;
+    } else if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
         (*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
         (*def)->data.bridge.brname = g_steal_pointer(&networkName);
     } else if (STRCASEEQ(connectionType, "hostonly")) {
@@ -3946,6 +3959,9 @@ virVMXFormatEthernet(virDomainNetDef *def, int controller,
                           controller);
         break;
 
+    case VIR_DOMAIN_NET_TYPE_DUMMY:
+        break;
+
     case VIR_DOMAIN_NET_TYPE_ETHERNET:
     case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
     case VIR_DOMAIN_NET_TYPE_SERVER:
@@ -3957,7 +3973,6 @@ virVMXFormatEthernet(virDomainNetDef *def, int controller,
     case VIR_DOMAIN_NET_TYPE_HOSTDEV:
     case VIR_DOMAIN_NET_TYPE_UDP:
     case VIR_DOMAIN_NET_TYPE_VDPA:
-    case VIR_DOMAIN_NET_TYPE_DUMMY:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type '%s'"),
                        virDomainNetTypeToString(def->type));
         return -1;
diff --git a/tests/vmx2xmldata/ethernet-unmanaged-nodev.vmx b/tests/vmx2xmldata/ethernet-unmanaged-nodev.vmx
new file mode 100644 (file)
index 0000000..6e08536
--- /dev/null
@@ -0,0 +1,7 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.virtualDev = "e1000e"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
+displayName = "test"
diff --git a/tests/vmx2xmldata/ethernet-unmanaged-nodev.xml b/tests/vmx2xmldata/ethernet-unmanaged-nodev.xml
new file mode 100644 (file)
index 0000000..a312430
--- /dev/null
@@ -0,0 +1,23 @@
+<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='dummy'>
+      <mac address='00:50:56:87:65:43' type='generated'/>
+      <model type='e1000e'/>
+    </interface>
+    <video>
+      <model type='vmvga' vram='4096' primary='yes'/>
+    </video>
+  </devices>
+</domain>
index dbd771017bf39992154dee4a0f56301bf7b87a38..e08079512b531c7aeb36062a1f13deba5ff7da6f 100644 (file)
@@ -236,6 +236,7 @@ mymain(void)
     DO_TEST("ethernet-static");
     DO_TEST("ethernet-vpx");
     DO_TEST("ethernet-other");
+    DO_TEST("ethernet-unmanaged-nodev");
 
     DO_TEST("serial-file");
     DO_TEST("serial-device");
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.vmx
new file mode 100644 (file)
index 0000000..41ba296
--- /dev/null
@@ -0,0 +1,13 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "ethernet-vpx"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
+ethernet0.present = "true"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.xml b/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.xml
new file mode 100644 (file)
index 0000000..a071b2f
--- /dev/null
@@ -0,0 +1,13 @@
+<domain type='vmware'>
+  <name>ethernet-vpx</name>
+  <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+  <memory unit='KiB'>4096</memory>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <interface type='dummy'>
+      <mac address='00:50:56:87:65:43'/>
+    </interface>
+  </devices>
+</domain>
index 1a7f2e4f3390df336f23a9ec17b00e7352950c5d..0ea213d5d5cd80073e6b95ddaaf83edd8f30795d 100644 (file)
@@ -225,6 +225,8 @@ mymain(void)
     DO_TEST("ethernet-other", "ethernet-other", 4);
     DO_TEST("ethernet-mac-type", "ethernet-mac-type", 4);
 
+    DO_TEST("ethernet-unmanaged-nodev", "ethernet-unmanaged-nodev", 4);
+
     DO_TEST("serial-file", "serial-file", 4);
     DO_TEST("serial-device", "serial-device", 4);
     DO_TEST("serial-pipe", "serial-pipe", 4);