From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulFS-0000oQ-Rw for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UulFR-0005FU-6V for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:15:06 -0400 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:62131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulFQ-0005Ce-Vw for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:15:05 -0400 Received: by mail-wg0-f51.google.com with SMTP id e11so1248622wgh.30 for ; Thu, 04 Jul 2013 08:15:04 -0700 (PDT) Received: from playground.station (net-37-117-148-210.cust.dsl.vodafone.it. [37.117.148.210]) by mx.google.com with ESMTPSA id d8sm4212546wiz.0.2013.07.04.08.15.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Jul 2013 08:15:03 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 4 Jul 2013 17:13:17 +0200 Message-Id: <1372950842-32422-22-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> References: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 21/66] memory: add getter for owner List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 3f48f07..2f3e8e4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -382,6 +382,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 56ef4ba..f85774a 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(); @@ -1013,6 +1014,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())) { -- 1.8.1.4