[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 15/22] qapi: add new QMP server that uses CharDr

From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 15/22] qapi: add new QMP server that uses CharDriverState
Date: Mon, 07 Mar 2011 08:02:09 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10

On 03/07/2011 07:52 AM, Stefan Hajnoczi wrote:
On Mon, Mar 7, 2011 at 1:22 AM, Anthony Liguori<address@hidden>  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.


Anthony Liguori


reply via email to

[Prev in Thread] Current Thread [Next in Thread]