--- src/conf/cpu_conf.c | 7 ++++--- src/conf/domain_conf.c | 12 ++++++++---- src/conf/interface_conf.c | 6 ++++-- src/conf/network_conf.c | 6 ++++-- src/conf/node_device_conf.c | 6 ++++-- src/conf/secret_conf.c | 6 ++++-- src/conf/storage_conf.c | 12 ++++++++---- src/security/virt-aa-helper.c | 3 ++- src/test/test_driver.c | 13 ++++++++++--- src/util/xml.c | 2 +- 10 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 5b7b363..56e1dd5 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -118,9 +118,10 @@ virCPUDefParseXML(const xmlNodePtr node, unsigned int i; if (!xmlStrEqual(node->name, BAD_CAST "cpu")) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("XML does not contain expected 'cpu' element")); + virCPUReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <cpu>"), + node->name); return NULL; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e7e265c..2e620d6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6419,8 +6419,10 @@ virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, virDomainDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virDomainReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <domain>"), + root->name); goto cleanup; } @@ -6448,8 +6450,10 @@ virDomainObjParseNode(virCapsPtr caps, virDomainObjPtr obj = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virDomainReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <domstatus>"), + root->name); goto cleanup; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 7e9c78f..ef8c9d4 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -838,8 +838,10 @@ virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml, virInterfaceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "interface")) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virInterfaceReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <interface>"), + root->name); return NULL; } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 598d01f..a79391d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -731,8 +731,10 @@ virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml, virNetworkDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "network")) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virNetworkReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <network>"), + root->name); return NULL; } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1675631..aeca749 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1203,8 +1203,10 @@ virNodeDeviceDefParseNode(xmlDocPtr xml, virNodeDeviceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "device")) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virNodeDeviceReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <device>"), + root->name); return NULL; } diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index c8a8b85..407666a 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -112,8 +112,10 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) char *uuidstr = NULL; if (!xmlStrEqual(root->name, BAD_CAST "secret")) { - virSecretReportError(VIR_ERR_XML_ERROR, "%s", - _("incorrect root element")); + virSecretReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <secret>"), + root->name); goto cleanup; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5f94c01..da18350 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -747,8 +747,10 @@ virStoragePoolDefParseNode(xmlDocPtr xml, virStoragePoolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "pool")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage pool")); + virStorageReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <pool>"), + root->name); goto cleanup; } @@ -1127,8 +1129,10 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool, virStorageVolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "volume")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage vol")); + virStorageReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <volume>"), + root->name); goto cleanup; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 41ba4a3..994f83c 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -647,7 +647,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr) root = xmlDocGetRootElement(xml); if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - vah_error(NULL, 0, _("incorrect root element")); + vah_error(NULL, 0, _("unexpected root element <%s>, expecting to see " + "<domain>"), root->name)); goto cleanup; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index eadd587..4524230 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -781,9 +781,16 @@ static int testOpenFromFile(virConnectPtr conn, } root = xmlDocGetRootElement(xml); - if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) { - testError(VIR_ERR_XML_ERROR, "%s", - _("Root element is not 'node'")); + if (root == NULL) { + testError(VIR_ERR_XML_CONFIG, "%s", + _("missing root element")); + goto error; + } + if (!xmlStrEqual(root->name, BAD_CAST "node")) { + testError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <node>"), + root->name); goto error; } diff --git a/src/util/xml.c b/src/util/xml.c index 05317ea..828bf00 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -700,7 +700,7 @@ virXMLParseHelper(int domcode, goto error; if (xmlDocGetRootElement(xml) == NULL) { - virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, + virGenericReportError(domcode, VIR_ERR_XML_CONFIG, "%s", _("missing root element")); goto error; } -- 1.7.5.rc3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list