From patchwork Thu Dec 10 19:16:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B82C9B6EF6 for ; Fri, 11 Dec 2009 06:44:29 +1100 (EST) Received: from localhost ([127.0.0.1]:43394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIow5-0000HX-DZ for incoming@patchwork.ozlabs.org; Thu, 10 Dec 2009 14:44:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIoVQ-0006yQ-HJ for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIoVM-0006sm-R7 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:51 -0500 Received: from [199.232.76.173] (port=56477 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIoVM-0006sb-Lb for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40081) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIoVM-0001Du-B2 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 14:16:48 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAJGlRk005534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 14:16:47 -0500 Received: from localhost (vpn-9-38.rdu.redhat.com [10.11.9.38]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAJGkvA019926; Thu, 10 Dec 2009 14:16:46 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 10 Dec 2009 17:16:03 -0200 Message-Id: <1260472570-13973-14-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260472570-13973-1-git-send-email-lcapitulino@redhat.com> References: <1260472570-13973-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 13/20] monitor: Convert do_info_uuid() to QObject X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org snprintf() is used because the UUID_FMT is too complex for qobject_from_jsonf(). Signed-off-by: Luiz Capitulino --- monitor.c | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index a824648..0163c07 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) {