Mailing List Archive

[xen-unstable] xl: Add "xl sysrq" command, a clone of "xm sysrq".
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1273650727 -3600
# Node ID 85df4f6f7023d4921bcd55e982883e1b3dfba4e5
# Parent 727ccaaa6cceb33780f51c77e24f806939af7a53
xl: Add "xl sysrq" command, a clone of "xm sysrq".

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
---
tools/libxl/libxl.c | 10 ++++++++++
tools/libxl/libxl.h | 1 +
tools/libxl/xl_cmdimpl.c | 40 ++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdimpl.h | 1 +
tools/libxl/xl_cmdtable.c | 5 +++++
5 files changed, 57 insertions(+)

diff -r 727ccaaa6cce -r 85df4f6f7023 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed May 12 08:51:26 2010 +0100
+++ b/tools/libxl/libxl.c Wed May 12 08:52:07 2010 +0100
@@ -2629,3 +2629,13 @@ int libxl_send_trigger(struct libxl_ctx

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 -r 727ccaaa6cce -r 85df4f6f7023 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed May 12 08:51:26 2010 +0100
+++ b/tools/libxl/libxl.h Wed May 12 08:52:07 2010 +0100
@@ -481,5 +481,6 @@ int libxl_sched_credit_domain_set(struct
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 -r 727ccaaa6cce -r 85df4f6f7023 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed May 12 08:51:26 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed May 12 08:52:07 2010 +0100
@@ -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 -r 727ccaaa6cce -r 85df4f6f7023 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h Wed May 12 08:51:26 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h Wed May 12 08:52:07 2010 +0100
@@ -39,5 +39,6 @@ int main_domname(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 -r 727ccaaa6cce -r 85df4f6f7023 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Wed May 12 08:51:26 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed May 12 08:52:07 2010 +0100
@@ -172,6 +172,11 @@ struct cmd_spec cmd_table[] = {
"Send a trigger to a domain",
"<Domain> <nmi|reset|init|power|sleep> [<VCPU>]",
},
+ { "sysrq",
+ &main_sysrq,
+ "Send a sysrq to a domain",
+ "<Domain> <letter>",
+ },
};

int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog