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

[Xen-changelog] [xen-unstable] libxl/xl: correctly report domain state.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1279903172 -3600
# Node ID 1c1b02487b577e0dc78370f1a3d4c1d24c10cc04
# Parent  267ddd7fa11f7a63f5c6ca0b9ecb1c60f03b39cf
libxl/xl: correctly report domain state.

In particular distinguish between domain shutdown and crash and the
blocked and running states.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c      |   26 ++++++++++++++++++--------
 tools/libxl/libxl.h      |    7 +++++--
 tools/libxl/xl_cmdimpl.c |    5 ++++-
 3 files changed, 27 insertions(+), 11 deletions(-)

diff -r 267ddd7fa11f -r 1c1b02487b57 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jul 23 17:35:59 2010 +0100
+++ b/tools/libxl/libxl.c       Fri Jul 23 17:39:32 2010 +0100
@@ -402,17 +402,27 @@ int libxl_domain_resume(struct libxl_ctx
 }
 
 static void xcinfo2xlinfo(const xc_domaininfo_t *xcinfo,
-                          struct libxl_dominfo *xlinfo) {
+                          struct libxl_dominfo *xlinfo)
+{
+    unsigned int shutdown_reason;
+
     memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
     xlinfo->domid = xcinfo->domain;
 
-    if (xcinfo->flags & XEN_DOMINF_dying)
-        xlinfo->dying = 1;
-    else if (xcinfo->flags & XEN_DOMINF_paused)
-        xlinfo->paused = 1;
-    else if (xcinfo->flags & XEN_DOMINF_blocked ||
-             xcinfo->flags & XEN_DOMINF_running)
-        xlinfo->running = 1;
+    xlinfo->dying    = !!(xcinfo->flags&XEN_DOMINF_dying);
+    xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
+    xlinfo->paused   = !!(xcinfo->flags&XEN_DOMINF_paused);
+    xlinfo->blocked  = !!(xcinfo->flags&XEN_DOMINF_blocked);
+    xlinfo->running  = !!(xcinfo->flags&XEN_DOMINF_running);
+    xlinfo->crashed  = 0;
+
+    shutdown_reason = (xcinfo->flags>>XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask;
+
+    if ( xlinfo->shutdown && (shutdown_reason == SHUTDOWN_crash) ) {
+        xlinfo->shutdown = 0;
+        xlinfo->crashed  = 1;
+    }
+
     xlinfo->max_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages);
     xlinfo->cpu_time = xcinfo->cpu_time;
     xlinfo->vcpu_max_id = xcinfo->max_vcpu_id;
diff -r 267ddd7fa11f -r 1c1b02487b57 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Jul 23 17:35:59 2010 +0100
+++ b/tools/libxl/libxl.h       Fri Jul 23 17:39:32 2010 +0100
@@ -25,9 +25,12 @@ struct libxl_dominfo {
 struct libxl_dominfo {
     uint8_t uuid[16];
     uint32_t domid;
+    uint8_t running:1;
+    uint8_t blocked:1;
+    uint8_t paused:1;
+    uint8_t shutdown:1;
+    uint8_t crashed:1;
     uint8_t dying:1;
-    uint8_t paused:1;
-    uint8_t running:1;
     uint64_t max_memkb;
     uint64_t cpu_time;
     uint32_t vcpu_max_id;
diff -r 267ddd7fa11f -r 1c1b02487b57 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jul 23 17:35:59 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Jul 23 17:39:32 2010 +0100
@@ -1920,13 +1920,16 @@ void list_domains(int verbose)
     }
     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",
+        printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
                 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].blocked ? 'b' : '-',
                 info[i].paused ? 'p' : '-',
+                info[i].shutdown ? 's' : '-',
+                info[i].crashed ? 'c' : '-',
                 info[i].dying ? 'd' : '-',
                 ((float)info[i].cpu_time / 1e9));
         if (verbose) {

_______________________________________________
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®.