From: Gihan Munasinghe <GMunasinghe@flexiant.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: Xen Devel <xen-devel@lists.xensource.com>,
Vincent Hanquez <Vincent.Hanquez@eu.citrix.com>
Subject: Re: [PATCH] new commands "xl reboot" & "xl shutdown"
Date: Mon, 31 May 2010 20:03:55 +0100 [thread overview]
Message-ID: <4C04081B.4050402@flexiant.com> (raw)
In-Reply-To: <C8116BCE.14217%keir.fraser@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 789 bytes --]
Keir Fraser wrote:
> On 12/05/2010 18:09, "Gihan Munasinghe" <GMunasinghe@flexiant.com> wrote:
>
>
>>> the if (/* hvm */ 0) is because the function never properly tested if
>>> the domain is hvm or not. nowadays you have is_hvm(domid) function
>>> that can handily replace the hardcoded value.
>>>
>>>
>> Yes having is_hvm is much better than the hard coded values I have
>> changed that bit of code see attached patch.
>>
>
> Please port your patch to the tip of xen-unstable and re-post with changeset
> comment and signed-off-by-line.
>
> Thanks,
> Keir
>
>
>
>
>
Sorry for the very long delay see updated patch
xl: adds shutdown and reboot commands
libxl : remote shutdown to work for pure hvm domains
Signed-off-by: Gihan Munasinghe <GMunasinghe@flexiant.com>
[-- Attachment #2: xen4-libxl-shutdown-reboot-xenunstable.patch --]
[-- Type: text/plain, Size: 5310 bytes --]
diff -Naur xen-unstable.hg/tools/libxl/libxl.c xen-unstable.hg.p/tools/libxl/libxl.c
--- xen-unstable.hg/tools/libxl/libxl.c 2010-05-11 09:37:50.000000000 +0100
+++ xen-unstable.hg.p/tools/libxl/libxl.c 2010-05-31 19:31:02.000000000 +0100
@@ -538,12 +538,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 -Naur xen-unstable.hg/tools/libxl/xl_cmdimpl.c xen-unstable.hg.p/tools/libxl/xl_cmdimpl.c
--- xen-unstable.hg/tools/libxl/xl_cmdimpl.c 2010-05-11 09:37:50.000000000 +0100
+++ xen-unstable.hg.p/tools/libxl/xl_cmdimpl.c 2010-05-31 19:31:02.000000000 +0100
@@ -1129,6 +1129,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");
@@ -1226,6 +1227,12 @@
} else if(!strcmp(command, "destroy")) {
printf("Usage: xl destroy <Domain>\n\n");
printf("Terminate a domain immediately.\n\n");
+ } else if(!strcmp(command, "shutdown")) {
+ printf("Usage: xl shutdown <Domain>\n\n");
+ printf("issue a shutdown signal to a domain.\n\n");
+ } else if(!strcmp(command, "reboot")) {
+ printf("Usage: xl reboot <Domain>\n\n");
+ printf("issue a reboot signal to a domain.\n\n");
} else if (!strcmp(command, "console")) {
printf("Usage: xl console <Domain>\n\n");
printf("Attach to domain's console.\n\n");
@@ -1591,6 +1598,23 @@
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;
@@ -2340,6 +2364,59 @@
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 -Naur xen-unstable.hg/tools/libxl/xl_cmdimpl.h xen-unstable.hg.p/tools/libxl/xl_cmdimpl.h
--- xen-unstable.hg/tools/libxl/xl_cmdimpl.h 2010-05-11 09:37:50.000000000 +0100
+++ xen-unstable.hg.p/tools/libxl/xl_cmdimpl.h 2010-05-31 19:31:02.000000000 +0100
@@ -27,6 +27,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);
diff -Naur xen-unstable.hg/tools/libxl/xl_cmdtable.c xen-unstable.hg.p/tools/libxl/xl_cmdtable.c
--- xen-unstable.hg/tools/libxl/xl_cmdtable.c 2010-05-11 09:37:50.000000000 +0100
+++ xen-unstable.hg.p/tools/libxl/xl_cmdtable.c 2010-05-31 19:31:02.000000000 +0100
@@ -18,6 +18,8 @@
{ "create", &main_create, "create a domain from config file <filename>" },
{ "list", &main_list, "list information about all domains" },
{ "destroy", &main_destroy, "terminate a domain immediately" },
+ { "shutdown", &main_shutdown, "issue a shutdown signal to a domain" },
+ { "reboot", &main_reboot, "issue a reboot signal to a domain " },
{ "pci-attach", &main_pciattach, "insert a new pass-through pci device" },
{ "pci-detach", &main_pcidetach, "remove a domain's pass-through pci device" },
{ "pci-list", &main_pcilist, "list pass-through pci devices for a domain" },
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2010-05-31 19:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-07 23:36 [PATCH] new commands "xl reboot" & "xl shutdown" Gihan Munasinghe
2010-05-10 15:11 ` Stefano Stabellini
2010-05-11 6:51 ` Gihan Munasinghe
2010-05-12 15:57 ` Gihan Munasinghe
2010-05-12 16:34 ` Vincent Hanquez
2010-05-12 17:09 ` Gihan Munasinghe
2010-05-13 7:41 ` Keir Fraser
2010-05-31 19:03 ` Gihan Munasinghe [this message]
2010-06-01 6:09 ` Keir Fraser
2010-06-01 22:51 ` Gihan Munasinghe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C04081B.4050402@flexiant.com \
--to=gmunasinghe@flexiant.com \
--cc=Vincent.Hanquez@eu.citrix.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.