[PATCH] [RFC] xen-xm: Generate UUID if not specified

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

 



I received a bug report about 'virsh domxml-from-native xen-xm' failing
when the xm configuration does not contain a UUID.  IMO, this is a bit
harsh since UUID is not even required when defining a domain.

I first took the approach of skipping the parsing of UUID when it is not
specified in the xm config, but that results in a UUID of all zeros,
which is the dom0 UUID from the xen tools perspective.

I'd like to hear what other folks think about the attached patch, which
generates a UUID if it is not specified in the xm config.

Regards,
Jim

>From 603650566effef533bc18a27303f5ac2072b5432 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@xxxxxxxx>
Date: Fri, 3 Aug 2012 15:10:13 -0600
Subject: [PATCH] xen-xm: Generate UUID if not specified

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 |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 5122866..479fb34 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -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) {
-- 
1.7.10.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]