From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJHd-0001cJ-9z for qemu-devel@nongnu.org; Mon, 07 Jan 2013 15:26:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsJHc-0002S9-9B for qemu-devel@nongnu.org; Mon, 07 Jan 2013 15:26:57 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:59509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJHc-0002S5-3p for qemu-devel@nongnu.org; Mon, 07 Jan 2013 15:26:56 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Jan 2013 15:26:55 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id CDD6BC90042 for ; Mon, 7 Jan 2013 15:26:52 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r07KQqie210926 for ; Mon, 7 Jan 2013 15:26:52 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r07KQqK2019406 for ; Mon, 7 Jan 2013 18:26:52 -0200 From: Anthony Liguori In-Reply-To: <1354740282-20679-5-git-send-email-pbonzini@redhat.com> References: <1354740282-20679-1-git-send-email-pbonzini@redhat.com> <1354740282-20679-5-git-send-email-pbonzini@redhat.com> Date: Mon, 07 Jan 2013 14:26:48 -0600 Message-ID: <87hamsg2nr.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 04/11] qdev: add reference count to a device for the BusChild List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: afaerber@suse.de Paolo Bonzini writes: > Each device has a reference through the BusChild. This reference > was not accounted for, add it now. > > Signed-off-by: Paolo Bonzini > --- > hw/qdev.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/hw/qdev.c b/hw/qdev.c > index e758131..87dfcb5 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -65,7 +65,10 @@ static void bus_remove_child(BusState *bus, DeviceState *child) > > snprintf(name, sizeof(name), "child[%d]", kid->index); > QTAILQ_REMOVE(&bus->children, kid, sibling); > + > + /* This gives back ownership of kid->child back to us. */ > object_property_del(OBJECT(bus), name, NULL); > + object_unref(OBJECT(kid->child)); > g_free(kid); > return; > } > @@ -83,9 +86,11 @@ static void bus_add_child(BusState *bus, DeviceState *child) > > kid->index = bus->max_index++; > kid->child = child; > + object_ref(OBJECT(kid->child)); > > QTAILQ_INSERT_HEAD(&bus->children, kid, sibling); > > + /* This transfers ownership of kid->child to the property. */ > snprintf(name, sizeof(name), "child[%d]", kid->index); > object_property_add_link(OBJECT(bus), name, > object_get_typename(OBJECT(child)), The link property itself holds a reference no? Or is this not the case because we aren't checking a link when it's added and taking a reference if it's !NULL? Regards, Anthony Liguori > -- > 1.8.0.1