# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1271090577 -3600
# Node ID cd05b6aa8c0a15512da49b5338477dea42eed04f
# Parent e226618aa7156ddf500960a2e8be44220466a981
xl, libxl: xl list -v shows the uuid too
Break uuid to string conversion (including logging) out into a new
function libxl_uuid2string for reuse, and expose it for the
convenience of callers.
Provide a new -v option to xl list which shows the domain's uuid.
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
tools/libxl/libxl.c | 7 ++-----
tools/libxl/libxl.h | 3 +++
tools/libxl/libxl_dom.c | 6 ++++++
tools/libxl/xl.c | 22 +++++++++++++++-------
4 files changed, 26 insertions(+), 12 deletions(-)
diff -r e226618aa715 -r cd05b6aa8c0a tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Mon Apr 12 17:42:29 2010 +0100
+++ b/tools/libxl/libxl.c Mon Apr 12 17:42:57 2010 +0100
@@ -93,11 +93,8 @@ int libxl_domain_make(struct libxl_ctx *
xs_transaction_t t;
xen_domain_handle_t handle;
- uuid_string = string_of_uuid(ctx, info->uuid);
- if (!uuid_string) {
- XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate uuid string");
- return ERROR_FAIL;
- }
+ uuid_string = libxl_uuid2string(ctx, info->uuid);
+ if (!uuid_string) return ERROR_NOMEM;
flags = info->hvm ? XEN_DOMCTL_CDF_hvm_guest : 0;
flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
diff -r e226618aa715 -r cd05b6aa8c0a tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Mon Apr 12 17:42:29 2010 +0100
+++ b/tools/libxl/libxl.h Mon Apr 12 17:42:57 2010 +0100
@@ -264,6 +264,9 @@ int libxl_domain_shutdown(struct libxl_c
int libxl_domain_shutdown(struct libxl_ctx *ctx, uint32_t domid, int req);
int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force);
+char *libxl_uuid2string(struct libxl_ctx *ctx, uint8_t uuid[16]);
+ /* 0 means ERROR_ENOMEM, which we have logged */
+
/* events handling */
typedef enum {
diff -r e226618aa715 -r cd05b6aa8c0a tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Mon Apr 12 17:42:29 2010 +0100
+++ b/tools/libxl/libxl_dom.c Mon Apr 12 17:42:57 2010 +0100
@@ -350,3 +350,9 @@ int save_device_model(struct libxl_ctx *
unlink(filename);
return 0;
}
+
+char *libxl_uuid2string(struct libxl_ctx *ctx, uint8_t uuid[16]) {
+ char *s = string_of_uuid(ctx, uuid);
+ if (!s) XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate for uuid");
+ return s;
+}
diff -r e226618aa715 -r cd05b6aa8c0a tools/libxl/xl.c
--- a/tools/libxl/xl.c Mon Apr 12 17:42:29 2010 +0100
+++ b/tools/libxl/xl.c Mon Apr 12 17:42:57 2010 +0100
@@ -891,7 +891,7 @@ static void help(char *command)
printf("-d Enable debug messages.\n");
printf("-e Do not wait in the background for the
death of the domain.\n");
} else if(!strcmp(command, "list")) {
- printf("Usage: xl list [Domain]\n\n");
+ printf("Usage: xl list [-v] [Domain]\n\n");
printf("List information about all/some domains.\n\n");
} else if(!strcmp(command, "pci-attach")) {
printf("Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n");
@@ -1368,7 +1368,7 @@ void destroy_domain(char *p)
libxl_domain_destroy(&ctx, domid, 0);
}
-void list_domains(void)
+void list_domains(int verbose)
{
struct libxl_ctx ctx;
struct libxl_dominfo *info;
@@ -1388,7 +1388,7 @@ void list_domains(void)
}
printf("Name ID Mem
VCPUs\tState\tTime(s)\n");
for (i = 0; i < nb_domain; i++) {
- printf("%-40s %5d %5lu %5d %c%c%c %8.1f\n",
+ printf("%-40s %5d %5lu %5d %c%c%c %8.1f",
libxl_domid_to_name(&ctx, info[i].domid),
info[i].domid,
(unsigned long) (info[i].max_memkb / 1024),
@@ -1397,6 +1397,11 @@ void list_domains(void)
info[i].paused ? 'p' : '-',
info[i].dying ? 'd' : '-',
((float)info[i].cpu_time / 1e9));
+ if (verbose) {
+ char *uuid = libxl_uuid2string(&ctx, info[i].uuid);
+ printf(" %s", uuid);
+ }
+ putchar('\n');
}
free(info);
}
@@ -1614,20 +1619,23 @@ int main_destroy(int argc, char **argv)
int main_list(int argc, char **argv)
{
- int opt;
-
- while ((opt = getopt(argc, argv, "h")) != -1) {
+ int opt, verbose = 0;
+
+ while ((opt = getopt(argc, argv, "hv")) != -1) {
switch (opt) {
case 'h':
help("list");
exit(0);
+ case 'v':
+ verbose = 1;
+ break;
default:
fprintf(stderr, "option not supported\n");
break;
}
}
- list_domains();
+ list_domains(verbose);
exit(0);
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|