WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1 of 8] libxl: add a specific UUID type
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 03 Aug 2010 12:00:16 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Tue, 03 Aug 2010 04:03:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1280833215@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# 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