# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# 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@xxxxxxxxxx>
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) {
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|