From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4v6D-0002JC-L1 for qemu-devel@nongnu.org; Fri, 24 Aug 2012 10:43:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4v6C-00020z-Ki for qemu-devel@nongnu.org; Fri, 24 Aug 2012 10:43:01 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:34431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4v6C-00020X-Dm for qemu-devel@nongnu.org; Fri, 24 Aug 2012 10:43:00 -0400 Received: by eeke53 with SMTP id e53so763887eek.4 for ; Fri, 24 Aug 2012 07:42:59 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <503792F1.4090109@redhat.com> Date: Fri, 24 Aug 2012 16:42:57 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1345801763-24227-1-git-send-email-qemulist@gmail.com> <1345801763-24227-11-git-send-email-qemulist@gmail.com> In-Reply-To: <1345801763-24227-11-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Liu Ping Fan , qemu-devel@nongnu.org, Anthony Liguori , Avi Kivity Il 24/08/2012 11:49, Liu Ping Fan ha scritto: > With this patch, we can protect PCIIDEState from disappearing during > mmio-dispatch hold the IDEBus->ref. I don't see why MMIO dispatch should hold the IDEBus ref rather than the PCIIDEState. In the case of the PIIX, the BARs are set up by the PCIIDEState in bmdma_setup_bar (called by bmdma_setup_bar). Also, containment may happen just as well for devices, not buses. Why isn't it a problem in that case? It looks like you're papering over a different bug. Paolo > And the ref circle has been broken when calling qdev_delete_subtree(). > > Signed-off-by: Liu Ping Fan > --- > hw/qdev.c | 2 ++ > hw/qdev.h | 1 + > 2 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index e2339a1..b09ebbf 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -510,6 +510,8 @@ void qbus_create_inplace(BusState *bus, const char *typename, > { > object_initialize(bus, typename); > > + bus->overlap = parent; > + object_ref(OBJECT(bus->overlap)); > bus->parent = parent; > bus->name = name ? g_strdup(name) : NULL; > qbus_realize(bus); > diff --git a/hw/qdev.h b/hw/qdev.h > index 182cfa5..9bc5783 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -117,6 +117,7 @@ struct BusState { > int allow_hotplug; > bool qom_allocated; > bool glib_allocated; > + DeviceState *overlap; > int max_index; > QTAILQ_HEAD(ChildrenHead, BusChild) children; > QLIST_ENTRY(BusState) sibling; > -- 1.7.4.4