From 6336fcd9f82e4d75f85ccfe22b9b8f5bb3df4fd4 Mon Sep 17 00:00:00 2001 From: Kristina Hanicova Date: Wed, 24 Mar 2021 17:47:44 +0100 Subject: [PATCH] XML update in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we accepted empty bridge name, because some old versions of VMWare Workstation did not put it into the config. But this doesn't make much sense - to have an interface type bridge with no name. We circumvented this problem by generating an empty name but that is equally wrong. Therefore, fill in missing bridge names (according to the documentation [1] the default bridge name is VMnet0) and error out if bridge name is missing. This partially reverts f246cdb5aca13ac9409b2ad43087e3078615ffcb 1: https://docs.vmware.com/en/VMware-Workstation-Player-for-Linux/16.0/com.vmware.player.linux.using.doc/GUID-BAFA66C3-81F0-4FCA-84C4-D9F7D258A60A.html Signed-off-by: Kristina Hanicova Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- src/vmx/vmx.c | 10 +++------- tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx | 2 ++ tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml | 4 ++-- tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx | 1 + tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +- tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.vmx | 2 ++ tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.xml | 4 ++-- tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx | 1 + tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 0b12b5dd7d..ecc2db7f43 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2801,11 +2801,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) STRCASEEQ(connectionType, "bridged") || STRCASEEQ(connectionType, "custom")) { if (virVMXGetConfigString(conf, networkName_name, &networkName, - true) < 0) + false) < 0) goto cleanup; - - if (!networkName) - networkName = g_strdup(""); } /* vmx:vnet -> def:data.ifname */ @@ -3911,9 +3908,8 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, /* def:type, def:ifname -> vmx:connectionType */ switch (def->type) { case VIR_DOMAIN_NET_TYPE_BRIDGE: - if (STRNEQ(def->data.bridge.brname, "")) - virBufferAsprintf(buffer, "ethernet%d.networkName = \"%s\"\n", - controller, def->data.bridge.brname); + virBufferAsprintf(buffer, "ethernet%d.networkName = \"%s\"\n", + controller, def->data.bridge.brname); if (def->ifname != NULL) { virBufferAsprintf(buffer, "ethernet%d.connectionType = \"custom\"\n", diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx index ef6af19b49..75583bdc53 100644 --- a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx +++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx @@ -12,9 +12,11 @@ sound.filename = "-1" sound.autodetect = "TRUE" usb.present = "TRUE" ethernet0.present = "TRUE" +ethernet0.networkName = "VMnet0" ethernet0.addressType = "generated" ethernet0.connectionType = "bridged" ethernet1.present = "TRUE" +ethernet1.networkName = "VMnet0" ethernet1.addressType = "generated" ethernet1.connectionType = "bridged" scsi0:0.present = "TRUE" diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml index 2dd46eb2b1..f6e9f4acdf 100644 --- a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml @@ -26,11 +26,11 @@ - + - +