提交 92d65301 编写于 作者: O Osier Yang 提交者: Eric Blake

conf: Report error if invalid type specified for character device

If invalid type is specified, e.g.
<serial type='foo'>
    <target port='0'/>
</serial>

We replace 'foo' with "null" type implicitly, without reporting an
error message to tell the user, and "start" or "edit" the domain
will be success.

It's not good to guess what the user wants, This patch is to fix
the problem.

* src/conf/domain_conf.c
上级 5e5acbc8
......@@ -2821,10 +2821,14 @@ virDomainChrDefParseXML(virCapsPtr caps,
}
type = virXMLPropString(node, "type");
if (type == NULL)
if (type == NULL) {
def->type = VIR_DOMAIN_CHR_TYPE_PTY;
else if ((def->type = virDomainChrTypeFromString(type)) < 0)
def->type = VIR_DOMAIN_CHR_TYPE_NULL;
} else if ((def->type = virDomainChrTypeFromString(type)) < 0) {
virDomainReportError(VIR_ERR_XML_ERROR,
_("unknown type presented to host for character device: %s"),
type);
goto error;
}
nodeName = (const char *) node->name;
if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册