From patchwork Mon Jun 7 14:42:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 54880 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 AA28EB7D47 for ; Tue, 8 Jun 2010 01:29:12 +1000 (EST) Received: from localhost ([127.0.0.1]:49614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLeGC-0002gR-6g for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 11:29:08 -0400 Received: from [140.186.70.92] (port=56386 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLdYa-0005xh-Oj for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:44:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLdYA-0005Ie-Kq for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:44:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22123) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLdYA-0005IK-DX for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:43:38 -0400 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 o57EhbWj019039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Jun 2010 10:43:37 -0400 Received: from localhost.localdomain (dhcp-1-192.lcy.redhat.com [10.32.224.192]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o57EgrCj031909; Mon, 7 Jun 2010 10:43:36 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 15:42:31 +0100 Message-Id: <1275921752-29420-19-git-send-email-berrange@redhat.com> In-Reply-To: <1275921752-29420-1-git-send-email-berrange@redhat.com> References: <1275921752-29420-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 18/19] 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 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 --- 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 39f8150..6203f75 100644 --- a/monitor.c +++ b/monitor.c @@ -341,7 +341,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 46b7a0e..733485f 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 /* QMP events */ typedef enum MonitorEvent { diff --git a/qemu-config.c b/qemu-config.c index 925bd04..20ed8c2 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -362,6 +362,9 @@ QemuOptsList qemu_mon_opts = { },{ .name = "default", .type = QEMU_OPT_BOOL, + },{ + .name = "pretty", + .type = QEMU_OPT_BOOL, }, { /* end if list */ } }, diff --git a/vl.c b/vl.c index 35d2b51..de010cc 100644 --- a/vl.c +++ b/vl.c @@ -2391,6 +2391,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;