From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIhZr-0001j3-8h for qemu-devel@nongnu.org; Thu, 10 Dec 2009 06:52:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIhZl-0001f6-Mf for qemu-devel@nongnu.org; Thu, 10 Dec 2009 06:52:58 -0500 Received: from [199.232.76.173] (port=54445 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIhZl-0001ek-DE for qemu-devel@nongnu.org; Thu, 10 Dec 2009 06:52:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48226) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIhZl-0000hH-1P for qemu-devel@nongnu.org; Thu, 10 Dec 2009 06:52:53 -0500 Date: Thu, 10 Dec 2009 09:52:37 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 10/19] monitor: Convert do_info_name() to QObject Message-ID: <20091210095237.38cafe5c@doriath> In-Reply-To: References: <1260376078-8694-1-git-send-email-lcapitulino@redhat.com> <1260376078-8694-11-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On Thu, 10 Dec 2009 11:09:53 +0100 Markus Armbruster wrote: > 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? I don't think so, but if we do the best way to deal with the fact that qemu_name can be NULL would be to return null, like: { "name": null } But we don't support json-null yet... There are other two ways to solve this, but they seem workarounds for not supporting null: return an empty dict or return { "name": false }. > Monitor output for unnamed guests changes from > > (qemu) info name > (qemu) > > to > > (qemu) info name > > (qemu) The strlen() call doesn't let this happen. Although the other way around does happen: if you call qemu with -name '', then output would be: (qemu) info name (qemu) This won't happen anymore, goto do_we_care.