qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 10/21] qom: add plug_get QMP command


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 10/21] qom: add plug_get QMP command
Date: Sun, 24 Jul 2011 20:44:42 -0500

Signed-off-by: Anthony Liguori <address@hidden>
---
 monitor.c       |   35 +++++++++++++++++++++++++++++++++++
 qmp-commands.hx |    9 +++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/monitor.c b/monitor.c
index f17eb3a..1937e9f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1094,6 +1094,41 @@ static int do_plug_list(Monitor *mon, const QDict 
*qdict, QObject **ret_data)
     return 0;
 }
 
+static int do_plug_get(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    const char *name = qdict_get_str(qdict, "name");
+    Error *local_err = NULL;
+    QmpOutputVisitor *qov;
+    TypeInstance *inst;
+    Plug *plug;
+    Visitor *v;
+
+    qov = qmp_output_visitor_new();
+    v = qmp_output_get_visitor(qov);
+
+    inst = type_find_by_id(id);
+    if (inst == NULL) {
+        return -1;
+    }
+
+    plug = PLUG(inst);
+
+    plug_get_property(plug, name, v, &local_err);
+    if (local_err) {
+        error_free(local_err);
+        qmp_output_visitor_cleanup(qov);
+
+        return -1;
+    }
+
+    *ret_data = qmp_output_get_qobject(qov);
+
+    qmp_output_visitor_cleanup(qov);
+
+    return 0;
+}
+
 #ifdef CONFIG_VNC
 static int change_vnc_password(const char *password)
 {
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 16f3f4d..822d422 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -121,6 +121,15 @@ EQMP
     },
 
     {
+        .name       = "plug_get",
+        .args_type  = "options:O",
+        .params     = "",
+        .help       = "get plug property",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_plug_get,
+    },
+
+    {
         .name       = "eject",
         .args_type  = "force:-f,device:B",
         .params     = "[-f] device",
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]