mirror of https://gitee.com/openkylin/libvirt.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 <eblake@redhat.com>
This commit is contained in:
parent
1b21d30069
commit
bb072e8a38
|
@ -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;
|
||||
|
|
|
@ -3,3 +3,5 @@ virtualHW.version = "4"
|
|||
serial0.present = "true"
|
||||
serial0.fileType = "device"
|
||||
serial0.fileName = "/dev/ttyS0"
|
||||
serial1.present = "true"
|
||||
serial1.fileName = "/dev/ttyS1"
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
<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'/>
|
||||
|
|
Loading…
Reference in New Issue