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(a)redhat.com>
---
src/vmx/vmx.c | 21 ++++++++++++++---
.../vmx2xmldata/ethernet-unmanaged-nodev.vmx | 7 ++++++
.../vmx2xmldata/ethernet-unmanaged-nodev.xml | 23 +++++++++++++++++++
tests/vmx2xmltest.c | 1 +
.../xml2vmx-ethernet-unmanaged-nodev.vmx | 13 +++++++++++
.../xml2vmx-ethernet-unmanaged-nodev.xml | 13 +++++++++++
tests/xml2vmxtest.c | 2 ++
7 files changed, 77 insertions(+), 3 deletions(-)
create mode 100644 tests/vmx2xmldata/ethernet-unmanaged-nodev.vmx
create mode 100644 tests/vmx2xmldata/ethernet-unmanaged-nodev.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.xml
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 95e2d4ae249c..49eef12e3ea7 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -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
index 000000000000..6e08536337f7
--- /dev/null
+++ b/tests/vmx2xmldata/ethernet-unmanaged-nodev.vmx
@@ -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
index 000000000000..a31243033785
--- /dev/null
+++ b/tests/vmx2xmldata/ethernet-unmanaged-nodev.xml
@@ -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>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index dbd771017bf3..e08079512b53 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -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
index 000000000000..41ba2967c08f
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.vmx
@@ -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
index 000000000000..a071b2f21513
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-unmanaged-nodev.xml
@@ -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>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 1a7f2e4f3390..0ea213d5d5cd 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -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);
--
2.35.1