All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 1/2]xl: Add "xl sysrq" command
Date: Wed, 12 May 2010 10:52:52 +0800	[thread overview]
Message-ID: <4BEA1804.5050104@cn.fujitsu.com> (raw)

Add "xl sysrq" command, a clone of "xm sysrq".

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

diff -r d77a88f938c6 -r feb1b75800d6 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Tue May 11 14:05:28 2010 +0100
+++ b/tools/libxl/libxl.c	Wed May 12 18:35:58 2010 +0800
@@ -2629,3 +2629,13 @@
 
     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 d77a88f938c6 -r feb1b75800d6 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Tue May 11 14:05:28 2010 +0100
+++ b/tools/libxl/libxl.h	Wed May 12 18:35:58 2010 +0800
@@ -481,5 +481,6 @@
                                   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 d77a88f938c6 -r feb1b75800d6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue May 11 14:05:28 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 12 18:35:58 2010 +0800
@@ -3058,3 +3058,43 @@
 
     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 d77a88f938c6 -r feb1b75800d6 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Tue May 11 14:05:28 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 12 18:35:58 2010 +0800
@@ -39,5 +39,6 @@
 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 d77a88f938c6 -r feb1b75800d6 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Tue May 11 14:05:28 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Wed May 12 18:35:58 2010 +0800
@@ -172,6 +172,11 @@
       "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);

-- 
Regards
Yang Hongyang

                 reply	other threads:[~2010-05-12  2:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4BEA1804.5050104@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.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.