Commit 4728b574 authored by Peter Xu's avatar Peter Xu Committed by Eduardo Habkost

hostmem: introduce host_memory_backend_mr_inited()

We were checking this against memory region size of host memory
backend's mr field to see whether the mr has been inited. This is
efficient but less elegant. Let's make a helper for it to avoid
confusions, along with some notes.
Suggested-by: 's avatarPeter Maydell <>
Signed-off-by: 's avatarPeter Xu <>
Message-Id: <>
Reviewed-by: 's avatarEduardo Habkost <>
Signed-off-by: 's avatarEduardo Habkost <>
parent 991db247
......@@ -237,6 +237,15 @@ static void host_memory_backend_init(Object *obj)
backend->prealloc = mem_prealloc;
bool host_memory_backend_mr_inited(HostMemoryBackend *backend)
* NOTE: We forbid zero-length memory backend, so here zero means
* "we haven't inited the backend memory region yet".
return memory_region_size(&backend->mr) != 0;
MemoryRegion *
host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
......@@ -62,6 +62,7 @@ struct HostMemoryBackend {
MemoryRegion mr;
bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
Error **errp);
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