[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API |
Date: |
Wed, 18 Jun 2014 19:16:06 +0300 |
From: Igor Mammedov <address@hidden>
which allows to check if MemoryRegion is already mapped.
Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/exec/memory.h | 8 ++++++++
memory.c | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 1d55ad9..ab11c32 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -848,6 +848,14 @@ void memory_region_set_alias_offset(MemoryRegion *mr,
bool memory_region_present(MemoryRegion *parent, hwaddr addr);
/**
+ * memory_region_is_mapped: returns true if #MemoryRegion is mapped
+ * into any address space.
+ *
+ * @mr: a #MemoryRegion which should be checked if it's mapped
+ */
+bool memory_region_is_mapped(MemoryRegion *mr);
+
+/**
* memory_region_find: translate an address/size relative to a
* MemoryRegion into a #MemoryRegionSection.
*
diff --git a/memory.c b/memory.c
index 678661e..93afea7 100644
--- a/memory.c
+++ b/memory.c
@@ -492,7 +492,7 @@ static AddressSpace
*memory_region_to_address_space(MemoryRegion *mr)
return as;
}
}
- abort();
+ return NULL;
}
/* Render a memory region into the global view. Ranges in @view obscure
@@ -1569,6 +1569,11 @@ bool memory_region_present(MemoryRegion *parent, hwaddr
addr)
return true;
}
+bool memory_region_is_mapped(MemoryRegion *mr)
+{
+ return mr->parent ? true : false;
+}
+
MemoryRegionSection memory_region_find(MemoryRegion *mr,
hwaddr addr, uint64_t size)
{
@@ -1586,6 +1591,9 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
}
as = memory_region_to_address_space(root);
+ if (!as) {
+ return ret;
+ }
range = addrrange_make(int128_make64(addr), int128_make64(size));
view = address_space_get_flatview(as);
--
MST
- [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 001/106] pc: create custom generic PC machine type, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 003/106] object_add: allow completion handler to get canonical path, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 004/106] vl.c: daemonize before guest memory allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 005/106] add memdev backend infrastructure, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 009/106] pc: implement pc-dimm device abstraction, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 011/106] pc-dimm: do not allow setting an in-use memdev, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 014/106] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 018/106] pc-dimm: add busy slot check and slot auto-allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 021/106] trace: add acpi memory hotplug IO region events, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 022/106] trace: pc: add PC_DIMM slot & address allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 023/106] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 025/106] pc: ich9 lpc: make it work with global/compat properties, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 024/106] acpi:piix4: add memory hotplug handling, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 026/106] acpi:ich9: add memory hotplug handling, Michael S. Tsirkin, 2014/06/18