From 92d653010606a45a69ea6edd55ba689bffca0b44 Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Sun, 9 Jan 2011 19:18:52 +0800 Subject: [PATCH] conf: Report error if invalid type specified for character device If invalid type is specified, e.g. 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 --- src/conf/domain_conf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c857a89040..b4df38c0b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) { -- GitLab