Commit 803c0816 authored by Paolo Bonzini's avatar Paolo Bonzini

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: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent b7e95164
......@@ -381,6 +381,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.
*
......
......@@ -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())) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment