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 2 of 9] libxl: return libxl_dominfo from libxl_event_

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 2 of 9] libxl: return libxl_dominfo from libxl_event_get_domain_death_info
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 26 Jul 2010 11:56:46 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 26 Jul 2010 04:02:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1280141804@xxxxxxxxxxxxxxxxxxxxx>
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
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1280140562 -3600
# Node ID f6300d42a667cf6a1a02fc065ecd9eaea0e10ecc
# Parent  7a0c37f2a9b51ac012a32bcf6ab222580e7cac94
libxl: return libxl_dominfo from libxl_event_get_domain_death_info

Removes a libxc data type from the libxl interface.


Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 7a0c37f2a9b5 -r f6300d42a667 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jul 26 11:36:02 2010 +0100
+++ b/tools/libxl/libxl.c       Mon Jul 26 11:36:02 2010 +0100
@@ -405,8 +405,6 @@ static void xcinfo2xlinfo(const xc_domai
 static void xcinfo2xlinfo(const xc_domaininfo_t *xcinfo,
                           struct libxl_dominfo *xlinfo)
 {
-    unsigned int shutdown_reason;
-
     memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
     xlinfo->domid = xcinfo->domain;
 
@@ -416,12 +414,28 @@ static void xcinfo2xlinfo(const xc_domai
     xlinfo->blocked  = !!(xcinfo->flags&XEN_DOMINF_blocked);
     xlinfo->running  = !!(xcinfo->flags&XEN_DOMINF_running);
     xlinfo->crashed  = 0;
+    xlinfo->shutdown_reason  = -1;
 
-    shutdown_reason = (xcinfo->flags>>XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask;
-
-    if ( xlinfo->shutdown && (shutdown_reason == SHUTDOWN_crash) ) {
-        xlinfo->shutdown = 0;
-        xlinfo->crashed  = 1;
+    if (xlinfo->shutdown) {
+        switch ((xcinfo->flags>>XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask) {
+        case SHUTDOWN_poweroff:
+            xlinfo->shutdown_reason = LIBXL_SHUTDOWN_POWEROFF;
+            break;
+        case SHUTDOWN_reboot:
+            xlinfo->shutdown_reason = LIBXL_SHUTDOWN_REBOOT;
+            break;
+        case SHUTDOWN_suspend:
+            xlinfo->shutdown_reason = LIBXL_SHUTDOWN_SUSPEND;
+            break;
+        case SHUTDOWN_crash:
+            xlinfo->shutdown_reason = LIBXL_SHUTDOWN_CRASH;
+            xlinfo->shutdown = 0;
+            xlinfo->crashed  = 1;
+            break;
+        case SHUTDOWN_watchdog:
+            xlinfo->shutdown_reason = LIBXL_SHUTDOWN_WATCHDOG;
+            break;
+        }
     }
 
     xlinfo->max_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages);
@@ -707,20 +721,19 @@ int libxl_free_waiter(libxl_waiter *wait
     return 0;
 }
 
-int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_domaininfo_t *info)
+int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, struct libxl_dominfo *info)
 {
     int rc = 0, ret;
+    if (event && event->type == LIBXL_EVENT_DOMAIN_DEATH) {
+        ret = libxl_domain_info(ctx, info, domid);
 
-    if (event && event->type == LIBXL_EVENT_DOMAIN_DEATH) {
-        ret = xc_domain_getinfolist(ctx->xch, domid, 1, info);
-        if (ret == 1 && info->domain == domid) {
-                if (info->flags & XEN_DOMINF_running ||
-                    (!(info->flags & XEN_DOMINF_shutdown) && !(info->flags & 
XEN_DOMINF_dying)))
+        if (ret == 0 && info->domid == domid) {
+            if (info->running || (!info->shutdown && !info->dying && 
!info->crashed))
                     goto out;
                 rc = 1;
                 goto out;
         }
-        memset(info, 0, sizeof(xc_dominfo_t));
+        memset(info, 0, sizeof(*info));
         rc = 1;
         goto out;
     }
diff -r 7a0c37f2a9b5 -r f6300d42a667 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Jul 26 11:36:02 2010 +0100
+++ b/tools/libxl/libxl.h       Mon Jul 26 11:36:02 2010 +0100
@@ -22,6 +22,14 @@
 #include <xs.h>
 #include <sys/wait.h> /* for pid_t */
 
+enum libxl_shutdown_reason {
+    LIBXL_SHUTDOWN_POWEROFF,  /* Domain exited normally. Clean up and kill. */
+    LIBXL_SHUTDOWN_REBOOT,    /* Clean up, kill, and then restart.          */
+    LIBXL_SHUTDOWN_SUSPEND,   /* Clean up, save suspend info, kill.         */
+    LIBXL_SHUTDOWN_CRASH,     /* Tell controller we've crashed.             */
+    LIBXL_SHUTDOWN_WATCHDOG,  /* Restart because watchdog time expired.     */
+};
+
 struct libxl_dominfo {
     uint8_t uuid[16];
     uint32_t domid;
@@ -31,6 +39,8 @@ struct libxl_dominfo {
     uint8_t shutdown:1;
     uint8_t crashed:1;
     uint8_t dying:1;
+    enum libxl_shutdown_reason shutdown_reason;
+
     uint64_t max_memkb;
     uint64_t cpu_time;
     uint32_t vcpu_max_id;
@@ -385,7 +395,7 @@ int libxl_free_event(libxl_event *event)
 int libxl_free_event(libxl_event *event);
 int libxl_free_waiter(libxl_waiter *waiter);
 
-int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, xc_domaininfo_t *info);
+int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, struct libxl_dominfo *info);
 int libxl_event_get_disk_eject_info(struct libxl_ctx *ctx, uint32_t domid, 
libxl_event *event, libxl_device_disk *disk);
 
 int libxl_domain_rename(struct libxl_ctx *ctx, uint32_t domid,
diff -r 7a0c37f2a9b5 -r f6300d42a667 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Jul 26 11:36:02 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Mon Jul 26 11:36:02 2010 +0100
@@ -1335,7 +1335,7 @@ start:
     while (1) {
         int ret;
         fd_set rfds;
-        xc_domaininfo_t info;
+        struct libxl_dominfo info;
         libxl_event event;
         libxl_device_disk disk;
         memset(&info, 0x00, sizeof(xc_domaininfo_t));
@@ -1351,11 +1351,10 @@ start:
             case LIBXL_EVENT_DOMAIN_DEATH:
                 if (libxl_event_get_domain_death_info(&ctx, domid, &event, 
&info)) {
                     LOG("Domain %d is dead", domid);
-                    if (info.flags & XEN_DOMINF_dying || (info.flags & 
XEN_DOMINF_shutdown && (((info.flags >> XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask) != SHUTDOWN_suspend))) {
+                    if (info.crashed || info.dying || (info.shutdown && 
info.shutdown_reason != SHUTDOWN_suspend)) {
                         LOG("Domain %d needs to be clean: destroying the 
domain", domid);
                         libxl_domain_destroy(&ctx, domid, 0);
-                        if (info.flags & XEN_DOMINF_shutdown &&
-                            (((info.flags >> XEN_DOMINF_shutdownshift) & 
XEN_DOMINF_shutdownmask) == SHUTDOWN_reboot)) {
+                        if (info.shutdown && info.shutdown_reason == 
SHUTDOWN_reboot) {
                             libxl_free_waiter(w1);
                             libxl_free_waiter(w2);
                             free(w1);

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

<Prev in Thread] Current Thread [Next in Thread>