From patchwork Fri Oct 1 18:19:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 66477 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 3DDD1B70E1 for ; Sat, 2 Oct 2010 04:24:42 +1000 (EST) Received: from localhost ([127.0.0.1]:36618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1kHf-0008Su-6a for incoming@patchwork.ozlabs.org; Fri, 01 Oct 2010 14:24:39 -0400 Received: from [140.186.70.92] (port=49300 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1kD6-0005zG-Ta for qemu-devel@nongnu.org; Fri, 01 Oct 2010 14:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P1kCp-0003Gk-VK for qemu-devel@nongnu.org; Fri, 01 Oct 2010 14:19:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P1kCp-0003Gf-Nk for qemu-devel@nongnu.org; Fri, 01 Oct 2010 14:19:39 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o91IJdJ8021343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Oct 2010 14:19:39 -0400 Received: from localhost (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o91IJbAi022274; Fri, 1 Oct 2010 14:19:38 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Fri, 1 Oct 2010 15:19:06 -0300 Message-Id: <1285957167-1228-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1285957167-1228-1-git-send-email-lcapitulino@redhat.com> References: <1285957167-1228-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 02/23] Add option to turn on JSON pretty printing in monitor 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 From: Daniel P. Berrange Expaned '-mon' arg to allow a 'pretty=on' flag. This makes the monitor pretty print its replies to easy human debugging / reading Signed-off-by: Daniel P. Berrange Signed-off-by: Luiz Capitulino --- monitor.c | 5 ++++- monitor.h | 1 + qemu-config.c | 3 +++ vl.c | 3 +++ 4 files changed, 11 insertions(+), 1 deletions(-) diff --git a/monitor.c b/monitor.c index e602480..a33cdc2 100644 --- a/monitor.c +++ b/monitor.c @@ -351,7 +351,10 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data) { QString *json; - json = qobject_to_json(data); + if (mon->flags & MONITOR_USE_PRETTY) + json = qobject_to_json_pretty(data); + else + json = qobject_to_json(data); assert(json != NULL); qstring_append_chr(json, '\n'); diff --git a/monitor.h b/monitor.h index 38b22a4..f2122b5 100644 --- a/monitor.h +++ b/monitor.h @@ -14,6 +14,7 @@ extern Monitor *default_mon; #define MONITOR_IS_DEFAULT 0x01 #define MONITOR_USE_READLINE 0x02 #define MONITOR_USE_CONTROL 0x04 +#define MONITOR_USE_PRETTY 0x08 /* flags for monitor commands */ #define MONITOR_CMD_ASYNC 0x0001 diff --git a/qemu-config.c b/qemu-config.c index e3b746c..6052a28 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -283,6 +283,9 @@ static QemuOptsList qemu_mon_opts = { },{ .name = "default", .type = QEMU_OPT_BOOL, + },{ + .name = "pretty", + .type = QEMU_OPT_BOOL, }, { /* end of list */ } }, diff --git a/vl.c b/vl.c index d352d18..939ee87 100644 --- a/vl.c +++ b/vl.c @@ -1562,6 +1562,9 @@ static int mon_init_func(QemuOpts *opts, void *opaque) exit(1); } + if (qemu_opt_get_bool(opts, "pretty", 0)) + flags |= MONITOR_USE_PRETTY; + if (qemu_opt_get_bool(opts, "default", 0)) flags |= MONITOR_IS_DEFAULT;