From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 1 of 8] libxl: add a specific UUID type
Date: Tue, 03 Aug 2010 12:00:16 +0100 [thread overview]
Message-ID: <cafba5708f95cf85f55b.1280833216@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1280833215@localhost.localdomain>
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# 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@citrix.com>
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);
next prev parent reply other threads:[~2010-08-03 11:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 11:00 [PATCH 0 of 8] [RFC] libxl: autogenerate type definitions and destructor functions Ian Campbell
2010-08-03 11:00 ` Ian Campbell [this message]
2010-08-03 11:00 ` [PATCH 2 of 8] libxl: add a specific MAC address type Ian Campbell
2010-08-03 11:00 ` [PATCH 3 of 8] libxl: move type definitions into _libxl_types.h Ian Campbell
2010-08-03 11:00 ` [PATCH 4 of 8] libxl: tweak formatting/whitespace of _libxl_types.h Ian Campbell
2010-08-03 11:00 ` [PATCH 5 of 8] libxl: autogenerate _libxl_types.h Ian Campbell
2010-08-03 12:13 ` Gianni Tedesco
2010-08-03 12:29 ` Ian Campbell
2010-08-03 12:36 ` Gianni Tedesco
2010-08-03 13:30 ` Ian Campbell
2010-08-03 11:00 ` [PATCH 6 of 8] libxl: add KeyedUnion type Ian Campbell
2010-08-03 11:00 ` [PATCH 7 of 8] libxl: generate destructors for each libxl defined type Ian Campbell
2010-08-03 12:07 ` Gianni Tedesco
2010-08-03 12:24 ` Ian Campbell
2010-08-03 12:34 ` Gianni Tedesco
2010-08-03 11:00 ` [PATCH 8 of 8] xl: free the libxl types contained in struct domain_config Ian Campbell
2010-08-04 10:25 ` [PATCH 0 of 8] [RFC] libxl: autogenerate type definitions and destructor functions Gianni Tedesco
2010-08-04 17:16 ` Stefano Stabellini
2010-08-10 14:41 ` Ian Jackson
2010-08-10 14:48 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cafba5708f95cf85f55b.1280833216@localhost.localdomain \
--to=ian.campbell@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).