aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-07 06:59:09 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2013-07-04 17:42:45 +0200
commit803c0816a7d3ab35460991ba5b7d1fccc070332b (patch)
tree11dbf5a0e9f6be80dba44b8828fb2601451b7862 /memory.c
parentb7e95164d1a9969aa591b8a72e05b94d08c49738 (diff)
memory: add getter for owner
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 <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index 56ef4bae4e..f85774a11f 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())) {