]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix messages using VIR_ERR_XML_ERROR
authorCole Robinson <crobinso@redhat.com>
Thu, 12 May 2011 21:22:29 +0000 (17:22 -0400)
committerCole Robinson <crobinso@redhat.com>
Wed, 18 May 2011 15:18:09 +0000 (11:18 -0400)
This error code has existed since the dawn of time, yet the messages it
generates are almost universally busted. Here's a small sampling:

src/conf/domain_conf.c:4889 : XML description for missing root element is not well formed or invalid
src/conf/domain_conf.c:4951 : XML description for unknown device type is not well formed or invalid
src/conf/domain_conf.c:5460 : XML description for maximum vcpus must be an integer is not well formed or invalid
src/conf/domain_conf.c:5468 : XML description for invalid maxvcpus %(count)lu is not well formed or invalid

Fix up the error code to instead be

XML error: <msg>

Adjust the few locations that were using the original correctly (or shouldn't
have been using the error code at all).

v2:
    Fix wording of error code without a passed argument

src/test/test_driver.c
src/util/virterror.c
src/xen/xm_internal.c

index 658bcee89846334df3822d8a37735f6f8294a527..eadd587b6f0354a4f882c838907075f8c5ce674f 100644 (file)
@@ -808,7 +808,8 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->nodes = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node cpu numa nodes"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu nodes value"));
         goto error;
     }
 
@@ -816,7 +817,8 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->sockets = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node cpu sockets"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu sockets value"));
         goto error;
     }
 
@@ -824,7 +826,8 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->cores = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node cpu cores"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu cores value"));
         goto error;
     }
 
@@ -832,7 +835,8 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->threads = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node cpu threads"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu threads value"));
         goto error;
     }
 
@@ -843,14 +847,16 @@ static int testOpenFromFile(virConnectPtr conn,
             nodeInfo->cpus = l;
         }
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node active cpu"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu active value"));
         goto error;
     }
     ret = virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l);
     if (ret == 0) {
         nodeInfo->mhz = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node cpu mhz"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node cpu mhz value"));
         goto error;
     }
 
@@ -869,7 +875,8 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->memory = l;
     } else if (ret == -2) {
-        testError(VIR_ERR_XML_ERROR, "%s", _("node memory"));
+        testError(VIR_ERR_XML_ERROR, "%s",
+                  _("invalid node memory value"));
         goto error;
     }
 
index fbb4a4526c976b1640b6ca01f0187867e2ec5d6c..2d7309a82d9257030b9a991ae39129efb120f762 100644 (file)
@@ -925,9 +925,9 @@ virErrorMsg(virErrorNumber error, const char *info)
             break;
         case VIR_ERR_XML_ERROR:
             if (info == NULL)
-                errmsg = _("XML description not well formed or invalid");
+                errmsg = _("XML description is invalid or not well formed");
             else
-                errmsg = _("XML description for %s is not well formed or invalid");
+                errmsg = _("XML error: %s");
             break;
         case VIR_ERR_DOM_EXIST:
             if (info == NULL)
index 7708554994ce8e11be9c05d47425e9d321a17296..713bac397b812efccf43d38e1d889c45be94489d 100644 (file)
@@ -1536,8 +1536,9 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
         break;
     }
     default:
-        xenXMError(VIR_ERR_XML_ERROR,
-                   "%s", _("unknown device"));
+        xenXMError(VIR_ERR_CONFIG_UNSUPPORTED,
+                   _("device type '%s' cannot be detached"),
+                   virDomainDeviceTypeToString(dev->type));
         goto cleanup;
     }