]> xenbits.xensource.com Git - libvirt.git/commitdiff
xen-xm: Generate UUID if not specified
authorJim Fehlig <jfehlig@suse.com>
Fri, 3 Aug 2012 21:10:13 +0000 (15:10 -0600)
committerJim Fehlig <jfehlig@suse.com>
Fri, 3 Aug 2012 22:16:56 +0000 (16:16 -0600)
Parsing xen-xm format configuration will fail if UUID is not
specified, e.g.

virsh domxml-from-native xen-xm some-config-without-uuid
error: internal error parsing xm config failed

Initially I thought to skip parsing the UUID in xenParseXM() when
not present in the configuration, but this results in a UUID of
all zeros since it is never set

virsh domxml-from-native xen-xm /tmp/jim/bug-773621_pierre-test
<domain type='xen'>
  <name>test</name>
  <uuid>00000000-0000-0000-0000-000000000000</uuid>
  ...

which certainly can't be correct since this is the UUID the xen
tools use for dom0.

This patch takes the approach of generating a UUID when it is not
specified in the configuration.

src/xenxs/xen_xm.c

index 5122866b0ed453380006b293757e4faf0f16a7a7..479fb342df59e69c463eb541a019b03b49c9cdad 100644 (file)
@@ -214,9 +214,13 @@ static int xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *
     }
 
     if (!(val = virConfGetValue(conf, name))) {
-        virReportError(VIR_ERR_CONF_SYNTAX,
-                       _("config value %s was missing"), name);
-        return -1;
+        if (virUUIDGenerate(uuid)) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s", _("Failed to generate UUID"));
+            return -1;
+        } else {
+            return 0;
+        }
     }
 
     if (val->type != VIR_CONF_STRING) {