debuggers.hg

changeset 21969:d0469b045277

libxl: add a specific UUID type.

Slightly less error prone and also more amenable to autogeneration.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Ian Campbell <Ian.Campbell@eu.citrix.com>
date Wed Aug 04 18:08:08 2010 +0100 (2010-08-04)
parents 756d770ef599
children d627f6b581b4
files tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl_dom.c tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Wed Aug 04 16:00:13 2010 +0100
     1.2 +++ b/tools/libxl/libxl.c	Wed Aug 04 18:08:08 2010 +0100
     1.3 @@ -410,7 +410,7 @@ int libxl_domain_resume(libxl_ctx *ctx, 
     1.4   * Does not modify info so that it may be reused.
     1.5   */
     1.6  int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
     1.7 -                          libxl_domain_create_info *info, const char *name_suffix, uint8_t new_uuid[16])
     1.8 +                          libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid)
     1.9  {
    1.10      struct xs_permissions roperm[2];
    1.11      xs_transaction_t t;
     2.1 --- a/tools/libxl/libxl.h	Wed Aug 04 16:00:13 2010 +0100
     2.2 +++ b/tools/libxl/libxl.h	Wed Aug 04 18:08:08 2010 +0100
     2.3 @@ -22,8 +22,10 @@
     2.4  #include <xs.h>
     2.5  #include <sys/wait.h> /* for pid_t */
     2.6  
     2.7 +typedef uint8_t libxl_uuid[16];
     2.8 +
     2.9  typedef struct {
    2.10 -    uint8_t uuid[16];
    2.11 +    libxl_uuid uuid;
    2.12      uint32_t domid;
    2.13      uint8_t running:1;
    2.14      uint8_t blocked:1;
    2.15 @@ -50,7 +52,7 @@ typedef struct {
    2.16  } libxl_poolinfo;
    2.17  
    2.18  typedef struct {
    2.19 -    uint8_t uuid[16];
    2.20 +    libxl_uuid uuid;
    2.21      uint32_t domid;
    2.22  } libxl_vminfo;
    2.23  
    2.24 @@ -93,7 +95,7 @@ typedef struct {
    2.25      bool oos;
    2.26      int ssidref;
    2.27      char *name;
    2.28 -    uint8_t uuid[16];
    2.29 +    libxl_uuid uuid;
    2.30      char **xsdata;
    2.31      char **platformdata;
    2.32      uint32_t poolid;
    2.33 @@ -173,7 +175,7 @@ typedef enum {
    2.34  
    2.35  typedef struct {
    2.36      int domid;
    2.37 -    uint8_t uuid[16]; /* this is use only with stubdom, and must be different from the domain uuid */
    2.38 +    libxl_uuid uuid; /* this is use only with stubdom, and must be different from the domain uuid */
    2.39      char *dom_name;
    2.40      char *device_model;
    2.41      char *saved_state;
    2.42 @@ -338,7 +340,7 @@ int libxl_domain_suspend(libxl_ctx *ctx,
    2.43  int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid);
    2.44  int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid, int req);
    2.45  int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force);
    2.46 -int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, uint8_t new_uuid[16]);
    2.47 +int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
    2.48  
    2.49  int libxl_file_reference_map(libxl_ctx *ctx, libxl_file_reference *f);
    2.50  int libxl_file_reference_unmap(libxl_ctx *ctx, libxl_file_reference *f);
    2.51 @@ -360,7 +362,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
    2.52                           libxl_device_disk *disk,
    2.53                           uint32_t domid);
    2.54  
    2.55 -char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]);
    2.56 +char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid);
    2.57    /* 0 means ERROR_ENOMEM, which we have logged */
    2.58  
    2.59  /* events handling */
     3.1 --- a/tools/libxl/libxl_dom.c	Wed Aug 04 16:00:13 2010 +0100
     3.2 +++ b/tools/libxl/libxl_dom.c	Wed Aug 04 18:08:08 2010 +0100
     3.3 @@ -427,7 +427,7 @@ int save_device_model(libxl_ctx *ctx, ui
     3.4      return 0;
     3.5  }
     3.6  
     3.7 -char *libxl_uuid2string(libxl_ctx *ctx, const uint8_t uuid[16]) {
     3.8 +char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid) {
     3.9      char *s = string_of_uuid(ctx, uuid);
    3.10      if (!s) XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid");
    3.11      return s;
     4.1 --- a/tools/libxl/xl_cmdimpl.c	Wed Aug 04 16:00:13 2010 +0100
     4.2 +++ b/tools/libxl/xl_cmdimpl.c	Wed Aug 04 18:08:08 2010 +0100
     4.3 @@ -265,11 +265,11 @@ static void init_build_info(libxl_domain
     4.4      }
     4.5  }
     4.6  
     4.7 -static void random_uuid(uint8_t *uuid)
     4.8 +static void random_uuid(libxl_uuid *uuid)
     4.9  {
    4.10      int i;
    4.11      for (i = 0; i < 16; i++)
    4.12 -        uuid[i] = rand();
    4.13 +        (*uuid)[i] = rand();
    4.14  }
    4.15  
    4.16  static void init_dm_info(libxl_device_model_info *dm_info,
    4.17 @@ -277,7 +277,7 @@ static void init_dm_info(libxl_device_mo
    4.18  {
    4.19      memset(dm_info, '\0', sizeof(*dm_info));
    4.20  
    4.21 -    random_uuid(&dm_info->uuid[0]);
    4.22 +    random_uuid(&dm_info->uuid);
    4.23  
    4.24      dm_info->dom_name = c_info->name;
    4.25      dm_info->device_model = "qemu-dm";
    4.26 @@ -586,7 +586,7 @@ static void parse_config_data(const char
    4.27          c_info->name = strdup(buf);
    4.28      else
    4.29          c_info->name = "test";
    4.30 -    random_uuid(&c_info->uuid[0]);
    4.31 +    random_uuid(&c_info->uuid);
    4.32  
    4.33      if (!xlu_cfg_get_long(config, "oos", &l))
    4.34          c_info->oos = l;
    4.35 @@ -1155,7 +1155,7 @@ static int preserve_domain(libxl_ctx *ct
    4.36      struct tm tm;
    4.37      char stime[24];
    4.38  
    4.39 -    uint8_t new_uuid[16];
    4.40 +    libxl_uuid new_uuid;
    4.41  
    4.42      int rc;
    4.43  
    4.44 @@ -1176,7 +1176,7 @@ static int preserve_domain(libxl_ctx *ct
    4.45          return 0;
    4.46      }
    4.47  
    4.48 -    random_uuid(&new_uuid[0]);
    4.49 +    random_uuid(&new_uuid);
    4.50  
    4.51      LOG("Preserving domain %d %s with suffix%s", domid, d_config->c_info.name, stime);
    4.52      rc = libxl_domain_preserve(ctx, domid, &d_config->c_info, stime, new_uuid);