提交 d1dd32af 编写于 作者: P Peter Crosthwaite 提交者: Paolo Bonzini

memory: Lazy init name from QOM name as needed

To support name retrieval of MemoryRegions that were created
dynamically (that is, not via memory_region_init and friends). We
cache the name in MemoryRegion's state as
object_get_canonical_path_component mallocs the returned value
so it's not suitable for direct return to callers. Memory already
frees the name field, so this will be garbage collected along with
the MR object.
Signed-off-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 3e1f5086
......@@ -1309,6 +1309,10 @@ uint64_t memory_region_size(MemoryRegion *mr)
const char *memory_region_name(const MemoryRegion *mr)
{
if (!mr->name) {
((MemoryRegion *)mr)->name =
object_get_canonical_path_component(OBJECT(mr));
}
return mr->name;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册