From: Keir Fraser Date: Wed, 12 May 2010 07:52:07 +0000 (+0100) Subject: xl: Add "xl sysrq" command, a clone of "xm sysrq". X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12186 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c614ef19d3eaf000f08f142ae4c3831bfa06bd93;p=xen.git xl: Add "xl sysrq" command, a clone of "xm sysrq". Signed-off-by: Yang Hongyang --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 1b09294016..e031582083 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2629,3 +2629,13 @@ int libxl_send_trigger(struct libxl_ctx *ctx, uint32_t domid, char *trigger_name return rc; } + +int libxl_send_sysrq(struct libxl_ctx *ctx, uint32_t domid, char sysrq) +{ + char *dompath = libxl_xs_get_dompath(ctx, domid); + + libxl_xs_write(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/control/sysrq", dompath), "%c", sysrq); + + return 0; +} + diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 198d98daf2..ffed896f45 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -481,5 +481,6 @@ int libxl_sched_credit_domain_set(struct libxl_ctx *ctx, uint32_t domid, struct libxl_sched_credit *scinfo); int libxl_send_trigger(struct libxl_ctx *ctx, uint32_t domid, char *trigger_name, uint32_t vcpuid); +int libxl_send_sysrq(struct libxl_ctx *ctx, uint32_t domid, char sysrq); #endif /* LIBXL_H */ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index f1e03913fa..1e2304756e 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3058,3 +3058,43 @@ int main_trigger(int argc, char **argv) exit(0); } + + +int main_sysrq(int argc, char **argv) +{ + int opt; + char *sysrq = NULL; + char *dom = NULL; + + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { + case 'h': + help("sysrq"); + exit(0); + default: + fprintf(stderr, "option `%c' not supported.\n", opt); + break; + } + } + + dom = argv[optind++]; + if (!dom || !argv[optind]) { + fprintf(stderr, "'xl sysrq' requires 2 arguments.\n\n"); + help("sysrq"); + exit(1); + } + + find_domain(dom); + + sysrq = argv[optind]; + + if (sysrq[1] != '\0') { + fprintf(stderr, "Invalid sysrq.\n\n"); + help("sysrq"); + exit(1); + } + + libxl_send_sysrq(&ctx, domid, sysrq[0]); + + exit(0); +} diff --git a/tools/libxl/xl_cmdimpl.h b/tools/libxl/xl_cmdimpl.h index c53ba4e4b8..c08c5d1593 100644 --- a/tools/libxl/xl_cmdimpl.h +++ b/tools/libxl/xl_cmdimpl.h @@ -39,5 +39,6 @@ int main_domid(int argc, char **argv); int main_domname(int argc, char **argv); int main_rename(int argc, char **argv); int main_trigger(int argc, char **argv); +int main_sysrq(int argc, char **argv); void help(char *command); diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 3c43094631..33582a79d9 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -172,6 +172,11 @@ struct cmd_spec cmd_table[] = { "Send a trigger to a domain", " []", }, + { "sysrq", + &main_sysrq, + "Send a sysrq to a domain", + " ", + }, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);