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-changelog

[Xen-changelog] [xen-unstable] xl: support -w (wait) option in xl shutdo

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: support -w (wait) option in xl shutdown
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 02 Nov 2010 04:50:26 -0700
Delivery-date: Tue, 02 Nov 2010 04:52:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1288264608 -3600
# Node ID 902fdaaa1fe6e081bb1d8acbc21ed81931556f4c
# Parent  951222c08589729770af022dd4f5d0ed41bea233
xl: support -w (wait) option in xl shutdown

improves compatibility with xm.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff -r 951222c08589 -r 902fdaaa1fe6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Oct 28 12:15:41 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Oct 28 12:16:48 2010 +0100
@@ -2395,12 +2395,47 @@ static void destroy_domain(char *p)
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
 }
 
-static void shutdown_domain(char *p)
+static void shutdown_domain(char *p, int wait)
 {
     int rc;
+
     find_domain(p);
     rc=libxl_domain_shutdown(&ctx, domid, 0);
     if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n.",rc);exit(-1); }
+
+    if (wait) {
+        libxl_waiter waiter;
+        int fd;
+
+        libxl_wait_for_domain_death(&ctx, domid, &waiter);
+
+        libxl_get_wait_fd(&ctx, &fd);
+
+        while (wait) {
+            fd_set rfds;
+            libxl_event event;
+            libxl_dominfo info;
+
+            FD_ZERO(&rfds);
+            FD_SET(fd, &rfds);
+
+            if (!select(fd + 1, &rfds, NULL, NULL, NULL))
+                continue;
+
+            libxl_get_event(&ctx, &event);
+
+            if (event.type == LIBXL_EVENT_DOMAIN_DEATH) {
+                if (libxl_event_get_domain_death_info(&ctx, domid, &event, 
&info) < 0)
+                    continue;
+
+                LOG("Domain %d is dead", domid);
+                wait = 0;
+            }
+
+            libxl_free_event(&event);
+        }
+        libxl_free_waiter(&waiter);
+    }
 }
 
 static void reboot_domain(char *p)
@@ -3220,13 +3255,17 @@ int main_shutdown(int argc, char **argv)
 int main_shutdown(int argc, char **argv)
 {
     int opt;
+    int wait = 0;
     char *p;
 
-    while ((opt = getopt(argc, argv, "h")) != -1) {
+    while ((opt = getopt(argc, argv, "hw")) != -1) {
         switch (opt) {
         case 'h':
             help("shutdown");
             return 0;
+        case 'w':
+            wait = 1;
+            break;
         default:
             fprintf(stderr, "option not supported\n");
             break;
@@ -3239,7 +3278,7 @@ int main_shutdown(int argc, char **argv)
 
     p = argv[optind];
 
-    shutdown_domain(p);
+    shutdown_domain(p, wait);
     return 0;
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: support -w (wait) option in xl shutdown, Xen patchbot-unstable <=