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 09/16] xl, libxl: xl list -v shows the uuid too

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 09/16] xl, libxl: xl list -v shows the uuid too
From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date: Mon, 12 Apr 2010 15:41:39 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Delivery-date: Mon, 12 Apr 2010 08:05:03 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1271083306-11126-9-git-send-email-ian.jackson@xxxxxxxxxxxxx>
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>
References: <1271083306-11126-1-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-2-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-3-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-4-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-5-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-6-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-7-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-8-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1271083306-11126-9-git-send-email-ian.jackson@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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        |   20 ++++++++++++++------
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index f96b3ae..663cbc1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -93,11 +93,8 @@ int libxl_domain_make(struct libxl_ctx *ctx, 
libxl_domain_create_info *info,
     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 --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 02bdd21..2ef8640 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -264,6 +264,9 @@ int libxl_domain_resume(struct libxl_ctx *ctx, uint32_t 
domid);
 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 --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c213792..57b800a 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -350,3 +350,9 @@ int save_device_model(struct libxl_ctx *ctx, uint32_t 
domid, int fd)
     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 --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index d99e637..41dada7 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -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;
+    int opt, verbose = 0;
 
-    while ((opt = getopt(argc, argv, "h")) != -1) {
+    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);
 }
 
-- 
1.5.6.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>