All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl/xl: correctly report domain state
@ 2010-07-23 10:43 Ian Campbell
  2010-07-23 11:02 ` Vincent Hanquez
  2010-07-23 12:18 ` Stefano Stabellini
  0 siblings, 2 replies; 7+ messages in thread
From: Ian Campbell @ 2010-07-23 10:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1279881736 -3600
# Node ID 006ec67363ab2651d712f9e3f0f48bf1d408396a
# Parent  b880a9fc98d14aad8464fb1a5c690f6b4bc14e03
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@citrix.com>

diff -r b880a9fc98d1 -r 006ec67363ab tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/libxl.c	Fri Jul 23 11:42:16 2010 +0100
@@ -403,17 +403,26 @@ 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);
+
+    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 b880a9fc98d1 -r 006ec67363ab tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/libxl.h	Fri Jul 23 11:42:16 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 b880a9fc98d1 -r 006ec67363ab tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Fri Jul 23 11:42:16 2010 +0100
@@ -1872,13 +1872,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) {

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] libxl/xl: correctly report domain state
@ 2010-07-23 12:27 Ian Campbell
  2010-07-23 12:34 ` Stefano Stabellini
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2010-07-23 12:27 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1279888063 -3600
# Node ID 0b66e68f4e580a3ad60d1173c73cd343a90f536f
# Parent  b880a9fc98d14aad8464fb1a5c690f6b4bc14e03
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@citrix.com>

diff -r b880a9fc98d1 -r 0b66e68f4e58 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/libxl.c	Fri Jul 23 13:27:43 2010 +0100
@@ -403,17 +403,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 b880a9fc98d1 -r 0b66e68f4e58 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/libxl.h	Fri Jul 23 13:27:43 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 b880a9fc98d1 -r 0b66e68f4e58 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Jul 22 17:32:08 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Fri Jul 23 13:27:43 2010 +0100
@@ -1872,13 +1872,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) {

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-23 12:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23 10:43 [PATCH] libxl/xl: correctly report domain state Ian Campbell
2010-07-23 11:02 ` Vincent Hanquez
2010-07-23 11:43   ` Ian Campbell
2010-07-23 12:18 ` Stefano Stabellini
2010-07-23 12:21   ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2010-07-23 12:27 Ian Campbell
2010-07-23 12:34 ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.