summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-10 17:16:03 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-12 08:17:31 -0600
commitee70ef8771a69e11c0814ab332c48efdf19ad0a2 (patch)
tree8c7866cd0444686947f1875ad28d9ecdc21addf3
parent5f9fe0f8d0b38d0af6b2b3a3bc9974e5a9a28213 (diff)
downloadqemu-ee70ef8771a69e11c0814ab332c48efdf19ad0a2.tar.gz
monitor: Convert do_info_uuid() to QObject
snprintf() is used because the UUID_FMT is too complex for qobject_from_jsonf(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 9603ceba2edd1dc7e3823da76d84706d3d1c3d78)
-rw-r--r--monitor.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/monitor.c b/monitor.c
index 7f091a3fed..daa45fcaa5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -621,13 +621,32 @@ static void do_info_hpet(Monitor *mon, QObject **ret_data)
}
#endif
-static void do_info_uuid(Monitor *mon)
+static void do_info_uuid_print(Monitor *mon, const QObject *data)
{
- monitor_printf(mon, UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1],
+ monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
+}
+
+/**
+ * do_info_uuid(): Show VM UUID
+ *
+ * Return a QDict with the following information:
+ *
+ * - "UUID": Universally Unique Identifier
+ *
+ * Example:
+ *
+ * { "UUID": "550e8400-e29b-41d4-a716-446655440000" }
+ */
+static void do_info_uuid(Monitor *mon, QObject **ret_data)
+{
+ char uuid[64];
+
+ snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1],
qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],
qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],
qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
qemu_uuid[14], qemu_uuid[15]);
+ *ret_data = qobject_from_jsonf("{ 'UUID': %s }", uuid);
}
/* get the current CPU defined by the user */
@@ -2521,7 +2540,8 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show the current VM UUID",
- .mhandler.info = do_info_uuid,
+ .user_print = do_info_uuid_print,
+ .mhandler.info_new = do_info_uuid,
},
#if defined(TARGET_PPC)
{