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

[Xen-devel] [PATCH 1 of 8] libxl: add a specific UUID type



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1280829528 -3600
# Node ID cafba5708f95cf85f55bdca322d2ff6b6769bcba
# Parent  b2ed7cc08554cba162f93cb95e84c2130d76b314
libxl: add a specific UUID type.

Slightly less error prone and also more amenable to autogeneration.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r b2ed7cc08554 -r cafba5708f95 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Aug 03 10:58:48 2010 +0100
+++ b/tools/libxl/libxl.c       Tue Aug 03 10:58:48 2010 +0100
@@ -410,7 +410,7 @@ int libxl_domain_resume(libxl_ctx *ctx, 
  * Does not modify info so that it may be reused.
  */
 int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
-                          libxl_domain_create_info *info, const char 
*name_suffix, uint8_t new_uuid[16])
+                          libxl_domain_create_info *info, const char 
*name_suffix, libxl_uuid new_uuid)
 {
     struct xs_permissions roperm[2];
     xs_transaction_t t;
diff -r b2ed7cc08554 -r cafba5708f95 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Tue Aug 03 10:58:48 2010 +0100
+++ b/tools/libxl/libxl.h       Tue Aug 03 10:58:48 2010 +0100
@@ -22,8 +22,10 @@
 #include <xs.h>
 #include <sys/wait.h> /* for pid_t */
 
+typedef uint8_t libxl_uuid[16];
+
 typedef struct {
-    uint8_t uuid[16];
+    libxl_uuid uuid;
     uint32_t domid;
     uint8_t running:1;
     uint8_t blocked:1;
@@ -50,7 +52,7 @@ typedef struct {
 } libxl_poolinfo;
 
 typedef struct {
-    uint8_t uuid[16];
+    libxl_uuid uuid;
     uint32_t domid;
 } libxl_vminfo;
 
@@ -93,7 +95,7 @@ typedef struct {
     bool oos;
     int ssidref;
     char *name;
-    uint8_t uuid[16];
+    libxl_uuid uuid;
     char **xsdata;
     char **platformdata;
     uint32_t poolid;
@@ -173,7 +175,7 @@ typedef enum {
 
 typedef struct {
     int domid;
-    uint8_t uuid[16]; /* this is use only with stubdom, and must be different 
from the domain uuid */
+    libxl_uuid uuid; /* this is use only with stubdom, and must be different 
from the domain uuid */
     char *dom_name;
     char *device_model;
     char *saved_state;
@@ -338,7 +340,7 @@ int libxl_domain_resume(libxl_ctx *ctx, 
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid);
 int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid, int req);
 int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force);
-int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, 
libxl_domain_create_info *info, const char *name_suffix, uint8_t new_uuid[16]);
+int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, 
libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
 
 int libxl_file_reference_map(libxl_ctx *ctx, libxl_file_reference *f);
 int libxl_file_reference_unmap(libxl_ctx *ctx, libxl_file_reference *f);
@@ -360,7 +362,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
                          libxl_device_disk *disk,
                          uint32_t domid);
 
-char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]);
+char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid);
   /* 0 means ERROR_ENOMEM, which we have logged */
 
 /* events handling */
diff -r b2ed7cc08554 -r cafba5708f95 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Tue Aug 03 10:58:48 2010 +0100
+++ b/tools/libxl/libxl_dom.c   Tue Aug 03 10:58:48 2010 +0100
@@ -427,7 +427,7 @@ int save_device_model(libxl_ctx *ctx, ui
     return 0;
 }
 
-char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]) {
+char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid) {
     char *s = string_of_uuid(ctx, uuid);
     if (!s) XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid");
     return s;
diff -r b2ed7cc08554 -r cafba5708f95 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue Aug 03 10:58:48 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Aug 03 10:58:48 2010 +0100
@@ -265,11 +265,11 @@ static void init_build_info(libxl_domain
     }
 }
 
-static void random_uuid(uint8_t *uuid)
+static void random_uuid(libxl_uuid *uuid)
 {
     int i;
     for (i = 0; i < 16; i++)
-        uuid[i] = rand();
+        (*uuid)[i] = rand();
 }
 
 static void init_dm_info(libxl_device_model_info *dm_info,
@@ -277,7 +277,7 @@ static void init_dm_info(libxl_device_mo
 {
     memset(dm_info, '\0', sizeof(*dm_info));
 
-    random_uuid(&dm_info->uuid[0]);
+    random_uuid(&dm_info->uuid);
 
     dm_info->dom_name = c_info->name;
     dm_info->device_model = "qemu-dm";
@@ -586,7 +586,7 @@ static void parse_config_data(const char
         c_info->name = strdup(buf);
     else
         c_info->name = "test";
-    random_uuid(&c_info->uuid[0]);
+    random_uuid(&c_info->uuid);
 
     if (!xlu_cfg_get_long(config, "oos", &l))
         c_info->oos = l;
@@ -1181,7 +1181,7 @@ static int preserve_domain(libxl_ctx *ct
     struct tm tm;
     char stime[24];
 
-    uint8_t new_uuid[16];
+    libxl_uuid new_uuid;
 
     int rc;
 
@@ -1202,7 +1202,7 @@ static int preserve_domain(libxl_ctx *ct
         return 0;
     }
 
-    random_uuid(&new_uuid[0]);
+    random_uuid(&new_uuid);
 
     LOG("Preserving domain %d %s with suffix%s", domid, d_config->c_info.name, 
stime);
     rc = libxl_domain_preserve(ctx, domid, &d_config->c_info, stime, new_uuid);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.