* [PATCH] new commands "xl reboot" & "xl shutdown"
@ 2010-05-07 23:36 Gihan Munasinghe
2010-05-10 15:11 ` Stefano Stabellini
0 siblings, 1 reply; 10+ messages in thread
From: Gihan Munasinghe @ 2010-05-07 23:36 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
Guys
I patched xl to have "reboot" and "shutdown" commands.
I tested this with hvm domains with and and without pv drivers seems to
work, of course the os level reboot and shutdown will only happen if
there are pv drivers with the dom U.
Also the libxl_domain_shutdown was not working for hvm guests without pv
drivers, I did a small patch to that as well. (same way xend shutdown
works used || instead of a && ). I would appreciate if someone can test
this more with hvm and pv domains.
Let me know what you think
--
Gihan Munasinghe
R&D Team Leader
Flexiant Ltd.
www.flexiant.com
[-- Attachment #2: xen4-libxl-shutdown-reboot.patch --]
[-- Type: text/plain, Size: 6259 bytes --]
diff -Naur vanila/xen-4.0.0/tools/libxl/libxl.c xen4patch/xen-4.0.0/tools/libxl/libxl.c
--- vanila/xen-4.0.0/tools/libxl/libxl.c 2010-04-07 17:12:04.000000000 +0100
+++ xen4patch/xen-4.0.0/tools/libxl/libxl.c 2010-05-07 23:14:26.000000000 +0100
@@ -400,12 +400,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 (/* hvm */ 1) {
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 vanila/xen-4.0.0/tools/libxl/xl.c xen4patch/xen-4.0.0/tools/libxl/xl.c
--- vanila/xen-4.0.0/tools/libxl/xl.c 2010-04-07 17:12:04.000000000 +0100
+++ xen4patch/xen-4.0.0/tools/libxl/xl.c 2010-05-08 00:19:51.000000000 +0100
@@ -702,9 +702,6 @@
if (debug)
printf_info(&info1, &info2, disks, num_disks, vifs, num_vifs, pcidevs, num_pcidevs, vfbs, num_vfbs, vkbs, num_vkbs, &dm_info);
-start:
- domid = 0;
-
if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
fprintf(stderr, "cannot init xl context\n");
return;
@@ -712,6 +709,9 @@
libxl_ctx_set_log(&ctx, log_callback, NULL);
+start:
+ domid = 0;
+
ret = libxl_domain_make(&ctx, &info1, &domid);
if (ret) {
fprintf(stderr, "cannot make domain: %d\n", ret);
@@ -830,8 +830,9 @@
libxl_free_waiter(w2);
free(w1);
free(w2);
- libxl_ctx_free(&ctx);
LOG("Done. Rebooting now");
+ sleep(2);/*Fix Me: The sleep is put here to slowdown the recreation of the domain
+ If this sleep it not there, hvm_domain creation failes sometimes*/
goto start;
}
LOG("Done. Exiting now");
@@ -864,6 +865,8 @@
printf(" create create a domain from config file <filename>\n\n");
printf(" list list information about all domains\n\n");
printf(" destroy terminate a domain immediately\n\n");
+ printf(" shutdown issue a shutdown signal to a domain\n\n");
+ printf(" reboot issue a reboot signal to a domain\n\n");
printf(" pci-attach insert a new pass-through pci device\n\n");
printf(" pci-detach remove a domain's pass-through pci device\n\n");
printf(" pci-list list pass-through pci devices for a domain\n\n");
@@ -917,6 +920,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");
@@ -1352,6 +1361,43 @@
libxl_domain_destroy(&ctx, domid, 0);
}
+void shutdown_domain(char *p)
+{
+ struct libxl_ctx ctx;
+ uint32_t domid;
+
+ if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
+ fprintf(stderr, "cannot init xl context\n");
+ return;
+ }
+ libxl_ctx_set_log(&ctx, log_callback, NULL);
+
+ if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) {
+ fprintf(stderr, "%s is an invalid domain identifier\n", p);
+ exit(2);
+ }
+ libxl_domain_shutdown(&ctx, domid, 0);
+}
+
+void reboot_domain(char *p)
+{
+ struct libxl_ctx ctx;
+ uint32_t domid;
+
+ if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
+ fprintf(stderr, "cannot init xl context\n");
+ return;
+ }
+ libxl_ctx_set_log(&ctx, log_callback, NULL);
+
+ if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) {
+ fprintf(stderr, "%s is an invalid domain identifier\n", p);
+ exit(2);
+ }
+ libxl_domain_shutdown(&ctx, domid, 1);
+}
+
+
void list_domains(void)
{
struct libxl_ctx ctx;
@@ -1596,6 +1642,58 @@
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;
@@ -1738,6 +1836,10 @@
main_list_vm(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "destroy")) {
main_destroy(argc - 1, argv + 1);
+ } else if (!strcmp(argv[1], "shutdown")) {
+ main_shutdown(argc - 1, argv + 1);
+ } else if (!strcmp(argv[1], "reboot")) {
+ main_reboot(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "pci-attach")) {
main_pciattach(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "pci-detach")) {
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
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
0 siblings, 2 replies; 10+ messages in thread
From: Stefano Stabellini @ 2010-05-10 15:11 UTC (permalink / raw)
To: Gihan Munasinghe; +Cc: xen-devel
On Sat, 8 May 2010, Gihan Munasinghe wrote:
> Guys
>
> I patched xl to have "reboot" and "shutdown" commands.
> I tested this with hvm domains with and and without pv drivers seems to
> work, of course the os level reboot and shutdown will only happen if
> there are pv drivers with the dom U.
>
> Also the libxl_domain_shutdown was not working for hvm guests without pv
> drivers, I did a small patch to that as well. (same way xend shutdown
> works used || instead of a && ). I would appreciate if someone can test
> this more with hvm and pv domains.
>
> Let me know what you think
>
Thanks for the patch!
It is mostly correct, however libxenlight changed quite a bit since xen
4.0 so could you please port your changes to xen-unstable?
> diff -Naur vanila/xen-4.0.0/tools/libxl/libxl.c xen4patch/xen-4.0.0/tools/libxl/libxl.c
> --- vanila/xen-4.0.0/tools/libxl/libxl.c 2010-04-07 17:12:04.000000000 +0100
> +++ xen4patch/xen-4.0.0/tools/libxl/libxl.c 2010-05-07 23:14:26.000000000 +0100
> @@ -400,12 +400,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 (/* hvm */ 1) {
> 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;
this should be correct
> diff -Naur vanila/xen-4.0.0/tools/libxl/xl.c xen4patch/xen-4.0.0/tools/libxl/xl.c
> --- vanila/xen-4.0.0/tools/libxl/xl.c 2010-04-07 17:12:04.000000000 +0100
> +++ xen4patch/xen-4.0.0/tools/libxl/xl.c 2010-05-08 00:19:51.000000000 +0100
> @@ -702,9 +702,6 @@
> if (debug)
> printf_info(&info1, &info2, disks, num_disks, vifs, num_vifs, pcidevs, num_pcidevs, vfbs, num_vfbs, vkbs, num_vkbs, &dm_info);
>
> -start:
> - domid = 0;
> -
> if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
> fprintf(stderr, "cannot init xl context\n");
> return;
> @@ -712,6 +709,9 @@
>
> libxl_ctx_set_log(&ctx, log_callback, NULL);
>
> +start:
> + domid = 0;
> +
> ret = libxl_domain_make(&ctx, &info1, &domid);
> if (ret) {
> fprintf(stderr, "cannot make domain: %d\n", ret);
this is probably not needed anymore
> @@ -830,8 +830,9 @@
> libxl_free_waiter(w2);
> free(w1);
> free(w2);
> - libxl_ctx_free(&ctx);
> LOG("Done. Rebooting now");
> + sleep(2);/*Fix Me: The sleep is put here to slowdown the recreation of the domain
> + If this sleep it not there, hvm_domain creation failes sometimes*/
> goto start;
> }
> LOG("Done. Exiting now");
since we don't free the ctx anymore here, it might be unnecessary.
The other changes look OK but we have a command table now, so they need
to be adapted.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-10 15:11 ` Stefano Stabellini
@ 2010-05-11 6:51 ` Gihan Munasinghe
2010-05-12 15:57 ` Gihan Munasinghe
1 sibling, 0 replies; 10+ messages in thread
From: Gihan Munasinghe @ 2010-05-11 6:51 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
Stefano Stabellini wrote:
> On Sat, 8 May 2010, Gihan Munasinghe wrote:
>
>> Guys
>>
>> I patched xl to have "reboot" and "shutdown" commands.
>>
>>
>>
>
> Thanks for the patch!
> It is mostly correct, however libxenlight changed quite a bit since xen
> 4.0 so could you please port your changes to xen-unstable?
>
>
I'll do the port and resubmit the patch
Thanks
Gihan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
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
1 sibling, 1 reply; 10+ messages in thread
From: Gihan Munasinghe @ 2010-05-12 15:57 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]
Stefano Stabellini wrote:
> On Sat, 8 May 2010, Gihan Munasinghe wrote:
>
>> Guys
>>
>> I patched xl to have "reboot" and "shutdown" commands.
>> I tested this with hvm domains with and and without pv drivers seems to
>> work, of course the os level reboot and shutdown will only happen if
>> there are pv drivers with the dom U.
>>
>> Also the libxl_domain_shutdown was not working for hvm guests without pv
>> drivers, I did a small patch to that as well. (same way xend shutdown
>> works used || instead of a && ). I would appreciate if someone can test
>> this more with hvm and pv domains.
>>
>> Let me know what you think
>>
>>
>
> Thanks for the patch!
> It is mostly correct, however libxenlight changed quite a bit since xen
> 4.0 so could you please port your changes to xen-unstable?
>
>
>
The Patch is ported to xen-unstable see attached
>>
>> +start:
>> + domid = 0;
>> +
>> ret = libxl_domain_make(&ctx, &info1, &domid);
>> if (ret) {
>> fprintf(stderr, "cannot make domain: %d\n", ret);
>>
>
> this is probably not needed anymore
>
>
Yes this fix is not needed anymore
>
>> LOG("Done. Rebooting now");
>> + sleep(2);/*Fix Me: The sleep is put here to slowdown the recreation of the domain
>> + If this sleep it not there, hvm_domain creation failes sometimes*/
>> goto start;
>> }
>> LOG("Done. Exiting now");
>>
>
> since we don't free the ctx anymore here, it might be unnecessary.
> The other changes look OK but we have a command table now, so they need
> to be adapted.
>
>
The sleep is still needed, if not libxl_* calls fails sometimes. I'll do
more debugging with in the calls it self and see, but for now the
sleep() seems to do the trick.
Thanks
Gihan
[-- Attachment #2: xen4-libxl-shutdown-reboot-xenunstable.patch --]
[-- Type: text/plain, Size: 4984 bytes --]
diff -Naur libxl/libxl.c libxl-patch/libxl.c
--- libxl/libxl.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/libxl.c 2010-05-12 16:24:42.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 (/* hvm */ 1) {
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 libxl/xl_cmdimpl.c libxl-patch/xl_cmdimpl.c
--- libxl/xl_cmdimpl.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdimpl.c 2010-05-12 16:46:12.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 libxl/xl_cmdimpl.h libxl-patch/xl_cmdimpl.h
--- libxl/xl_cmdimpl.h 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdimpl.h 2010-05-11 12:51:14.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 libxl/xl_cmdtable.c libxl-patch/xl_cmdtable.c
--- libxl/xl_cmdtable.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdtable.c 2010-05-11 13:28:31.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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-12 15:57 ` Gihan Munasinghe
@ 2010-05-12 16:34 ` Vincent Hanquez
2010-05-12 17:09 ` Gihan Munasinghe
0 siblings, 1 reply; 10+ messages in thread
From: Vincent Hanquez @ 2010-05-12 16:34 UTC (permalink / raw)
To: Gihan Munasinghe; +Cc: Xen Devel
On 12/05/10 16:57, Gihan Munasinghe wrote:
> The sleep is still needed, if not libxl_* calls fails sometimes. I'll do
> more debugging with in the calls it self and see, but for now the
> sleep() seems to do the trick.
diff -Naur libxl/libxl.c libxl-patch/libxl.c
--- libxl/libxl.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/libxl.c 2010-05-12 16:24:42.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 (/* hvm */ 1) {
unsigned long acpi_s_state = 0;
unsigned long pvdriver = 0;
you can't just switch from 0 to 1, otherwise pv domains will just fails
(although i see we're not testing xc_get_hvm_param return values either).
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.
--
Vincent
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-12 16:34 ` Vincent Hanquez
@ 2010-05-12 17:09 ` Gihan Munasinghe
2010-05-13 7:41 ` Keir Fraser
0 siblings, 1 reply; 10+ messages in thread
From: Gihan Munasinghe @ 2010-05-12 17:09 UTC (permalink / raw)
To: Vincent Hanquez; +Cc: Xen Devel
[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]
Vincent Hanquez wrote:
> On 12/05/10 16:57, Gihan Munasinghe wrote:
>> The sleep is still needed, if not libxl_* calls fails sometimes. I'll do
>> more debugging with in the calls it self and see, but for now the
>> sleep() seems to do the trick.
>
> diff -Naur libxl/libxl.c libxl-patch/libxl.c
> --- libxl/libxl.c 2010-05-11 09:37:50.000000000 +0100
> +++ libxl-patch/libxl.c 2010-05-12 16:24:42.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 (/* hvm */ 1) {
> unsigned long acpi_s_state = 0;
> unsigned long pvdriver = 0;
>
> you can't just switch from 0 to 1, otherwise pv domains will just
> fails (although i see we're not testing xc_get_hvm_param return values
> either).
I though PV domain would have been captured by..
xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
if (!pvdriver .. )
>
> 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.
I tested with hvm with and with out pv drivers. seems to work. Would be
appreciate if someone can test in full pv domains.
Thanks
--
Gihan
[-- Attachment #2: xen4-libxl-shutdown-reboot-xenunstable.patch --]
[-- Type: text/plain, Size: 4990 bytes --]
diff -Naur libxl/libxl.c libxl-patch/libxl.c
--- libxl/libxl.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/libxl.c 2010-05-12 17:43:51.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 libxl/xl_cmdimpl.c libxl-patch/xl_cmdimpl.c
--- libxl/xl_cmdimpl.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdimpl.c 2010-05-12 16:46:12.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 libxl/xl_cmdimpl.h libxl-patch/xl_cmdimpl.h
--- libxl/xl_cmdimpl.h 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdimpl.h 2010-05-11 12:51:14.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 libxl/xl_cmdtable.c libxl-patch/xl_cmdtable.c
--- libxl/xl_cmdtable.c 2010-05-11 09:37:50.000000000 +0100
+++ libxl-patch/xl_cmdtable.c 2010-05-11 13:28:31.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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-12 17:09 ` Gihan Munasinghe
@ 2010-05-13 7:41 ` Keir Fraser
2010-05-31 19:03 ` Gihan Munasinghe
0 siblings, 1 reply; 10+ messages in thread
From: Keir Fraser @ 2010-05-13 7:41 UTC (permalink / raw)
To: Gihan Munasinghe, Vincent Hanquez; +Cc: Xen Devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-13 7:41 ` Keir Fraser
@ 2010-05-31 19:03 ` Gihan Munasinghe
2010-06-01 6:09 ` Keir Fraser
0 siblings, 1 reply; 10+ messages in thread
From: Gihan Munasinghe @ 2010-05-31 19:03 UTC (permalink / raw)
To: Keir Fraser; +Cc: Xen Devel, Vincent Hanquez
[-- 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-05-31 19:03 ` Gihan Munasinghe
@ 2010-06-01 6:09 ` Keir Fraser
2010-06-01 22:51 ` Gihan Munasinghe
0 siblings, 1 reply; 10+ messages in thread
From: Keir Fraser @ 2010-06-01 6:09 UTC (permalink / raw)
To: Gihan Munasinghe; +Cc: Xen Devel, Vincent Hanquez
On 31/05/2010 20:03, "Gihan Munasinghe" <GMunasinghe@flexiant.com> wrote:
> 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>
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] new commands "xl reboot" & "xl shutdown"
2010-06-01 6:09 ` Keir Fraser
@ 2010-06-01 22:51 ` Gihan Munasinghe
0 siblings, 0 replies; 10+ messages in thread
From: Gihan Munasinghe @ 2010-06-01 22:51 UTC (permalink / raw)
To: Keir Fraser; +Cc: Xen Devel
[-- Attachment #1: Type: text/plain, Size: 442 bytes --]
> 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@flexiant.com>
Thanks
Gihan
[-- Attachment #2: xen4-libxl-shutdown-reboot-xenunstable.patch --]
[-- Type: text/plain, Size: 4168 bytes --]
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);
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-06-01 22:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2010-06-01 6:09 ` Keir Fraser
2010-06-01 22:51 ` Gihan Munasinghe
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.