From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 06/15] memory: use refcnt to manage MemoryRegion Date: Wed, 08 Aug 2012 12:20:20 +0300 Message-ID: <50222F54.4080108@redhat.com> References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-7-git-send-email-qemulist@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Anthony Liguori , Jan Kiszka , Marcelo Tosatti , Stefan Hajnoczi , Paolo Bonzini , Blue Swirl , =?ISO-8859-1?Q?Andreas_F=E4rber?= To: Liu Ping Fan Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752505Ab2HHJUa (ORCPT ); Wed, 8 Aug 2012 05:20:30 -0400 In-Reply-To: <1344407156-25562-7-git-send-email-qemulist@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/08/2012 09:25 AM, Liu Ping Fan wrote: > From: Liu Ping Fan > > Using refcnt for mr, so we can separate mr's life cycle management > from refered object. > When mr->ref 0->1, inc the refered object. > When mr->ref 1->0, dec the refered object. > > The refered object can be DeviceStae, another mr, or other opaque. Please explain the motivation more fully. Usually a MemoryRegion will be embedded within some DeviceState, or its lifecycle will be managed by the DeviceState. So long as we keep the DeviceState alive all associated MemoryRegions should be alive as well. Why not do this directly? -- error compiling committee.c: too many arguments to function