Message ID | 1433776757-61958-5-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
On 08/06/2015 17:19, Igor Mammedov wrote: > MemoryRegion * > host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp) > { > + UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(backend); > + > + if (memory_region_is_hva_mapped(&backend->mr)) { > + object_unparent(OBJECT(&backend->mr)); > + ucc->complete(USER_CREATABLE(backend), errp); > + } I'm not sure I understand this, and the commit message... doesn't help. Is it for the case where you unplug memory and then reuse the old backend? Can we just outlaw this, forcing each memory backend to be used only once? Paolo
On Mon, 08 Jun 2015 17:30:20 +0200 Paolo Bonzini <pbonzini@redhat.com> wrote: > > > On 08/06/2015 17:19, Igor Mammedov wrote: > > MemoryRegion * > > host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp) > > { > > + UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(backend); > > + > > + if (memory_region_is_hva_mapped(&backend->mr)) { > > + object_unparent(OBJECT(&backend->mr)); > > + ucc->complete(USER_CREATABLE(backend), errp); > > + } > > I'm not sure I understand this, and the commit message... doesn't help. > > Is it for the case where you unplug memory and then reuse the old > backend? yes > Can we just outlaw this, forcing each memory backend to be > used only once? to outlaw it gracefully without asserting QEMU during hotplug user should be able to detect that it's outlawed i.e. use memory_region_is_hva_mapped(), but yes we can. > > Paolo
On 08/06/2015 18:25, Igor Mammedov wrote: > >> > Can we just outlaw this, forcing each memory backend to be >> > used only once? > to outlaw it gracefully without asserting QEMU during hotplug > user should be able to detect that it's outlawed i.e. use > memory_region_is_hva_mapped(), but yes we can. We can also add a ->detach method to HostMemoryBackend, and forbid get_memory after it has been invoked. Paolo
diff --git a/backends/hostmem.c b/backends/hostmem.c index 2a8614d..4486483 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -283,6 +283,12 @@ static void host_memory_backend_init(Object *obj) MemoryRegion * host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp) { + UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(backend); + + if (memory_region_is_hva_mapped(&backend->mr)) { + object_unparent(OBJECT(&backend->mr)); + ucc->complete(USER_CREATABLE(backend), errp); + } return memory_region_size(&backend->mr) ? &backend->mr : NULL; }
Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- backends/hostmem.c | 6 ++++++ 1 file changed, 6 insertions(+)