This patch adds support for vmx files with empty networkName values (which is the case for vmx generated by Workstation). It also adds support for vmx containing NATed network interfaces. Update test suite accordingly --- src/vmx/vmx.c | 39 ++++++++++++------ tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx | 6 +++ tests/vmx2xmldata/vmx2xml-ethernet-nat.xml | 21 ++++++++++ tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx | 52 ++++++++++++++++++++++++ tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 35 ++++++++++++++++ tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx | 52 ++++++++++++++++++++++++ tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 36 ++++++++++++++++ tests/vmx2xmltest.c | 4 ++ tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx | 14 ++++++ tests/xml2vmxdata/xml2vmx-ethernet-nat.xml | 13 ++++++ tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx | 22 ++++++++++ tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml | 29 +++++++++++++ tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx | 22 ++++++++++ tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml | 30 ++++++++++++++ tests/xml2vmxtest.c | 4 ++ 15 files changed, 366 insertions(+), 13 deletions(-) create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.xml create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.xml create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 823d5df..910bb0e 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2418,12 +2418,20 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) } /* vmx:networkName -> def:data.bridge.brname */ - if ((connectionType == NULL || - STRCASEEQ(connectionType, "bridged") || - STRCASEEQ(connectionType, "custom")) && - virVMXGetConfigString(conf, networkName_name, &networkName, - false) < 0) { - goto cleanup; + if (connectionType == NULL || + STRCASEEQ(connectionType, "bridged") || + STRCASEEQ(connectionType, "custom")) { + if (virVMXGetConfigString(conf, networkName_name, &networkName, + true) < 0) + goto cleanup; + + if (networkName == NULL) { + networkName = strdup(""); + if (networkName == NULL) { + virReportOOMError(); + goto cleanup; + } + } } /* vmx:vnet -> def:data.ifname */ @@ -2447,11 +2455,10 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) connectionType, connectionType_name); goto cleanup; } else if (STRCASEEQ(connectionType, "nat")) { - /* FIXME */ - VMX_ERROR(VIR_ERR_INTERNAL_ERROR, - _("No yet handled value '%s' for VMX entry '%s'"), - connectionType, connectionType_name); - goto cleanup; + (*def)->type = VIR_DOMAIN_NET_TYPE_USER; + (*def)->model = virtualDev; + + virtualDev = NULL; } else if (STRCASEEQ(connectionType, "custom")) { (*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE; (*def)->model = virtualDev; @@ -3533,8 +3540,9 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, /* def:type, def:ifname -> vmx:connectionType */ switch (def->type) { case VIR_DOMAIN_NET_TYPE_BRIDGE: - virBufferAsprintf(buffer, "ethernet%d.networkName = \"%s\"\n", - controller, def->data.bridge.brname); + if (STRNEQ(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", @@ -3548,6 +3556,11 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, break; + case VIR_DOMAIN_NET_TYPE_USER: + virBufferAsprintf(buffer, "ethernet%d.connectionType = \"nat\"\n", + controller); + break; + default: VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type '%s'"), virDomainNetTypeToString(def->type)); diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx new file mode 100644 index 0000000..701c385 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx @@ -0,0 +1,6 @@ +config.version = "8" +virtualHW.version = "4" +ethernet0.present = "true" +ethernet0.connectionType = "nat" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:11:22:33" diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml b/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml new file mode 100644 index 0000000..8631049 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml @@ -0,0 +1,21 @@ +<domain type='vmware'> + <uuid>00000000-0000-0000-0000-000000000000</uuid> + <memory>32768</memory> + <currentMemory>32768</currentMemory> + <vcpu>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='user'> + <mac address='00:50:56:11:22:33'/> + </interface> + <video> + <model type='vmvga' vram='4096'/> + </video> + </devices> +</domain> diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx new file mode 100644 index 0000000..a25f3de --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx @@ -0,0 +1,52 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "8" +virtualHW.productCompatibility = "hosted" +displayName = "debian6" +guestOS = "debian6-64" +memsize = "512" +numvcpus = "1" +vcpu.hotadd = "TRUE" +scsi0.present = "TRUE" +scsi0.virtualDev = "lsilogic" +scsi0:0.present = "TRUE" +scsi0:0.fileName = "/data/vmware/disk.vmdk" +ide1:0.present = "TRUE" +ide1:0.fileName = "/usr/lib/vmware/isoimages/linux.iso" +ide1:0.deviceType = "cdrom-image" +floppy0.startConnected = "FALSE" +floppy0.fileName = "" +floppy0.autodetect = "TRUE" +ethernet0.present = "TRUE" +ethernet0.connectionType = "nat" +ethernet0.virtualDev = "e1000" +ethernet0.wakeOnPcktRcv = "FALSE" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:2F:D3:46" +usb.present = "TRUE" +usb.vbluetooth.startConnected = "TRUE" +ehci.present = "TRUE" +sound.present = "TRUE" +sound.startConnected = "FALSE" +sound.fileName = "-1" +sound.autodetect = "TRUE" +pciBridge0.present = "TRUE" +pciBridge4.present = "TRUE" +pciBridge4.virtualDev = "pcieRootPort" +pciBridge4.functions = "8" +pciBridge5.present = "TRUE" +pciBridge5.virtualDev = "pcieRootPort" +pciBridge5.functions = "8" +pciBridge6.present = "TRUE" +pciBridge6.virtualDev = "pcieRootPort" +pciBridge6.functions = "8" +pciBridge7.present = "TRUE" +pciBridge7.virtualDev = "pcieRootPort" +pciBridge7.functions = "8" +vmci0.present = "TRUE" +hpet0.present = "TRUE" +powerType.powerOff = "hard" +powerType.powerOn = "hard" +powerType.suspend = "hard" +powerType.reset = "hard" +serial0.present = "FALSE" diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml new file mode 100644 index 0000000..71bf9e8 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml @@ -0,0 +1,35 @@ +<domain type='vmware'> + <name>debian6</name> + <uuid>00000000-0000-0000-0000-000000000000</uuid> + <memory>524288</memory> + <currentMemory>524288</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/data/vmware/disk.vmdk'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <disk type='file' device='cdrom'> + <source file='/usr/lib/vmware/isoimages/linux.iso'/> + <target dev='hdc' bus='ide'/> + <address type='drive' controller='0' bus='1' unit='0'/> + </disk> + <controller type='scsi' index='0' model='lsilogic'/> + <controller type='ide' index='0'/> + <interface type='user'> + <mac address='00:50:56:2f:d3:46'/> + <model type='e1000'/> + </interface> + <video> + <model type='vmvga' vram='4096'/> + </video> + </devices> +</domain> diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx new file mode 100644 index 0000000..6e078d4 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx @@ -0,0 +1,52 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "8" +virtualHW.productCompatibility = "hosted" +displayName = "debian6" +guestOS = "debian6-64" +memsize = "512" +numvcpus = "1" +vcpu.hotadd = "TRUE" +scsi0.present = "TRUE" +scsi0.virtualDev = "lsilogic" +scsi0:0.present = "TRUE" +scsi0:0.fileName = "/data/vmware/disk.vmdk" +ide1:0.present = "TRUE" +ide1:0.fileName = "/usr/lib/vmware/isoimages/linux.iso" +ide1:0.deviceType = "cdrom-image" +floppy0.startConnected = "FALSE" +floppy0.fileName = "" +floppy0.autodetect = "TRUE" +ethernet0.present = "TRUE" +ethernet0.connectionType = "bridged" +ethernet0.virtualDev = "e1000" +ethernet0.wakeOnPcktRcv = "FALSE" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:2F:D3:46" +usb.present = "TRUE" +usb.vbluetooth.startConnected = "TRUE" +ehci.present = "TRUE" +sound.present = "TRUE" +sound.startConnected = "FALSE" +sound.fileName = "-1" +sound.autodetect = "TRUE" +pciBridge0.present = "TRUE" +pciBridge4.present = "TRUE" +pciBridge4.virtualDev = "pcieRootPort" +pciBridge4.functions = "8" +pciBridge5.present = "TRUE" +pciBridge5.virtualDev = "pcieRootPort" +pciBridge5.functions = "8" +pciBridge6.present = "TRUE" +pciBridge6.virtualDev = "pcieRootPort" +pciBridge6.functions = "8" +pciBridge7.present = "TRUE" +pciBridge7.virtualDev = "pcieRootPort" +pciBridge7.functions = "8" +vmci0.present = "TRUE" +hpet0.present = "TRUE" +powerType.powerOff = "hard" +powerType.powerOn = "hard" +powerType.suspend = "hard" +powerType.reset = "hard" +serial0.present = "FALSE" diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml new file mode 100644 index 0000000..d310204 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml @@ -0,0 +1,36 @@ +<domain type='vmware'> + <name>debian6</name> + <uuid>00000000-0000-0000-0000-000000000000</uuid> + <memory>524288</memory> + <currentMemory>524288</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/data/vmware/disk.vmdk'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <disk type='file' device='cdrom'> + <source file='/usr/lib/vmware/isoimages/linux.iso'/> + <target dev='hdc' bus='ide'/> + <address type='drive' controller='0' bus='1' unit='0'/> + </disk> + <controller type='scsi' index='0' model='lsilogic'/> + <controller type='ide' index='0'/> + <interface type='bridge'> + <mac address='00:50:56:2f:d3:46'/> + <source bridge=''/> + <model type='e1000'/> + </interface> + <video> + <model type='vmvga' vram='4096'/> + </video> + </devices> +</domain> diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 3c566f8..35740ea 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -245,6 +245,7 @@ mymain(void) DO_TEST("ethernet-custom", "ethernet-custom"); DO_TEST("ethernet-bridged", "ethernet-bridged"); + DO_TEST("ethernet-nat", "ethernet-nat"); DO_TEST("ethernet-generated", "ethernet-generated"); DO_TEST("ethernet-static", "ethernet-static"); @@ -275,6 +276,9 @@ mymain(void) DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3"); DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4"); + DO_TEST("ws-in-the-wild-1", "ws-in-the-wild-1"); + DO_TEST("ws-in-the-wild-2", "ws-in-the-wild-2"); + DO_TEST("annotation", "annotation"); DO_TEST("smbios", "smbios"); diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx new file mode 100644 index 0000000..0ee0f03 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx @@ -0,0 +1,14 @@ +.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-nat" +memsize = "4" +numvcpus = "1" +floppy0.present = "false" +floppy1.present = "false" +ethernet0.present = "true" +ethernet0.connectionType = "nat" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:11:22:33" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-nat.xml b/tests/xml2vmxdata/xml2vmx-ethernet-nat.xml new file mode 100644 index 0000000..1df74f4 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-nat.xml @@ -0,0 +1,13 @@ +<domain type='vmware'> + <name>ethernet-nat</name> + <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid> + <memory>4096</memory> + <os> + <type>hvm</type> + </os> + <devices> + <interface type='user'> + <mac address='00:50:56:11:22:33'/> + </interface> + </devices> +</domain> diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx new file mode 100644 index 0000000..539a371 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx @@ -0,0 +1,22 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "8" +guestOS = "other-64" +uuid.bios = "dc d9 c4 36 48 25 4f c0-8f a1 14 44 4b 0f 05 69" +displayName = "dcd9c436-4825-4fc0-8fa1-14444b0f0569" +memsize = "512" +numvcpus = "1" +scsi0.present = "true" +scsi0.virtualDev = "lsilogic" +scsi0:0.present = "true" +scsi0:0.deviceType = "scsi-hardDisk" +scsi0:0.fileName = "/data/vmware/disk.vmdk" +floppy0.present = "false" +floppy1.present = "false" +ethernet0.present = "true" +ethernet0.virtualDev = "e1000" +ethernet0.connectionType = "nat" +ethernet0.addressType = "static" +ethernet0.address = "00:90:B9:DC:EA:81" +ethernet0.checkMACAddress = "false" +svga.vramSize = "4194304" diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml new file mode 100644 index 0000000..eab25d8 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml @@ -0,0 +1,29 @@ +<domain type='vmware'> + <name>dcd9c436-4825-4fc0-8fa1-14444b0f0569</name> + <uuid>dcd9c436-4825-4fc0-8fa1-14444b0f0569</uuid> + <memory>524288</memory> + <currentMemory>524288</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/data/vmware/disk.vmdk'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='scsi' index='0' model='lsilogic'/> + <interface type='user'> + <mac address='00:90:b9:dc:ea:81'/> + <model type='e1000'/> + </interface> + <video> + <model type='vmvga' vram='4096'/> + </video> + </devices> +</domain> diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx new file mode 100644 index 0000000..7035ac3 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx @@ -0,0 +1,22 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "8" +guestOS = "other-64" +uuid.bios = "dc d9 c4 36 48 25 4f c0-8f a1 14 44 4b 0f 05 69" +displayName = "dcd9c436-4825-4fc0-8fa1-14444b0f0569" +memsize = "512" +numvcpus = "1" +scsi0.present = "true" +scsi0.virtualDev = "lsilogic" +scsi0:0.present = "true" +scsi0:0.deviceType = "scsi-hardDisk" +scsi0:0.fileName = "/data/vmware/disk.vmdk" +floppy0.present = "false" +floppy1.present = "false" +ethernet0.present = "true" +ethernet0.virtualDev = "e1000" +ethernet0.connectionType = "bridged" +ethernet0.addressType = "static" +ethernet0.address = "00:90:B9:DC:EA:81" +ethernet0.checkMACAddress = "false" +svga.vramSize = "4194304" diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml new file mode 100644 index 0000000..30fb76c --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml @@ -0,0 +1,30 @@ +<domain type='vmware'> + <name>dcd9c436-4825-4fc0-8fa1-14444b0f0569</name> + <uuid>dcd9c436-4825-4fc0-8fa1-14444b0f0569</uuid> + <memory>524288</memory> + <currentMemory>524288</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <source file='/data/vmware/disk.vmdk'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' unit='0'/> + </disk> + <controller type='scsi' index='0' model='lsilogic'/> + <interface type='bridge'> + <mac address='00:90:b9:dc:ea:81'/> + <source bridge=''/> + <model type='e1000'/> + </interface> + <video> + <model type='vmvga' vram='4096'/> + </video> + </devices> +</domain> diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index f4e4ed6..60a24b2 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -260,6 +260,7 @@ mymain(void) DO_TEST("ethernet-custom", "ethernet-custom", 4); DO_TEST("ethernet-bridged", "ethernet-bridged", 4); + DO_TEST("ethernet-nat", "ethernet-nat", 4); DO_TEST("ethernet-generated", "ethernet-generated", 4); DO_TEST("ethernet-static", "ethernet-static", 4); @@ -287,6 +288,9 @@ mymain(void) DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", 4); DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", 4); + DO_TEST("ws-in-the-wild-1", "ws-in-the-wild-1", 8); + DO_TEST("ws-in-the-wild-2", "ws-in-the-wild-2", 8); + DO_TEST("annotation", "annotation", 4); DO_TEST("smbios", "smbios", 4); -- 1.7.9 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list