From patchwork Wed Sep 28 14:44:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 116821 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 770911007D2 for ; Thu, 29 Sep 2011 01:22:01 +1000 (EST) Received: from localhost ([::1]:47993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vOT-00040t-V7 for incoming@patchwork.ozlabs.org; Wed, 28 Sep 2011 10:45:53 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vNz-00036K-Dc for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8vNt-0004yE-89 for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8vNt-0004y6-0x for qemu-devel@nongnu.org; Wed, 28 Sep 2011 10:45:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8SEjFXg017206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2011 10:45:15 -0400 Received: from localhost (ovpn-113-147.phx2.redhat.com [10.3.113.147]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8SEjDmd012185; Wed, 28 Sep 2011 10:45:14 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 28 Sep 2011 11:44:39 -0300 Message-Id: <1317221085-5825-16-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1317221085-5825-1-git-send-email-lcapitulino@redhat.com> References: <1317221085-5825-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 15/21] qapi: Convert query-uuid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The original conversion was done by Anthony Liguori. This commit is just a rebase. Signed-off-by: Luiz Capitulino --- 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 9e7f07e..1cd40ae 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 f641504..d294bc9 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 de0f807..b678f07 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; +} +