]> xenbits.xensource.com Git - libvirt.git/commitdiff
vmx: Fix a VMX parsing problem
authorGeoff Hickey <ghickey@datagravity.com>
Wed, 7 Jan 2015 23:45:42 +0000 (18:45 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 8 Jan 2015 00:17:00 +0000 (17:17 -0700)
VMware ESX does not always set the "serialX.fileType" tag in VMX files. The
default value for this tag is "device", and when adding a new serial port
of this type VMware will omit the fileType tag. This caused libvirt to
fail to parse the VMX file. Fixed by making this tag optional and using
"device" as a default value. Also updated vmx2xmltest to test for this
case.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/vmx/vmx.c
tests/vmx2xmldata/vmx2xml-serial-device.vmx
tests/vmx2xmldata/vmx2xml-serial-device.xml

index e6bf5c3db75bf18971024e9eba8ea8f10c14cbfb..2a794c7fe3ab49ab3cc7654d5e584584e43b25e1 100644 (file)
@@ -2697,7 +2697,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
         goto ignore;
 
     /* vmx:fileType -> def:type */
-    if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0)
+    if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0)
         goto cleanup;
 
     /* vmx:fileName -> def:data.file.path */
@@ -2710,8 +2710,12 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
         goto cleanup;
     }
 
-    /* Setup virDomainChrDef */
-    if (STRCASEEQ(fileType, "device")) {
+    /*
+     * Setup virDomainChrDef. The default fileType is "device", and vmware
+     * will sometimes omit this tag when adding a new serial port of this
+     * type.
+     */
+    if (!fileType || STRCASEEQ(fileType, "device")) {
         (*def)->target.port = port;
         (*def)->source.type = VIR_DOMAIN_CHR_TYPE_DEV;
         (*def)->source.data.file.path = fileName;
index 8c101e311e09c521eeff03dddf209ad1e46ed5d6..927f408fbb4bc648403376024135e49af29d349c 100644 (file)
@@ -3,3 +3,5 @@ virtualHW.version = "4"
 serial0.present = "true"
 serial0.fileType = "device"
 serial0.fileName = "/dev/ttyS0"
+serial1.present = "true"
+serial1.fileName = "/dev/ttyS1"
index 9ecd867f374ee2dbf17d934d92c8bc7e0b1b18ab..cc45c078ea2c390075f79b41f06a11d420f6b956 100644 (file)
       <source path='/dev/ttyS0'/>
       <target port='0'/>
     </serial>
+    <serial type='dev'>
+      <source path='/dev/ttyS1'/>
+      <target port='1'/>
+    </serial>
     <console type='dev'>
       <source path='/dev/ttyS0'/>
       <target type='serial' port='0'/>