diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 823d5dfc9caeda7e6348e6ea1c470fb230290da0..910bb0eb69150c90ddf8419c7d42724ab1b8a7a9 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 0000000000000000000000000000000000000000..701c3851fb05ce43324ebfa31cdf3e0ce8555630 --- /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 0000000000000000000000000000000000000000..8631049e8a2fb81bd53826fab44c8810eccd90c1 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml @@ -0,0 +1,21 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + 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 0000000000000000000000000000000000000000..a25f3de64ab75ccc787688f86ec8419617c8dc35 --- /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 0000000000000000000000000000000000000000..71bf9e88d4e564225ab30f9f66ca4d1dbd50ee89 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml @@ -0,0 +1,35 @@ + + debian6 + 00000000-0000-0000-0000-000000000000 + 524288 + 524288 + 1 + + hvm + + + destroy + restart + destroy + + + + +
+ + + + +
+ + + + + + + + + + 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 0000000000000000000000000000000000000000..6e078d4d92eea243ff1f5b153e447b7e12e23cef --- /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 0000000000000000000000000000000000000000..d31020413a402ad18c68d3e4b9fb36ac0d74b9bf --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml @@ -0,0 +1,36 @@ + + debian6 + 00000000-0000-0000-0000-000000000000 + 524288 + 524288 + 1 + + hvm + + + destroy + restart + destroy + + + + +
+ + + + +
+ + + + + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 3c566f898624db698cd846a96c0781fe6fb849e8..35740ea423d044815cd6fe7f7e523afcfa3f5408 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 0000000000000000000000000000000000000000..0ee0f034f7727c12b56b0487f1aef1f3d3c8f2d0 --- /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 0000000000000000000000000000000000000000..1df74f4eaf4eeb231dce255e836162443c332d47 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-nat.xml @@ -0,0 +1,13 @@ + + ethernet-nat + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + 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 0000000000000000000000000000000000000000..539a371237b992fd3ccd8bed8cdb2276f0b1dd63 --- /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 0000000000000000000000000000000000000000..eab25d8e58ed1a6d6e146de7537c532b3e942363 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml @@ -0,0 +1,29 @@ + + dcd9c436-4825-4fc0-8fa1-14444b0f0569 + dcd9c436-4825-4fc0-8fa1-14444b0f0569 + 524288 + 524288 + 1 + + hvm + + + destroy + restart + destroy + + + + +
+ + + + + + + + + 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 0000000000000000000000000000000000000000..7035ac31602d428ba0c723dabb8373df56b2885c --- /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 0000000000000000000000000000000000000000..30fb76c818a1b27fd9fe808f452684bf136e17cc --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml @@ -0,0 +1,30 @@ + + dcd9c436-4825-4fc0-8fa1-14444b0f0569 + dcd9c436-4825-4fc0-8fa1-14444b0f0569 + 524288 + 524288 + 1 + + hvm + + + destroy + restart + destroy + + + + +
+ + + + + + + + + + diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index f4e4ed6b60d37eb4a917a29f5f711b85e6700b86..60a24b2a6bb10b5389de62b5ce196aa8464b1b8b 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);