Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIfyE-0004IR-H7 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:10:02 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIfyA-0004Fy-1R for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:10:01 -0500 Received: from [199.232.76.173] (port=49944 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIfy9-0004Fu-QP for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:09:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41712) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIfy9-0007hv-40 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 05:09:57 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 10/19] monitor: Convert do_info_name() to QObject References: <1260376078-8694-1-git-send-email-lcapitulino@redhat.com> <1260376078-8694-11-git-send-email-lcapitulino@redhat.com> Date: Thu, 10 Dec 2009 11:09:53 +0100 In-Reply-To: <1260376078-8694-11-git-send-email-lcapitulino@redhat.com> (Luiz Capitulino's message of "Wed, 9 Dec 2009 14:27:49 -0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Luiz Capitulino writes: > Signed-off-by: Luiz Capitulino > --- > monitor.c | 29 +++++++++++++++++++++++++---- > 1 files changed, 25 insertions(+), 4 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 47f794d..3d33bd8 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -514,10 +514,30 @@ static void do_info_version(Monitor *mon, QObject **ret_data) > QEMU_VERSION, QEMU_PKGVERSION); > } > > -static void do_info_name(Monitor *mon) > +static void do_info_name_print(Monitor *mon, const QObject *data) > { > - if (qemu_name) > - monitor_printf(mon, "%s\n", qemu_name); > + const char *str; > + > + str = qdict_get_str(qobject_to_qdict(data), "name"); > + if (strlen(str) > 0) { > + monitor_printf(mon, "%s\n", str); > + } > +} > + > +/** > + * do_info_name(): Show VM name > + * > + * Return a QDict with the following information: > + * > + * - "name": VM's name. If the VM has no name, the string will be empty So you can't distinguish name "" from unnamed. Do we care? Monitor output for unnamed guests changes from (qemu) info name (qemu) to (qemu) info name (qemu) > + * > + * Example: > + * > + * { "name": "qemu-name" } > + */ > +static void do_info_name(Monitor *mon, QObject **ret_data) > +{ > + *ret_data = qobject_from_jsonf("{'name': %s}", qemu_name ? qemu_name : ""); > } > > /** > @@ -2449,7 +2469,8 @@ static const mon_cmd_t info_cmds[] = { > .args_type = "", > .params = "", > .help = "show the current VM name", > - .mhandler.info = do_info_name, > + .user_print = do_info_name_print, > + .mhandler.info_new = do_info_name, > }, > { > .name = "uuid",