summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-10 17:16:01 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-12 07:59:48 -0600
commite05486cba662ccceef6be4b3ce38961876aa8f6e (patch)
treeb329f333e443bfed4737f3a804c1a8eb44de8dfa /monitor.c
parent2af5ba712b3e03cf644320f7386bf1dfd2c2b6a8 (diff)
downloadqemu-e05486cba662ccceef6be4b3ce38961876aa8f6e.tar.gz
qemu-e05486cba662ccceef6be4b3ce38961876aa8f6e.tar.bz2
qemu-e05486cba662ccceef6be4b3ce38961876aa8f6e.zip
monitor: Convert do_info_name() to QObject
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/monitor.c b/monitor.c
index 18c461215a..eb641e3d00 100644
--- a/monitor.c
+++ b/monitor.c
@@ -514,10 +514,33 @@ static void do_info_version(Monitor *mon, QObject **ret_data)
QEMU_VERSION, QEMU_PKGVERSION);
}
-static void do_info_name(Monitor *mon)
+static void do_info_name_print(Monitor *mon, const QObject *data)
{
- if (qemu_name)
- monitor_printf(mon, "%s\n", qemu_name);
+ QDict *qdict;
+
+ qdict = qobject_to_qdict(data);
+ if (qdict_size(qdict) == 0) {
+ return;
+ }
+
+ monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name"));
+}
+
+/**
+ * do_info_name(): Show VM name
+ *
+ * Return a QDict with the following information:
+ *
+ * - "name": VM's name (optional)
+ *
+ * Example:
+ *
+ * { "name": "qemu-name" }
+ */
+static void do_info_name(Monitor *mon, QObject **ret_data)
+{
+ *ret_data = qemu_name ? qobject_from_jsonf("{'name': %s }", qemu_name) :
+ qobject_from_jsonf("{}");
}
static QObject *get_cmd_dict(const char *name)
@@ -2472,7 +2495,8 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show the current VM name",
- .mhandler.info = do_info_name,
+ .user_print = do_info_name_print,
+ .mhandler.info_new = do_info_name,
},
{
.name = "uuid",