[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/2] xen: add error handling to UUID parsing



otherwise a missing UUID in a domain config just shows:

libxlDomainXMLFromNative:2600 : Internal Error parsing xm config failed

Now we have:

xenXMConfigGetUUID:186 : Internal Error config value uuid was missing

O.k. to apply?
 -- Guido

---
 src/xenxs/xen_xm.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 03857c8..d057043 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -174,21 +174,38 @@ static int xenXMConfigCopyStringOpt(virConfPtr conf,
 /* Convenience method to grab a string UUID from the config file object */
 static int xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) {
     virConfValuePtr val;
-    if (!uuid || !name || !conf)
-        return (-1);
+
+    if (!uuid || !name || !conf) {
+        XENXS_ERROR(VIR_ERR_INVALID_ARG,
+                   _("Arguments must be non null"));
+        return -1;
+    }
+
     if (!(val = virConfGetValue(conf, name))) {
-        return (-1);
+        XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
+                   _("config value %s was missing"), name);
+        return -1;
     }
 
-    if (val->type != VIR_CONF_STRING)
-        return (-1);
-    if (!val->str)
-        return (-1);
+    if (val->type != VIR_CONF_STRING) {
+        XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
+                   _("config value %s not a string"), name);
+        return -1;
+    }
+
+    if (!val->str) {
+        XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
+                   _("%s can't be empty"), name);
+        return -1;
+    }
 
-    if (virUUIDParse(val->str, uuid) < 0)
-        return (-1);
+    if (virUUIDParse(val->str, uuid) < 0) {
+        XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
+                   _("%s not parseable"), val->str);
+        return -1;
+    }
 
-    return (0);
+    return 0;
 }
 
 #define MAX_VFB 1024
-- 
1.7.6.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]