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] libxl: fix "xl list" output

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl: fix "xl list" output
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 18 Jan 2010 11:21:07 +0000
Delivery-date: Mon, 18 Jan 2010 03:19:52 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Hi all,
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>

---

diff -r 618b3597603c tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jan 18 10:37:28 2010 +0000
+++ b/tools/libxl/libxl.c       Mon Jan 18 11:13:03 2010 +0000
@@ -287,7 +287,7 @@
 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 @@
         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++;
+            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 = index;
+    *nb_domain = ret;
     return ptr;
 }
 
diff -r 618b3597603c tools/libxl/xl.c
--- a/tools/libxl/xl.c  Mon Jan 18 10:37:28 2010 +0000
+++ b/tools/libxl/xl.c  Mon Jan 18 11:13:03 2010 +0000
@@ -1421,14 +1421,17 @@
         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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] libxl: fix "xl list" output, Stefano Stabellini <=