vmx: Better Workstation vmx handling

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
This commit is contained in:
Jean-Baptiste Rouault 2012-02-23 10:34:45 +01:00 committed by Matthias Bolte
parent cff5573da2
commit f246cdb5ac
15 changed files with 366 additions and 13 deletions

View File

@ -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));

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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");

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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);