From a35ba7be4b696d4c7b47318fd2022e6c3eca0a63 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 10 Jun 2014 19:15:23 +0800 Subject: hostmem: allow preallocation of any memory region And allow preallocation of file-based memory even without -mem-prealloc. Some care is necessary because -mem-prealloc does not allow disabling preallocation for hostmem-file. Signed-off-by: Paolo Bonzini Signed-off-by: Hu Tao Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- backends/hostmem-file.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'backends/hostmem-file.c') diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 55d1c62ddd..92659c119d 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -9,7 +9,9 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ +#include "qemu-common.h" #include "sysemu/hostmem.h" +#include "sysemu/sysemu.h" #include "qom/object_interfaces.h" /* hostmem-file.c */ @@ -46,6 +48,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) error_setg(errp, "-mem-path not supported on this host"); #else if (!memory_region_size(&backend->mr)) { + backend->force_prealloc = mem_prealloc; memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), object_get_canonical_path(OBJECT(backend)), backend->size, -- cgit v1.2.1