From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIiZY-0005DF-Be for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:56:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIiZT-00058P-SK for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:56:43 -0500 Received: from [199.232.76.173] (port=36390 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIiZT-000583-F0 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:56:39 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:53874) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NIiZT-0005u8-CL for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:56:39 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e7.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id nBACpfTQ022907 for ; Thu, 10 Dec 2009 07:51:41 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nBACubi9039556 for ; Thu, 10 Dec 2009 07:56:37 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nBACubX6018413 for ; Thu, 10 Dec 2009 10:56:37 -0200 Message-ID: <4B20F003.6070409@linux.vnet.ibm.com> Date: Thu, 10 Dec 2009 06:56:35 -0600 From: Anthony Liguori MIME-Version: 1.0 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> <20091210095237.38cafe5c@doriath> In-Reply-To: <20091210095237.38cafe5c@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Anthony Liguori , Markus Armbruster , qemu-devel@nongnu.org Luiz Capitulino wrote: > 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 }. > I'd prefer an empty dict. I actually prefer that over null. -- Regards, Anthony Liguori