diff options
-rw-r--r-- | backends/hostmem.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c index 99e8f99..b7b6cf8 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -335,12 +335,26 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) } } +static bool +host_memory_backend_can_be_deleted(UserCreatable *uc, Error **errp) +{ + MemoryRegion *mr; + + mr = host_memory_backend_get_memory(MEMORY_BACKEND(uc), errp); + if (memory_region_is_mapped(mr)) { + return false; + } else { + return true; + } +} + static void host_memory_backend_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); ucc->complete = host_memory_backend_memory_complete; + ucc->can_be_deleted = host_memory_backend_can_be_deleted; } static const TypeInfo host_memory_backend_info = { |