From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=44735 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pwb0l-0007h5-UB for qemu-devel@nongnu.org; Mon, 07 Mar 2011 09:02:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pwb0l-00055B-0A for qemu-devel@nongnu.org; Mon, 07 Mar 2011 09:02:11 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:54879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pwb0k-00054z-UD for qemu-devel@nongnu.org; Mon, 07 Mar 2011 09:02:10 -0500 Received: by gxk28 with SMTP id 28so2037466gxk.4 for ; Mon, 07 Mar 2011 06:02:10 -0800 (PST) Message-ID: <4D74E561.4070405@codemonkey.ws> Date: Mon, 07 Mar 2011 08:02:09 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 15/22] qapi: add new QMP server that uses CharDriverState References: <1299460984-15849-1-git-send-email-aliguori@us.ibm.com> <1299460984-15849-16-git-send-email-aliguori@us.ibm.com> In-Reply-To: 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: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Adam Litke , Markus Armbruster , Luiz Capitulino On 03/07/2011 07:52 AM, Stefan Hajnoczi wrote: > On Mon, Mar 7, 2011 at 1:22 AM, Anthony Liguori wrote: > >> +static void qmp_chr_send_greeting(QmpSession *s) >> +{ >> + VersionInfo *info; >> + QObject *vers; >> + QObject *greeting; >> + QString *str; >> + >> + info = qmp_query_version(NULL); >> + vers = qmp_marshal_type_VersionInfo(info); >> + qmp_free_version_info(info); >> + >> + greeting = qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []} }", >> + vers); >> + str = qobject_to_json(greeting); >> + qobject_decref(greeting); >> + >> + qemu_chr_write(s->chr, (void *)str->string, str->length); >> + qemu_chr_write(s->chr, (void *)"\n", 1); >> + QDECREF(str); >> +} >> > Is vers leaked? > No, %p takes ownership of the object. qdict_put* also does FWIW. The ownership semantics of QObject functions are very challenging. We really need a concept of floating references to let stuff like this continue to work without explicitly transferring ownership. But really, a big part of this refactoring is isolating QObject so that we can eventually replace it with GVariant so it may not be worth worrying about. Regards, Anthony Liguori > Stefan > >