diff options
Diffstat (limited to 'backends/hostmem-file.c')
-rw-r--r-- | backends/hostmem-file.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 639c8d4307..6630021226 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -42,6 +42,9 @@ static void file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend); +#ifdef CONFIG_POSIX + gchar *path; +#endif if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -54,18 +57,15 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) #ifndef CONFIG_POSIX error_setg(errp, "-mem-path not supported on this host"); #else - if (!host_memory_backend_mr_inited(backend)) { - gchar *path; - backend->force_prealloc = mem_prealloc; - path = object_get_canonical_path(OBJECT(backend)); - memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), - path, - backend->size, fb->align, - (backend->share ? RAM_SHARED : 0) | - (fb->is_pmem ? RAM_PMEM : 0), - fb->mem_path, errp); - g_free(path); - } + backend->force_prealloc = mem_prealloc; + path = object_get_canonical_path(OBJECT(backend)); + memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), + path, + backend->size, fb->align, + (backend->share ? RAM_SHARED : 0) | + (fb->is_pmem ? RAM_PMEM : 0), + fb->mem_path, errp); + g_free(path); #endif } |