[PATCH V2 3/5] virsh: add 'sysrq' command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All domainSendSysrq related API should be manageable from
the virsh command line. So, expose 'virsh sysrq' command.

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 tools/virsh-domain.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 750411b..6a1e4fd 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))
+        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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]