From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz2l4-0002p8-35 for qemu-devel@nongnu.org; Wed, 08 Aug 2012 05:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sz2ky-0001XV-E8 for qemu-devel@nongnu.org; Wed, 08 Aug 2012 05:40:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz2ky-0001XP-2k for qemu-devel@nongnu.org; Wed, 08 Aug 2012 05:40:48 -0400 Message-ID: <50223413.9000101@redhat.com> Date: Wed, 08 Aug 2012 11:40:35 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-15-git-send-email-qemulist@gmail.com> In-Reply-To: <1344407156-25562-15-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/15] qom: object_unref call reclaimer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: kvm@vger.kernel.org, Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, Blue Swirl , Avi Kivity , Anthony Liguori , Stefan Hajnoczi , =?ISO-8859-15?Q?Andreas_F=E4rber?= Il 08/08/2012 08:25, Liu Ping Fan ha scritto: > From: Liu Ping Fan > > iohandler/bh/timer may use DeviceState when its refcnt=0, > postpone the reclaimer till they have done with it. > > Signed-off-by: Liu Ping Fan > --- > qom/object.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/qom/object.c b/qom/object.c > index 822bdb7..1452b1b 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -23,6 +23,8 @@ > #include "qbool.h" > #include "qint.h" > #include "qstring.h" > +#include "hw/qdev.h" > +#include "qemu/reclaimer.h" > > #define MAX_INTERFACES 32 > > @@ -646,7 +648,12 @@ void object_unref(Object *obj) > { > g_assert(atomic_read(&obj->ref) > 0); > if (atomic_dec_and_test(&obj->ref)) { > - object_finalize(obj); > + /* fixme, maybe introduce obj->finalze to make this more elegant */ > + if (object_dynamic_cast(obj, TYPE_DEVICE) != NULL) { > + qemu_reclaimer_enqueue(obj, object_finalize); > + } else { > + object_finalize(obj); > + } > } > } > > Just do this unconditionally. Paolo