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

Re: [Xen-devel] [PATCH] new commands "xl reboot" & "xl shutdown"

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] new commands "xl reboot" & "xl shutdown"
From: Gihan Munasinghe <GMunasinghe@xxxxxxxxxxxx>
Date: Tue, 01 Jun 2010 23:51:08 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 01 Jun 2010 15:52:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C82A6297.16584%keir.fraser@xxxxxxxxxxxxx>
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>
References: <C82A6297.16584%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.24 (Macintosh/20100228)

This is still against a very old version of xen-unstable.

In your repo do:
hg pull -u http://xenbits.xensource.com/staging/xen-unstable.hg

Then re-base your patch to that.

 -- Keir




Hi
Re did the patch for the latest unstable release see attached

xl: adds shutdown and reboot commands
libxl : remote shutdown to work for pure hvm domains

Signed-off-by: Gihan Munasinghe <GMunasinghe@xxxxxxxxxxxx>

Thanks
Gihan
diff -Nuar a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       2010-06-01 23:32:43.000000000 +0100
+++ b/tools/libxl/libxl.c       2010-06-01 23:42:32.000000000 +0100
@@ -550,12 +550,12 @@
     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 -Nuar a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  2010-06-01 23:32:43.000000000 +0100
+++ b/tools/libxl/xl_cmdimpl.c  2010-06-01 23:42:32.000000000 +0100
@@ -1160,6 +1160,7 @@
                             free(w1);
                             free(w2);
                             LOG("Done. Rebooting now");
+                            sleep(2);/*Fix Me: If this sleep is not there the 
domain creation failes sometimes*/
                             goto start;
                         }
                         LOG("Done. Exiting now");
@@ -1623,6 +1624,22 @@
     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 +2392,57 @@
     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 -Nuar a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c 2010-06-01 23:32:43.000000000 +0100
+++ b/tools/libxl/xl_cmdtable.c 2010-06-01 23:42:32.000000000 +0100
@@ -35,6 +35,16 @@
       "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",
diff -Nuar a/tools/libxl/xl.h b/tools/libxl/xl.h
--- a/tools/libxl/xl.h  2010-06-01 23:32:43.000000000 +0100
+++ b/tools/libxl/xl.h  2010-06-01 23:42:32.000000000 +0100
@@ -40,6 +40,8 @@
 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);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • Re: [Xen-devel] [PATCH] new commands "xl reboot" & "xl shutdown", Gihan Munasinghe <=