mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 02:25:18 +00:00
esx: Make the conf parser compare names case insensitive in VMX mode
The keys of entries in a VMX file are case insensitive. Both scsi0:1.fileName and scsi0:1.filename are valid. Therefore, make the conf parser compare names case insensitive in VMX mode to accept every capitalization variation. Also add test cases for this.
This commit is contained in:
parent
f66636e3ca
commit
5edaf95599
@ -831,7 +831,10 @@ virConfGetValue(virConfPtr conf, const char *setting)
|
||||
|
||||
cur = conf->entries;
|
||||
while (cur != NULL) {
|
||||
if ((cur->name != NULL) && (STREQ(cur->name, setting)))
|
||||
if ((cur->name != NULL) &&
|
||||
((conf->flags & VIR_CONF_FLAG_VMX_FORMAT &&
|
||||
STRCASEEQ(cur->name, setting)) ||
|
||||
STREQ(cur->name, setting)))
|
||||
return(cur->value);
|
||||
cur = cur->next;
|
||||
}
|
||||
|
51
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
Normal file
51
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
Normal file
@ -0,0 +1,51 @@
|
||||
CONFIG.VERSION = "8"
|
||||
VIRTUALHW.VERSION = "4"
|
||||
FLOPPY0.PRESENT = "FALSE"
|
||||
NVRAM = "FEDORA11.NVRAM"
|
||||
DEPLOYMENTPLATFORM = "WINDOWS"
|
||||
VIRTUALHW.PRODUCTCOMPATIBILITY = "HOSTED"
|
||||
TOOLS.UPGRADE.POLICY = "USEGLOBAL"
|
||||
POWERTYPE.POWEROFF = "DEFAULT"
|
||||
POWERTYPE.POWERON = "DEFAULT"
|
||||
POWERTYPE.SUSPEND = "DEFAULT"
|
||||
POWERTYPE.RESET = "DEFAULT"
|
||||
|
||||
DISPLAYNAME = "FEDORA11"
|
||||
EXTENDEDCONFIGFILE = "FEDORA11.VMXF"
|
||||
|
||||
SCSI0.PRESENT = "TRUE"
|
||||
SCSI0.SHAREDBUS = "NONE"
|
||||
SCSI0.VIRTUALDEV = "LSILOGIC"
|
||||
MEMSIZE = "1024"
|
||||
SCSI0:0.PRESENT = "TRUE"
|
||||
SCSI0:0.FILENAME = "FEDORA11.vmdk"
|
||||
SCSI0:0.DEVICETYPE = "SCSI-HARDDISK"
|
||||
IDE0:0.PRESENT = "TRUE"
|
||||
IDE0:0.CLIENTDEVICE = "TRUE"
|
||||
IDE0:0.DEVICETYPE = "CDROM-RAW"
|
||||
IDE0:0.STARTCONNECTED = "FALSE"
|
||||
ETHERNET0.PRESENT = "TRUE"
|
||||
ETHERNET0.NETWORKNAME = "VM NETWORK"
|
||||
ETHERNET0.ADDRESSTYPE = "VPX"
|
||||
ETHERNET0.GENERATEDADDRESS = "00:50:56:91:48:C7"
|
||||
CHIPSET.ONLINESTANDBY = "FALSE"
|
||||
GUESTOSALTNAME = "RED HAT ENTERPRISE LINUX 5 (32-BIT)"
|
||||
GUESTOS = "RHEL5"
|
||||
UUID.BIOS = "50 11 5E 16 9B DC 49 D7-F1 71 53 C4 D7 F9 17 10"
|
||||
SNAPSHOT.ACTION = "KEEP"
|
||||
SCHED.CPU.MIN = "0"
|
||||
SCHED.CPU.UNITS = "MHZ"
|
||||
SCHED.CPU.SHARES = "NORMAL"
|
||||
SCHED.MEM.MINSIZE = "0"
|
||||
SCHED.MEM.SHARES = "NORMAL"
|
||||
TOOLSCRIPTS.AFTERPOWERON = "TRUE"
|
||||
TOOLSCRIPTS.AFTERRESUME = "TRUE"
|
||||
TOOLSCRIPTS.BEFORESUSPEND = "TRUE"
|
||||
TOOLSCRIPTS.BEFOREPOWEROFF = "TRUE"
|
||||
|
||||
SCSI0:0.REDO = ""
|
||||
TOOLS.SYNCTIME = "FALSE"
|
||||
UUID.LOCATION = "56 4D B5 06 A2 BD FB EB-AE 86 F7 D8 49 27 D0 C4"
|
||||
SCHED.CPU.MAX = "UNLIMITED"
|
||||
SCHED.SWAP.DERIVEDNAME = "/VMFS/VOLUMES/498076B2-02796C1A-EF5B-000AE484A6A3/FEDORA11/FEDORA11-7DE040D8.VSWP"
|
||||
TOOLS.REMINDINSTALL = "TRUE"
|
25
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
Normal file
25
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<domain type='vmware'>
|
||||
<name>FEDORA11</name>
|
||||
<uuid>50115e16-9bdc-49d7-f171-53c4d7f91710</uuid>
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</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>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='LSILOGIC'/>
|
||||
<source file='[datastore] directory/FEDORA11.vmdk'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:50:56:91:48:c7'/>
|
||||
<source bridge='VM NETWORK'/>
|
||||
</interface>
|
||||
</devices>
|
||||
</domain>
|
51
tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
Normal file
51
tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
Normal file
@ -0,0 +1,51 @@
|
||||
config.version = "8"
|
||||
virtualhw.version = "4"
|
||||
floppy0.present = "false"
|
||||
nvram = "fedora11.nvram"
|
||||
deploymentplatform = "windows"
|
||||
virtualhw.productcompatibility = "hosted"
|
||||
tools.upgrade.policy = "useglobal"
|
||||
powertype.poweroff = "default"
|
||||
powertype.poweron = "default"
|
||||
powertype.suspend = "default"
|
||||
powertype.reset = "default"
|
||||
|
||||
displayname = "fedora11"
|
||||
extendedconfigfile = "fedora11.vmxf"
|
||||
|
||||
scsi0.present = "true"
|
||||
scsi0.sharedbus = "none"
|
||||
scsi0.virtualdev = "lsilogic"
|
||||
memsize = "1024"
|
||||
scsi0:0.present = "true"
|
||||
scsi0:0.filename = "fedora11.vmdk"
|
||||
scsi0:0.devicetype = "scsi-harddisk"
|
||||
ide0:0.present = "true"
|
||||
ide0:0.clientdevice = "true"
|
||||
ide0:0.devicetype = "cdrom-raw"
|
||||
ide0:0.startconnected = "false"
|
||||
ethernet0.present = "true"
|
||||
ethernet0.networkname = "vm network"
|
||||
ethernet0.addresstype = "vpx"
|
||||
ethernet0.generatedaddress = "00:50:56:91:48:c7"
|
||||
chipset.onlinestandby = "false"
|
||||
guestosaltname = "red hat enterprise linux 5 (32-bit)"
|
||||
guestos = "rhel5"
|
||||
uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
|
||||
snapshot.action = "keep"
|
||||
sched.cpu.min = "0"
|
||||
sched.cpu.units = "mhz"
|
||||
sched.cpu.shares = "normal"
|
||||
sched.mem.minsize = "0"
|
||||
sched.mem.shares = "normal"
|
||||
toolscripts.afterpoweron = "true"
|
||||
toolscripts.afterresume = "true"
|
||||
toolscripts.beforesuspend = "true"
|
||||
toolscripts.beforepoweroff = "true"
|
||||
|
||||
scsi0:0.redo = ""
|
||||
tools.synctime = "false"
|
||||
uuid.location = "56 4d b5 06 a2 bd fb eb-ae 86 f7 d8 49 27 d0 c4"
|
||||
sched.cpu.max = "unlimited"
|
||||
sched.swap.derivedname = "/vmfs/volumes/498076b2-02796c1a-ef5b-000ae484a6a3/fedora11/fedora11-7de040d8.vswp"
|
||||
tools.remindinstall = "true"
|
25
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
Normal file
25
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<domain type='vmware'>
|
||||
<name>fedora11</name>
|
||||
<uuid>50115e16-9bdc-49d7-f171-53c4d7f91710</uuid>
|
||||
<memory>1048576</memory>
|
||||
<currentMemory>1048576</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>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='lsilogic'/>
|
||||
<source file='[datastore] directory/fedora11.vmdk'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:50:56:91:48:c7'/>
|
||||
<source bridge='vm network'/>
|
||||
</interface>
|
||||
</devices>
|
||||
</domain>
|
@ -26,6 +26,7 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion)
|
||||
char *vmxPtr = &(vmxData[0]);
|
||||
char *xmlPtr = &(xmlData[0]);
|
||||
virDomainDefPtr def = NULL;
|
||||
virErrorPtr err = NULL;
|
||||
|
||||
if (virtTestLoadFile(vmx, &vmxPtr, MAX_FILE) < 0) {
|
||||
goto failure;
|
||||
@ -39,12 +40,16 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion)
|
||||
apiVersion);
|
||||
|
||||
if (def == NULL) {
|
||||
err = virGetLastError();
|
||||
fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);
|
||||
|
||||
if (formatted == NULL) {
|
||||
err = virGetLastError();
|
||||
fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
@ -117,6 +122,9 @@ mymain(int argc, char **argv)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_APIVersion_25);
|
||||
DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_APIVersion_25);
|
||||
|
||||
DO_TEST("minimal", "minimal", esxVI_APIVersion_25);
|
||||
DO_TEST("minimal-64bit", "minimal-64bit", esxVI_APIVersion_25);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user