From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbxoz-0004Mv-QN for qemu-devel@nongnu.org; Thu, 31 Oct 2013 15:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vbxov-000707-DC for qemu-devel@nongnu.org; Thu, 31 Oct 2013 15:22:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbxov-0006zv-5G for qemu-devel@nongnu.org; Thu, 31 Oct 2013 15:22:17 -0400 Date: Thu, 31 Oct 2013 15:22:10 -0400 From: Luiz Capitulino Message-ID: <20131031152210.2e0317bd@redhat.com> In-Reply-To: <201310301710276996796@cn.fujitsu.com> References: <201310301710276996796@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] monitor.c : fix the monitor_user_noop function for hmp-commands calling user_print conveniently List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhou Yuan Cc: qemu-devel On Wed, 30 Oct 2013 17:10:29 +0800 "Zhou Yuan" wrote: > From: zhouy > To: qemu-devel@nongnu.org > Date: Wed, 30 Oct 2013 12:37:51 -0400 > Subject: [PATCH] fix the monitor_user_noop function for hmp-commands calling user_print conveniently > If a new hmp command added,just using the function call "monitor_user_noop" to print the result in the monitor model. > The function is alreadly existed but not have been fixed. Not sure what you're trying to accomplish here, but monitor_user_noop() is legacy and shouldn't be touched. If you to add a new command, taking a look at docs/writing-qmp-commands.txt may be helpful. > > Cc: Luiz Capitulino > Signed-off-by: zhouy > --- > qemu-master/monitor.c | 23 ++++++++++++++++++++++- > 1 files changed, 22 insertions(+), 1 deletions(-) > > diff --git a/qemu-master/monitor.c b/qemu-master/monitor.c > index 0aeaf6c..8aa24da 100644 > --- a/qemu-master/monitor.c > +++ b/qemu-master/monitor.c > @@ -387,7 +387,28 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, > return 0; > } > > -static void monitor_user_noop(Monitor *mon, const QObject *data) { } > +static void monitor_user_noop(Monitor *mon, const QObject *data) > +{ > + switch ((*data->type).code) { > + case QTYPE_QSTRING:{ > + const char *result = qstring_get_str(qobject_to_qstring(data)); > + monitor_printf(mon, "%s\n", result); > + break; > + } > + case QTYPE_QINT:{ > + int result = qint_get_int(qobject_to_qint(data)); > + monitor_printf(mon, "%d\n", result); > + break; > + } > + case QTYPE_QFLOAT:{ > + double result = qfloat_get_double(qobject_to_qfloat(data)); > + monitor_printf(mon, "%.3f\n", result); > + break; > + } > + default: > + break; > + } > +} > > static inline int handler_is_qobject(const mon_cmd_t *cmd) > {