aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-09-10 17:49:46 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2018-11-28 11:51:24 +0100
commit86100290cb6600b3d65e0794b45c1b82ead99411 (patch)
treef8038870c6549b912e128976401c5f6521e98ee4
parent36ea397956c169aa79db9487de2ea65a938a13e9 (diff)
downloadqemu-86100290cb6600b3d65e0794b45c1b82ead99411.zip
qemu-86100290cb6600b3d65e0794b45c1b82ead99411.tar.gz
qemu-86100290cb6600b3d65e0794b45c1b82ead99411.tar.bz2
hostmem: no need to check for host_memory_backend_mr_inited() in alloc()
memfd_backend_memory_alloc/file_backend_memory_alloc both needlessly are are calling host_memory_backend_mr_inited() which creates an illusion that alloc could be called multiple times but it isn't, it's called once from UserCreatable complete(). Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--backends/hostmem-file.c24
-rw-r--r--backends/hostmem-memfd.c4
2 files changed, 12 insertions, 16 deletions
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 639c8d4..6630021 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
}
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 1c3579e..2eb9c82 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -44,10 +44,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
return;
}
- if (host_memory_backend_mr_inited(backend)) {
- return;
- }
-
backend->force_prealloc = mem_prealloc;
fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size,
m->hugetlb, m->hugetlbsize, m->seal ?