@@ -33,6 +33,7 @@
#include "qapi/dealloc-visitor.h"
#include "hw/boards.h"
#include "sysemu/hostmem.h"
+#include "sysemu/hostmem-shared.h"
#include "qmp-commands.h"
#include "hw/mem/pc-dimm.h"
#include "qemu/option.h"
@@ -442,6 +443,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
{
uint64_t addr = 0;
int i;
+ bool vmstate_register = true;
if (nb_numa_nodes == 0 || !have_memdevs) {
allocate_system_memory_nonnuma(mr, owner, name, ram_size);
@@ -453,9 +455,18 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
Error *local_err = NULL;
uint64_t size = numa_info[i].node_mem;
HostMemoryBackend *backend = numa_info[i].node_memdev;
+
if (!backend) {
continue;
}
+
+ if (IS_MEMORY_BACKEND_SHARED(backend)) {
+ HostMemoryBackendShared *shm = MEMORY_BACKEND_SHARED(backend);
+ if (!shm->master) {
+ vmstate_register = false;
+ }
+ }
+
MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err);
if (local_err) {
error_report_err(local_err);
@@ -471,7 +482,11 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
}
memory_region_add_subregion(mr, addr, seg);
- vmstate_register_ram_global(seg);
+
+ if (vmstate_register) {
+ vmstate_register_ram_global(seg);
+ }
+
addr += size;
}
}