From 900c0ba373aada4c13d47d95330aa72ec4067ba5 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 19 Feb 2020 11:08:37 -0500 Subject: machine: alias -mem-path and -mem-prealloc into memory-foo backend Allow machine to opt in for hostmem backend based initial RAM even if user uses old -mem-path/prealloc options by providing MachineClass::default_ram_id Follow up patches will incrementally convert machines to new API, by dropping memory_region_allocate_system_memory() and setting default_ram_id that board used to use before conversion to keep migration stream the same. Signed-off-by: Igor Mammedov Message-Id: <20200219160953.13771-4-imammedo@redhat.com> --- backends/hostmem-file.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'backends/hostmem-file.c') diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index be64020746..cb319a9157 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -18,13 +18,6 @@ #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" -/* hostmem-file.c */ -/** - * @TYPE_MEMORY_BACKEND_FILE: - * name of backend that uses mmap on a file descriptor - */ -#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file" - #define MEMORY_BACKEND_FILE(obj) \ OBJECT_CHECK(HostMemoryBackendFile, (obj), TYPE_MEMORY_BACKEND_FILE) -- cgit v1.2.3 From 4ebc74dbbf7ad50e4101629f3f5da5fdc1544051 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 19 Feb 2020 11:09:51 -0500 Subject: hostmem: fix strict bind policy When option -mem-prealloc is used with one or more memory-backend objects, created backends may not obey configured bind policy or creation may fail after kernel attempts to move pages according to bind policy. Reason is in file_ram_alloc(), which will pre-allocate any descriptor based RAM if global mem_prealloc != 0 and that happens way before bind policy is applied to memory range. One way to fix it would be to extend memory_region_foo() API and add more invariants that could broken later due implicit dependencies that's hard to track. Another approach is to drop adhoc main RAM allocation and consolidate it around memory-backend. That allows to have single place that allocates guest RAM (main and memdev) in the same way and then global mem_prealloc could be replaced by backend's property[s] that will affect created memory-backend objects but only in correct order this time. With main RAM now converted to hostmem backends, there is no point in keeping global mem_prealloc around, so alias -mem-prealloc to "memory-backend.prealloc=on" machine compat[*] property and make mem_prealloc a local variable to only stir registration of compat property. *) currently user accessible -global works only with DEVICE based objects and extra work is needed to make it work with hostmem backends. But that is convenience option and out of scope of this already huge refactoring. Hence machine compat properties were used. Signed-off-by: Igor Mammedov Message-Id: <20200219160953.13771-78-imammedo@redhat.com> --- backends/hostmem-file.c | 1 - 1 file changed, 1 deletion(-) (limited to 'backends/hostmem-file.c') diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index cb319a9157..c8c355f5aa 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -51,7 +51,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) return; } - backend->force_prealloc = mem_prealloc; name = host_memory_backend_get_name(backend); memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), name, -- cgit v1.2.3