[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/26] qapi: Convert query-uuid
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 20/26] qapi: Convert query-uuid |
Date: |
Fri, 30 Sep 2011 17:34:45 -0300 |
Signed-off-by: Anthony Liguori <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
hmp.c | 8 ++++++++
hmp.h | 1 +
monitor.c | 28 +---------------------------
qapi-schema.json | 24 ++++++++++++++++++++++++
qmp-commands.hx | 6 ++++++
qmp.c | 15 +++++++++++++++
6 files changed, 55 insertions(+), 27 deletions(-)
diff --git a/hmp.c b/hmp.c
index 30925b0..25302f5 100644
--- a/hmp.c
+++ b/hmp.c
@@ -72,3 +72,11 @@ void hmp_info_status(Monitor *mon)
qapi_free_StatusInfo(info);
}
+void hmp_info_uuid(Monitor *mon)
+{
+ UuidInfo *info;
+
+ info = qmp_query_uuid(NULL);
+ monitor_printf(mon, "%s\n", info->UUID);
+ qapi_free_UuidInfo(info);
+}
diff --git a/hmp.h b/hmp.h
index df4242f..49a5971 100644
--- a/hmp.h
+++ b/hmp.h
@@ -21,5 +21,6 @@ void hmp_info_name(Monitor *mon);
void hmp_info_version(Monitor *mon);
void hmp_info_kvm(Monitor *mon);
void hmp_info_status(Monitor *mon);
+void hmp_info_uuid(Monitor *mon);
#endif
diff --git a/monitor.c b/monitor.c
index 3501f68..0789f98 100644
--- a/monitor.c
+++ b/monitor.c
@@ -765,23 +765,6 @@ static void do_info_commands(Monitor *mon, QObject
**ret_data)
*ret_data = QOBJECT(cmd_list);
}
-static void do_info_uuid_print(Monitor *mon, const QObject *data)
-{
- monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
-}
-
-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 */
static int mon_set_cpu(int cpu_index)
{
@@ -2983,8 +2966,7 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show the current VM UUID",
- .user_print = do_info_uuid_print,
- .mhandler.info_new = do_info_uuid,
+ .mhandler.info = hmp_info_uuid,
},
#if defined(TARGET_PPC)
{
@@ -3144,14 +3126,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
},
#endif
{
- .name = "uuid",
- .args_type = "",
- .params = "",
- .help = "show the current VM UUID",
- .user_print = do_info_uuid_print,
- .mhandler.info_new = do_info_uuid,
- },
- {
.name = "migrate",
.args_type = "",
.params = "",
diff --git a/qapi-schema.json b/qapi-schema.json
index 0e59c71..b717491 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -152,3 +152,27 @@
##
{ 'command': 'query-status', 'returns': 'StatusInfo' }
+##
+# @UuidInfo:
+#
+# Guest UUID information.
+#
+# @UUID: the UUID of the guest
+#
+# Since: 0.14.0
+#
+# Notes: If no UUID was specified for the guest, a null UUID is returned.
+##
+{ 'type': 'UuidInfo', 'data': {'UUID': 'str'} }
+
+##
+# @query-uuid:
+#
+# Query the guest UUID information.
+#
+# Returns: The @UuidInfo for the guest
+#
+# Since 0.14.0
+##
+{ 'command': 'query-uuid', 'returns': 'UuidInfo' }
+
diff --git a/qmp-commands.hx b/qmp-commands.hx
index afa95bd..4fef25f 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1821,6 +1821,12 @@ Example:
EQMP
+ {
+ .name = "query-uuid",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_uuid,
+ },
+
SQMP
query-migrate
-------------
diff --git a/qmp.c b/qmp.c
index 8f7f666..58337c7 100644
--- a/qmp.c
+++ b/qmp.c
@@ -55,3 +55,18 @@ KvmInfo *qmp_query_kvm(Error **errp)
return info;
}
+UuidInfo *qmp_query_uuid(Error **errp)
+{
+ UuidInfo *info = g_malloc0(sizeof(*info));
+ 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]);
+
+ info->UUID = g_strdup(uuid);
+ return info;
+}
+
--
1.7.7.rc0.72.g4b5ea
- [Qemu-devel] [PATCH 08/26] qapi: add test cases for generated free functions, (continued)
- [Qemu-devel] [PATCH 08/26] qapi: add test cases for generated free functions, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 12/26] qapi: Automatically generate a _MAX value for enums, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 13/26] qapi: convert query-name, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 01/26] error: let error_is_type take a NULL error, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 14/26] qapi: Convert query-version, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 17/26] RunState: Drop the RSTATE_NO_STATE value, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 16/26] vl: Change qemu_vmstop_requested() to return a bool, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 15/26] qapi: Convert query-kvm, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 03/26] qapi: add code generation support for middle mode, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 25/26] qapi: Convert system_reset, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 20/26] qapi: Convert query-uuid,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 18/26] RunState: Rename enum values as generated by the QAPI, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 21/26] qapi: Convert query-chardev, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 19/26] qapi: Convert query-status, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 22/26] qapi: Convert query-commands, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 24/26] qapi: Convert stop, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 26/26] qapi: Convert system_powerdown, Luiz Capitulino, 2011/09/30
- [Qemu-devel] [PATCH 23/26] qapi: Convert quit, Luiz Capitulino, 2011/09/30