xs_transaction_t t;
xen_domain_handle_t handle;
- uuid_string = libxl_uuid2string(ctx, info->uuid);
+ uuid_string = libxl_uuid2string(&gc, info->uuid);
if (!uuid_string) {
libxl_free_all(&gc);
return ERROR_NOMEM;
return ERROR_NOMEM;
}
- uuid_string = libxl_uuid2string(ctx, new_uuid);
+ uuid_string = libxl_uuid2string(&gc, new_uuid);
if (!uuid_string) {
libxl_free_all(&gc);
return ERROR_NOMEM;
if (rc != 1 || info.domain != domid)
goto out;
xcinfo2xlinfo(&info, &ptr);
- uuid = libxl_uuid2string(ctx, ptr.uuid);
+ uuid = libxl_uuid2string(&gc, ptr.uuid);
libxl_xs_write(&gc, XBT_NULL, libxl_sprintf(&gc, "/vm/%s/memory", uuid), "%"PRIu32, target_memkb / 1024);
if (enforce || !domid)
#include <sys/wait.h> /* for pid_t */
typedef uint8_t libxl_uuid[16];
+#define LIBXL_UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+#define LIBXL_UUID_BYTES(uuid) uuid[0], uuid[1], uuid[2], uuid[3], \
+ uuid[4], uuid[5], uuid[6], uuid[7], \
+ uuid[8], uuid[9], uuid[10], uuid[11], \
+ uuid[12], uuid[13], uuid[14], uuid[15] \
+
typedef uint8_t libxl_mac[6];
libxl_device_disk *disk,
uint32_t domid);
-char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid);
/* 0 means ERROR_ENOMEM, which we have logged */
/* events handling */
return 0;
}
-char *libxl_uuid2string(libxl_ctx *ctx, const libxl_uuid uuid)
+char *libxl_uuid2string(libxl_gc *gc, const libxl_uuid uuid)
{
- libxl_gc gc = LIBXL_INIT_GC(ctx);
- char *s = string_of_uuid(&gc, uuid);
- char *ret;
- if (!s) {
- XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid");
- ret = NULL;
- }else{
- ret = strdup(s);
- }
- libxl_free_all(&gc);
- return ret;
+ char *s = libxl_sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
+ if (!s)
+ XL_LOG(libxl_gc_owner(gc), XL_LOG_ERROR, "cannot allocate for uuid");
+ return s;
}
static const char *userdata_path(libxl_gc *gc, uint32_t domid,
" for domain %"PRIu32, domid);
return NULL;
}
- uuid_string = string_of_uuid(gc, info.uuid);
+ uuid_string = libxl_sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info.uuid));
path = libxl_sprintf(gc, "/var/lib/xen/"
"userdata-%s.%s.%s",
#define PRINTF_ATTRIBUTE(x, y) __attribute__((format(printf, x, y)))
-#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
-#define string_of_uuid(ctx, u) \
- libxl_sprintf(ctx, UUID_FMT, \
- (u)[0], (u)[1], (u)[2], (u)[3], (u)[4], (u)[5], (u)[6], (u)[7], \
- (u)[8], (u)[9], (u)[10], (u)[11], (u)[12], (u)[13], (u)[14], (u)[15])
-
_hidden int xs_writev(struct xs_handle *xsh, xs_transaction_t t, char *dir, char *kvs[]);
typedef struct {
const char *disk,
libxl_disk_phystype phystype);
+_hidden char *libxl_uuid2string(libxl_gc *gc, const libxl_uuid uuid);
+
#endif
#include "libxlutil.h"
#include "xl.h"
-#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
-
#define CHK_ERRNO( call ) ({ \
int chk_errno = (call); \
if (chk_errno < 0) { \
printf("\t(oos %d)\n", c_info->oos);
printf("\t(ssidref %d)\n", c_info->ssidref);
printf("\t(name %s)\n", c_info->name);
- printf("\t(uuid " UUID_FMT ")\n",
- (c_info->uuid)[0], (c_info->uuid)[1], (c_info->uuid)[2], (c_info->uuid)[3],
- (c_info->uuid)[4], (c_info->uuid)[5], (c_info->uuid)[6], (c_info->uuid)[7],
- (c_info->uuid)[8], (c_info->uuid)[9], (c_info->uuid)[10], (c_info->uuid)[11],
- (c_info->uuid)[12], (c_info->uuid)[13], (c_info->uuid)[14], (c_info->uuid)[15]);
+ printf("\t(uuid " LIBXL_UUID_FMT ")\n", LIBXL_UUID_BYTES(c_info->uuid));
printf("\t(cpupool %s (%d))\n", c_info->poolname, c_info->poolid);
if (c_info->xsdata)
printf("\t(xsdata contains data)\n");
info[i].dying ? 'd' : '-',
((float)info[i].cpu_time / 1e9));
free(domname);
- if (verbose) {
- char *uuid = libxl_uuid2string(&ctx, info[i].uuid);
- printf(" %s", uuid);
- }
+ if (verbose)
+ printf(" " LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info[i].uuid));
putchar('\n');
}
}
printf("UUID ID name\n");
for (i = 0; i < nb_vm; i++) {
domname = libxl_domid_to_name(&ctx, info[i].domid);
- printf(UUID_FMT " %d %-30s\n",
- info[i].uuid[0], info[i].uuid[1], info[i].uuid[2], info[i].uuid[3],
- info[i].uuid[4], info[i].uuid[5], info[i].uuid[6], info[i].uuid[7],
- info[i].uuid[8], info[i].uuid[9], info[i].uuid[10], info[i].uuid[11],
- info[i].uuid[12], info[i].uuid[13], info[i].uuid[14], info[i].uuid[15],
+ printf(LIBXL_UUID_FMT " %d %-30s\n", LIBXL_UUID_BYTES(info[i].uuid),
info[i].domid, domname);
free(domname);
}