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.
---
src/util/conf.c | 5 ++-
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 25 +++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 25 +++++++++++
tests/vmx2xmltest.c | 9 ++++
6 files changed, 165 insertions(+), 1 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
diff --git a/src/util/conf.c b/src/util/conf.c
index 24588c2..ae0459e 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -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;
}
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
new file mode 100644
index 0000000..3626c5e
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
@@ -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"
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
new file mode 100644
index 0000000..0be570f
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
@@ -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>
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
new file mode 100644
index 0000000..a485d03
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
@@ -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"
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
new file mode 100644
index 0000000..766172f
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
@@ -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>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index b4eb5d5..4c93059 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -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,10 @@ 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);
--
1.6.3.3
Show replies by date
On Wed, Mar 24, 2010 at 02:12:14AM +0100, Matthias Bolte wrote:
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.
---
src/util/conf.c | 5 ++-
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 25 +++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 25 +++++++++++
tests/vmx2xmltest.c | 9 ++++
6 files changed, 165 insertions(+), 1 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
Patch for issue raised privately by Paul Dorman, looks fine to me,
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/
2010/3/24 Daniel Veillard <veillard(a)redhat.com>:
On Wed, Mar 24, 2010 at 02:12:14AM +0100, Matthias Bolte wrote:
> 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.
> ---
> src/util/conf.c | 5 ++-
> tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 51 ++++++++++++++++++++++
> tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 25 +++++++++++
> tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx | 51 ++++++++++++++++++++++
> tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 25 +++++++++++
> tests/vmx2xmltest.c | 9 ++++
> 6 files changed, 165 insertions(+), 1 deletions(-)
> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
Patch for issue raised privately by Paul Dorman, looks fine to me,
ACK,
Daniel
Thanks, pushed.
Matthias
Patch successfully resolves this issue. Tested with previously failing
domains.
Thanks,
Paul
On Thu, Mar 25, 2010 at 9:05 AM, Matthias Bolte <
matthias.bolte(a)googlemail.com> wrote:
2010/3/24 Daniel Veillard <veillard(a)redhat.com>:
> On Wed, Mar 24, 2010 at 02:12:14AM +0100, Matthias Bolte wrote:
>> 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.
>> ---
>> src/util/conf.c | 5 ++-
>> tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 51
++++++++++++++++++++++
>> tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 25 +++++++++++
>> tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx | 51
++++++++++++++++++++++
>> tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 25 +++++++++++
>> tests/vmx2xmltest.c | 9 ++++
>> 6 files changed, 165 insertions(+), 1 deletions(-)
>> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
>> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
>> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
>> create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
>
> Patch for issue raised privately by Paul Dorman, looks fine to me,
> ACK,
>
> Daniel
>
Thanks, pushed.
Matthias
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list