]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Improve incorrect root element error messages
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 25 Nov 2011 12:23:03 +0000 (13:23 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 28 Nov 2011 14:12:37 +0000 (15:12 +0100)
When user pass wrong root element, it is not 'internal error' and
we can give him hint what we are expecting.

src/conf/domain_conf.c
src/conf/interface_conf.c
src/conf/network_conf.c
src/conf/node_device_conf.c
src/conf/secret_conf.c
src/security/virt-aa-helper.c

index f04e477e3dbf450d465c68b3487871d6be421ff7..bb504f98a626a0af2ad9adb7f99f4cf48391555f 100644 (file)
@@ -7932,8 +7932,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_ERROR,
+                             _("unexpected root element <%s>, "
+                               "expecting <domain>"),
+                             root->name);
         goto cleanup;
     }
 
@@ -7963,8 +7965,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_ERROR,
+                             _("unexpected root element <%s>, "
+                               "expecting <domstatus>"),
+                             root->name);
         goto cleanup;
     }
 
index fd8d1ae28f68f2ffe367e15fb36c10082d1158d3..59f74a1ab7857fa494e8f097d753bac89a0d64bb 100644 (file)
@@ -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_ERROR,
+                                _("unexpected root element <%s>, "
+                                  "expecting <interface>"),
+                                root->name);
         return NULL;
     }
 
index 10afcde6d9d0b5381301ebd85816bb460258e876..1058b0774a63da7d9fe7b42fb7f179318079e97e 100644 (file)
@@ -1107,8 +1107,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_ERROR,
+                              _("unexpected root element <%s>, "
+                                "expecting <network>"),
+                              root->name);
         return NULL;
     }
 
index fc284e01e05cbc055ff814348afba3869f946ef6..084121f26dc6c474f6789d2dfea8f375d5f0e48f 100644 (file)
@@ -1204,8 +1204,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_ERROR,
+                                 _("unexpected root element <%s> "
+                                   "expecting <device>"),
+                                 root->name);
         return NULL;
     }
 
index a51fc6963a823cf6e018d1c0420c53a18ab56632..6e80733dd2045678c9092b2c881326ea1ad0f9fb 100644 (file)
@@ -126,8 +126,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_ERROR,
+                             _("unexpected root element <%s>, "
+                               "expecting <secret>"),
+                             root->name);
         goto cleanup;
     }
 
index ad0697424fa6f5a9fe18f0c93876441dd489dd31..14399cce63fc3a11939dc637d35efae5022cc03d 100644 (file)
@@ -644,7 +644,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
     }
 
     if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domain")) {
-        vah_error(NULL, 0, _("incorrect root element"));
+        vah_error(NULL, 0, _("unexpected root element, expecting <domain>"));
         goto cleanup;
     }