From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
introduce function
xenFormatXMGeneralMeta(virConfPtr conf, .......);
which formats UUID and name instead
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 289f0ad..ae474a4 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1655,6 +1655,20 @@ xenFormatXMPCI(virConfPtr conf,
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough. */
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
+static
+int xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
+{
+ char uuid[VIR_UUID_STRING_BUFLEN];
+
+ if (xenXMConfigSetString(conf, "name", def->name) < 0)
+ return -1;
+
+ virUUIDFormat(def->uuid, uuid);
+ if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
+ return -1;
+
+ return 0;
+}
virConfPtr xenFormatXM(virConnectPtr conn,
virDomainDefPtr def,
@@ -1665,21 +1679,13 @@ virConfPtr xenFormatXM(virConnectPtr conn,
size_t i;
char *cpus = NULL;
const char *lifecycle;
- char uuid[VIR_UUID_STRING_BUFLEN];
virConfValuePtr diskVal = NULL;
virConfValuePtr netVal = NULL;
if (!(conf = virConfNew()))
goto cleanup;
-
-
- if (xenXMConfigSetString(conf, "name", def->name) < 0)
+ if (xenFormatXMGeneralMeta(conf, def) < 0)
goto cleanup;
-
- virUUIDFormat(def->uuid, uuid);
- if (xenXMConfigSetString(conf, "uuid", uuid) < 0)
- goto cleanup;
-
if (xenXMConfigSetInt(conf, "maxmem",
VIR_DIV_UP(def->mem.max_balloon, 1024)) < 0)
goto cleanup;
--
1.8.4.5