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

[libvirt] [PATCH 09/10] Implement virsh qemu-monitor-command.



Signed-off-by: Chris Lalancette <clalance redhat com>
---
 tools/Makefile.am |    1 +
 tools/virsh.c     |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 33a3216..b69de75 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -39,6 +39,7 @@ virsh_LDADD =							\
 		$(STATIC_BINARIES)				\
 		$(WARN_CFLAGS)					\
 		../src/libvirt.la				\
+		../src/libvirt-qemu.la				\
 		../gnulib/lib/libgnu.la				\
 		$(VIRSH_LIBS)
 virsh_CFLAGS = 							\
diff --git a/tools/virsh.c b/tools/virsh.c
index b2a1538..8b1a355 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -50,6 +50,7 @@
 #include "util.h"
 #include "memory.h"
 #include "xml.h"
+#include "libvirt/libvirt-qemu.h"
 
 static char *progname;
 
@@ -8627,6 +8628,58 @@ cleanup:
 }
 
 /*
+ * "qemu-monitor-command" command
+ */
+static const vshCmdInfo info_qemu_monitor_command[] = {
+    {"help", N_("Qemu Monitor Command")},
+    {"desc", N_("Qemu Monitor Command")},
+    {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_qemu_monitor_command[] = {
+    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
+    {"cmd", VSH_OT_DATA, VSH_OFLAG_REQ, N_("command")},
+    {NULL, 0, 0, NULL}
+};
+
+static int
+cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom = NULL;
+    int ret = FALSE;
+    char *monitor_cmd;
+    char *result = NULL;
+
+    if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+        goto cleanup;
+
+    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    if (dom == NULL)
+        goto cleanup;
+
+    monitor_cmd = vshCommandOptString(cmd, "cmd", NULL);
+    if (monitor_cmd == NULL) {
+        vshError(ctl, "%s", _("missing monitor command"));
+        goto cleanup;
+    }
+
+    if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, 0) < 0)
+        goto cleanup;
+
+    fprintf(stdout, "%s\n", result);
+
+    ret = TRUE;
+
+cleanup:
+    VIR_FREE(result);
+    if (dom)
+        virDomainFree(dom);
+
+    return ret;
+}
+
+
+/*
  * Commands
  */
 static const vshCmdDef commands[] = {
@@ -8788,6 +8841,8 @@ static const vshCmdDef commands[] = {
     {"snapshot-list", cmdSnapshotList, opts_snapshot_list, info_snapshot_list},
     {"snapshot-revert", cmdDomainSnapshotRevert, opts_snapshot_revert, info_snapshot_revert},
 
+    {"qemu-monitor-command", cmdQemuMonitorCommand, opts_qemu_monitor_command, info_qemu_monitor_command},
+
     {NULL, NULL, NULL, NULL}
 };
 
-- 
1.6.6.1


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