summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2020-02-19 11:08:41 -0500
committerPatchew Importer <importer@patchew.org>2020-02-19 16:49:54 +0000
commitfe64d06afc1c5d895f220c268cfe4d5f1e65d44e (patch)
tree7a510e51d0c2cff98c01543888bf1c74f11cc5a6
parenta1b18df9a4848fc8a906e40c275063bfe9ca2047 (diff)
downloadfocaccia-qemu-fe64d06afc1c5d895f220c268cfe4d5f1e65d44e.tar.gz
focaccia-qemu-fe64d06afc1c5d895f220c268cfe4d5f1e65d44e.zip
vl.c: ensure that ram_size matches size of machine.memory-backend
Extend set_memory_options() to check that size specified by -m
matches the size of backend pointed by memory-backend.
And in case of -m was omitted adjust ram_size to match that
of explicitly provided backend.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20200219160953.13771-8-imammedo@redhat.com>
-rw-r--r--vl.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 72ffc06f2f..a7edcba094 100644
--- a/vl.c
+++ b/vl.c
@@ -2655,6 +2655,21 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
         exit(EXIT_FAILURE);
     }
 
+    if (current_machine->ram_memdev_id) {
+        Object *backend;
+        ram_addr_t backend_size;
+
+        backend = object_resolve_path_type(current_machine->ram_memdev_id,
+                                           TYPE_MEMORY_BACKEND, NULL);
+        backend_size = object_property_get_uint(backend, "size",  &error_abort);
+        if (mem_str && backend_size != ram_size) {
+                error_report("Size specified by -m option must match size of "
+                             "explicitly specified 'memory-backend' property");
+                exit(EXIT_FAILURE);
+        }
+        ram_size = backend_size;
+    }
+
     if (!xen_enabled()) {
         /* On 32-bit hosts, QEMU is limited by virtual address space */
         if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {