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: adds shutdown and reboot commands

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: adds shutdown and reboot commands
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 02 Jun 2010 05:15:20 -0700
Delivery-date: Wed, 02 Jun 2010 05:16:17 -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 Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275472337 -3600
# Node ID 27e86dcdcfacabbb3ab93290c2b4fc51a27eaffc
# Parent  331b0a934a2033fa830915e080bbca9d8adf19b6
xl: adds shutdown and reboot commands
libxl : remote shutdown to work for pure hvm domains

Signed-off-by: Gihan Munasinghe <GMunasinghe@xxxxxxxxxxxx>
---
 tools/libxl/libxl.c       |    4 +-
 tools/libxl/xl.h          |    2 +
 tools/libxl/xl_cmdimpl.c  |   72 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c |   10 ++++++
 4 files changed, 86 insertions(+), 2 deletions(-)

diff -r 331b0a934a20 -r 27e86dcdcfac tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Jun 02 10:49:35 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Jun 02 10:52:17 2010 +0100
@@ -550,12 +550,12 @@ int libxl_domain_shutdown(struct libxl_c
     shutdown_path = libxl_sprintf(ctx, "%s/control/shutdown", dom_path);
 
     xs_write(ctx->xsh, XBT_NULL, shutdown_path, req_table[req], 
strlen(req_table[req]));
-    if (/* hvm */ 0) {
+    if (is_hvm(ctx,domid)) {
         unsigned long acpi_s_state = 0;
         unsigned long pvdriver = 0;
         xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_ACPI_S_STATE, 
&acpi_s_state);
         xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
-        if (!pvdriver && acpi_s_state != 0)
+        if (!pvdriver || acpi_s_state != 0)
             xc_domain_shutdown(ctx->xch, domid, req);
     }
     return 0;
diff -r 331b0a934a20 -r 27e86dcdcfac tools/libxl/xl.h
--- a/tools/libxl/xl.h  Wed Jun 02 10:49:35 2010 +0100
+++ b/tools/libxl/xl.h  Wed Jun 02 10:52:17 2010 +0100
@@ -40,6 +40,8 @@ int main_pause(int argc, char **argv);
 int main_pause(int argc, char **argv);
 int main_unpause(int argc, char **argv);
 int main_destroy(int argc, char **argv);
+int main_shutdown(int argc, char **argv);
+int main_reboot(int argc, char **argv);
 int main_list(int argc, char **argv);
 int main_list_vm(int argc, char **argv);
 int main_create(int argc, char **argv);
diff -r 331b0a934a20 -r 27e86dcdcfac tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Jun 02 10:49:35 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Jun 02 10:52:17 2010 +0100
@@ -1160,6 +1160,11 @@ start:
                             free(w1);
                             free(w2);
                             LOG("Done. Rebooting now");
+                            /*
+                             * XXX FIXME: If this sleep is not there then
+                             * domain re-creation fails sometimes.
+                             */
+                            sleep(2);
                             goto start;
                         }
                         LOG("Done. Exiting now");
@@ -1623,6 +1628,22 @@ void destroy_domain(char *p)
     if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
 }
 
+void shutdown_domain(char *p)
+{
+    int rc;
+    find_domain(p);
+    rc=libxl_domain_shutdown(&ctx, domid, 0);
+    if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n.",rc);exit(-1); }
+}
+
+void reboot_domain(char *p)
+{
+    int rc;
+    find_domain(p);
+    rc=libxl_domain_shutdown(&ctx, domid, 1);
+    if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1); }
+}
+
 void list_domains(int verbose)
 {
     struct libxl_dominfo *info;
@@ -2375,6 +2396,57 @@ int main_destroy(int argc, char **argv)
     exit(0);
 }
 
+int main_shutdown(int argc, char **argv)
+{
+    int opt;
+    char *p;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("shutdown");
+            exit(0);
+        default:
+            fprintf(stderr, "option not supported\n");
+            break;
+        }
+    }
+    if (optind >= argc) {
+        help("shutdown");
+        exit(2);
+    }
+
+    p = argv[optind];
+
+    shutdown_domain(p);
+    exit(0);
+}
+
+int main_reboot(int argc, char **argv)
+{
+    int opt;
+    char *p;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("reboot");
+            exit(0);
+        default:
+            fprintf(stderr, "option not supported\n");
+            break;
+        }
+    }
+    if (optind >= argc) {
+        help("reboot");
+        exit(2);
+    }
+
+    p = argv[optind];
+
+    reboot_domain(p);
+    exit(0);
+}
 int main_list(int argc, char **argv)
 {
     int opt, verbose = 0;
diff -r 331b0a934a20 -r 27e86dcdcfac tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Wed Jun 02 10:49:35 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed Jun 02 10:52:17 2010 +0100
@@ -35,6 +35,16 @@ struct cmd_spec cmd_table[] = {
       "Terminate a domain immediately",
       "<Domain>",
     },
+    { "shutdown",
+      &main_shutdown,
+      "Issue a shutdown signal to a domain",
+      "<Domain>",
+    },
+    { "reboot",
+      &main_reboot,
+      "Issue a reboot signal to a domain",
+      "<Domain>",
+    }, 
     { "pci-attach",
       &main_pciattach,
       "Insert a new pass-through pci device",

_______________________________________________
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: adds shutdown and reboot commands, Xen patchbot-unstable <=