[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: fix "xl list" output



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263826140 0
# Node ID d7e8b6a66a3d3329e515a5f5cbf8f5d3ea43c199
# Parent  a56216b3f62dc002159af2cff001c4549fdd1b85
libxl: fix "xl list" output

This simple patch fixes the "xl list" output and cleans
libxl_list_domain after the recent API changes to list domains and
VMs.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c |   28 +++++++++++++---------------
 tools/libxl/xl.c    |    9 ++++++---
 2 files changed, 19 insertions(+), 18 deletions(-)

diff -r a56216b3f62d -r d7e8b6a66a3d tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jan 18 14:48:18 2010 +0000
+++ b/tools/libxl/libxl.c       Mon Jan 18 14:49:00 2010 +0000
@@ -287,7 +287,7 @@ struct libxl_dominfo * libxl_list_domain
 struct libxl_dominfo * libxl_list_domain(struct libxl_ctx *ctx, int *nb_domain)
 {
     struct libxl_dominfo *ptr;
-    int index, i, ret;
+    int i, ret;
     xc_domaininfo_t info[1024];
     int size = 1024;
 
@@ -296,24 +296,22 @@ struct libxl_dominfo * libxl_list_domain
         return NULL;
 
     ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info);
-    for (index = i = 0; i < ret; i++) {
-        memcpy(&(ptr[index].uuid), info[i].handle, 
sizeof(xen_domain_handle_t));
-        ptr[index].domid = info[i].domain;
+    for (i = 0; i < ret; i++) {
+        memcpy(&(ptr[i].uuid), info[i].handle, sizeof(xen_domain_handle_t));
+        ptr[i].domid = info[i].domain;
 
         if (info[i].flags & XEN_DOMINF_dying)
-            ptr[index].dying = 1;
+            ptr[i].dying = 1;
         else if (info[i].flags & XEN_DOMINF_paused)
-            ptr[index].paused = 1;
+            ptr[i].paused = 1;
         else if (info[i].flags & XEN_DOMINF_blocked || info[i].flags & 
XEN_DOMINF_running)
-            ptr[index].running = 1;
-        ptr[index].max_memkb = PAGE_TO_MEMKB(info[i].max_pages);
-        ptr[index].cpu_time = info[i].cpu_time;
-        ptr[index].vcpu_max_id = info[i].max_vcpu_id;
-        ptr[index].vcpu_online = info[i].nr_online_vcpus;
-
-        index++;
-    }
-    *nb_domain = index;
+            ptr[i].running = 1;
+        ptr[i].max_memkb = PAGE_TO_MEMKB(info[i].tot_pages);
+        ptr[i].cpu_time = info[i].cpu_time;
+        ptr[i].vcpu_max_id = info[i].max_vcpu_id;
+        ptr[i].vcpu_online = info[i].nr_online_vcpus;
+    }
+    *nb_domain = ret;
     return ptr;
 }
 
diff -r a56216b3f62d -r d7e8b6a66a3d tools/libxl/xl.c
--- a/tools/libxl/xl.c  Mon Jan 18 14:48:18 2010 +0000
+++ b/tools/libxl/xl.c  Mon Jan 18 14:49:00 2010 +0000
@@ -1421,14 +1421,17 @@ void list_domains(void)
         fprintf(stderr, "libxl_domain_infolist failed.\n");
         exit(1);
     }
-    printf("Name                                        ID   \tState\n");
+    printf("Name                                        ID   Mem 
VCPUs\tState\tTime(s)\n");
     for (i = 0; i < nb_domain; i++) {
-        printf("%-40s %5d     %c%c%c\n",
+        printf("%-40s %5d %5lu %5d        %c%c%c %8.1f\n",
                 libxl_domid_to_name(&ctx, info[i].domid),
                 info[i].domid,
+                (unsigned long) (info[i].max_memkb / 1024),
+                info[i].vcpu_online,
                 info[i].running ? 'r' : '-',
                 info[i].paused ? 'p' : '-',
-                info[i].dying ? 'd' : '-');
+                info[i].dying ? 'd' : '-',
+                ((float)info[i].cpu_time / 1e9));
     }
     free(info);
 }

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.