All domainSendSysrq related API should be manageable from
the virsh command line. So, expose 'virsh sysrq' command.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
tools/virsh-domain.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 750411b..bffcc8e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12289,6 +12289,54 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
return ret >= 0;
}
+/*
+ * "sysrq" command
+ */
+static const vshCmdInfo info_sysrq[] = {
+ {.name = "help",
+ .data = N_("Send SysRq key to the guest")
+ },
+ {.name = "desc",
+ .data = N_("Send SysRq key to the guest")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_sysrq[] = {
+ {.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("domain name, id or uuid")
+ },
+ {.name = "key",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("the SysRq key")
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdSysrq(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom;
+ bool ret = false;
+ const char *key = NULL;
+
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "key", &key) < 0)
+ return false;
+
+ if (!(virDomainSendSysrq(dom, key[0], 0) < 0))
+ ret = true;
+
+ virDomainFree(dom);
+ return ret;
+}
+
+
const vshCmdDef domManagementCmds[] = {
{.name = "attach-device",
.handler = cmdAttachDevice,
@@ -12808,5 +12856,11 @@ const vshCmdDef domManagementCmds[] = {
.info = info_vncdisplay,
.flags = 0
},
+ {.name = "sysrq",
+ .handler = cmdSysrq,
+ .opts = opts_sysrq,
+ .info = info_sysrq,
+ .flags = 0
+ },
{.name = NULL}
};
--
1.8.4.5