From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtfCX-0003MQ-Lg for qemu-devel@nongnu.org; Mon, 01 Jul 2013 10:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtfCS-00042e-Is for qemu-devel@nongnu.org; Mon, 01 Jul 2013 10:35:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtfCS-00042a-9B for qemu-devel@nongnu.org; Mon, 01 Jul 2013 10:35:28 -0400 Message-ID: <51D193AB.8020706@redhat.com> Date: Mon, 01 Jul 2013 16:35:23 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1372438702-20491-1-git-send-email-pbonzini@redhat.com> <1372438702-20491-5-git-send-email-pbonzini@redhat.com> <51D1910B.6080506@siemens.com> In-Reply-To: <51D1910B.6080506@siemens.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 04/11] memory: add getter for owner List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: "peter.maydell@linaro.org" , "qemu-devel@nongnu.org" Il 01/07/2013 16:24, Jan Kiszka ha scritto: > On 2013-06-28 18:58, Paolo Bonzini wrote: >> Whenever memory regions are accessed outside the BQL, they need to be >> preserved against hot-unplug. MemoryRegions actually do not have their >> own reference count; they piggyback on a QOM object, their "owner". >> The owner is set at creation time, and there is a function to retrieve >> the owner. >> >> Signed-off-by: Paolo Bonzini >> --- >> include/exec/memory.h | 7 +++++++ >> memory.c | 6 ++++++ >> 2 files changed, 13 insertions(+) >> >> diff --git a/include/exec/memory.h b/include/exec/memory.h >> index be3d39f..1ad9c19 100644 >> --- a/include/exec/memory.h >> +++ b/include/exec/memory.h >> @@ -380,6 +380,13 @@ void memory_region_init_iommu(MemoryRegion *mr, >> void memory_region_destroy(MemoryRegion *mr); >> >> /** >> + * memory_region_owner: get a memory region's owner. >> + * >> + * @mr: the memory region being queried. >> + */ >> +struct Object *memory_region_owner(MemoryRegion *mr); >> + >> +/** >> * memory_region_size: get a memory region's size. >> * >> * @mr: the memory region being queried. >> diff --git a/memory.c b/memory.c >> index 6250bec1..4d396c3 100644 >> --- a/memory.c >> +++ b/memory.c >> @@ -738,6 +738,7 @@ void memory_region_init(MemoryRegion *mr, >> mr->owner = owner; >> mr->iommu_ops = NULL; >> mr->parent = NULL; >> + mr->owner = NULL; >> mr->size = int128_make64(size); >> if (size == UINT64_MAX) { >> mr->size = int128_2_64(); >> @@ -1011,6 +1012,11 @@ void memory_region_destroy(MemoryRegion *mr) >> g_free(mr->ioeventfds); >> } >> >> +Object *memory_region_owner(MemoryRegion *mr) >> +{ >> + return mr->owner; >> +} >> + >> uint64_t memory_region_size(MemoryRegion *mr) >> { >> if (int128_eq(mr->size, int128_2_64())) { >> > > OK, fine... and who is using this? ;) There'll be a couple users in hw/acpi/core.c. > Also, as this is trivial and the structure publicly known anyway, I'd go > for a static inline function instead. Ok. Though it's not a fast path anyway. Paolo