From: Geoff Hickey Date: Wed, 7 Jan 2015 23:45:42 +0000 (-0500) Subject: vmx: Fix a VMX parsing problem X-Git-Tag: v1.2.12-rc1~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb072e8a38d1d6d2f7819bbcb8ff106520081667;p=thirdparty%2Flibvirt.git vmx: Fix a VMX parsing problem 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 --- diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index e6bf5c3db7..2a794c7fe3 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -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; diff --git a/tests/vmx2xmldata/vmx2xml-serial-device.vmx b/tests/vmx2xmldata/vmx2xml-serial-device.vmx index 8c101e311e..927f408fbb 100644 --- a/tests/vmx2xmldata/vmx2xml-serial-device.vmx +++ b/tests/vmx2xmldata/vmx2xml-serial-device.vmx @@ -3,3 +3,5 @@ virtualHW.version = "4" serial0.present = "true" serial0.fileType = "device" serial0.fileName = "/dev/ttyS0" +serial1.present = "true" +serial1.fileName = "/dev/ttyS1" diff --git a/tests/vmx2xmldata/vmx2xml-serial-device.xml b/tests/vmx2xmldata/vmx2xml-serial-device.xml index 9ecd867f37..cc45c078ea 100644 --- a/tests/vmx2xmldata/vmx2xml-serial-device.xml +++ b/tests/vmx2xmldata/vmx2xml-serial-device.xml @@ -15,6 +15,10 @@ + + + +