From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsvw4-0002Ey-Qo for qemu-devel@nongnu.org; Wed, 09 Jan 2013 08:43:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tsvw0-00050M-Ma for qemu-devel@nongnu.org; Wed, 09 Jan 2013 08:43:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsvw0-00050I-FF for qemu-devel@nongnu.org; Wed, 09 Jan 2013 08:43:12 -0500 Message-ID: <50ED6FB3.4070208@redhat.com> Date: Wed, 09 Jan 2013 14:25:07 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1354740282-20679-1-git-send-email-pbonzini@redhat.com> <1354740282-20679-8-git-send-email-pbonzini@redhat.com> <87ehhwg2jk.fsf@codemonkey.ws> In-Reply-To: <87ehhwg2jk.fsf@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/11] qdev: add reference for the bus while it is referred to by the DeviceState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, afaerber@suse.de Il 07/01/2013 21:29, Anthony Liguori ha scritto: > Paolo Bonzini writes: > >> Now that the unparent callbacks are complete, we can correctly account >> more missing references. >> >> Signed-off-by: Paolo Bonzini >> --- >> hw/qdev.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/hw/qdev.c b/hw/qdev.c >> index d7f1545..62b6c14 100644 >> --- a/hw/qdev.c >> +++ b/hw/qdev.c >> @@ -101,6 +101,7 @@ static void bus_add_child(BusState *bus, DeviceState *child) >> void qdev_set_parent_bus(DeviceState *dev, BusState *bus) >> { >> dev->parent_bus = bus; >> + object_ref(OBJECT(bus)); >> bus_add_child(bus, dev); > > If we make parent_bus a link property, we'll get the reference counting > for free. True, but I think this should be a separate series. Paolo > Regards, > > Anthony Liguori > >> } >> >> @@ -734,6 +735,8 @@ static void qdev_remove_from_bus(Object *obj) >> } >> if (dev->parent_bus) { >> bus_remove_child(dev->parent_bus, dev); >> + object_unref(OBJECT(dev->parent_bus)); >> + dev->parent_bus = NULL; >> } >> } >> >> -- >> 1.8.0.1 >