qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Baptiste Reynal <b.reynal@virtualopensystems.com>
To: qemu-devel@nongnu.org
Cc: b.reynal@virtualopensystems.com, Jani.Kokkonen@huawei.com,
	tech@virtualopensystems.com, Claudio.Fontana@huawei.com,
	Christian Pinto <c.pinto@virtualopensystems.com>
Subject: [Qemu-devel] [RFC v2 6/6] qemu: numa
Date: Fri, 18 Mar 2016 10:13:58 +0100	[thread overview]
Message-ID: <1458292438-13909-7-git-send-email-b.reynal@virtualopensystems.com> (raw)
In-Reply-To: <1458292438-13909-1-git-send-email-b.reynal@virtualopensystems.com>

From: Christian Pinto <c.pinto@virtualopensystems.com>

This patch modifies the behavior of
memory_region_allocate_system_memory, when the new shared memory backend
is used from a slave qemu instance.
In such case there is not yet a valid pointer for the memory region pointed
by the backend (it will be innitilized later when received from the master.)
and vmstate_register would fail.

The patch skips the call to vmstate_register in case of slave shared memory
backend, that will be performed later after the actual memory pointer is
available.

Signed-off-by: Christian Pinto <c.pinto@virtualopensystems.com>
---
 numa.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/numa.c b/numa.c
index e9b18f5..b39a892 100644
--- a/numa.c
+++ b/numa.c
@@ -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;
     }
 }
-- 
2.7.3

  parent reply	other threads:[~2016-03-18  9:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18  9:13 [Qemu-devel] [RFC v2 0/6] QEMU shared-memory backend Baptiste Reynal
2016-03-18  9:13 ` [Qemu-devel] [RFC v2 1/6] backend: shared memory backend Baptiste Reynal
2016-03-18  9:13 ` [Qemu-devel] [RFC v2 2/6] migration: add shared migration type Baptiste Reynal
2016-03-18  9:13 ` [Qemu-devel] [RFC v2 3/6] hw/misc: sdm signal shboot Baptiste Reynal
2016-03-18  9:13 ` [Qemu-devel] [RFC v2 4/6] qemu: slave machine flag Baptiste Reynal
2016-03-18  9:13 ` [Qemu-devel] [RFC v2 5/6] hw/arm: boot Baptiste Reynal
2016-03-18  9:13 ` Baptiste Reynal [this message]
2016-03-22 14:14 ` [Qemu-devel] [RFC v2 0/6] QEMU shared-memory backend Markus Armbruster
2016-03-22 14:54   ` Baptiste Reynal
2016-04-07 16:27     ` Markus Armbruster
2016-04-08 12:52       ` Baptiste Reynal
2016-04-08 13:59         ` Markus Armbruster
2016-03-31  9:14 ` Stefan Hajnoczi
2016-04-05 12:00   ` Baptiste Reynal
2016-04-06  8:57     ` Stefan Hajnoczi
2016-04-06 13:47       ` Igor Mammedov
2016-04-08 12:46         ` Baptiste Reynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458292438-13909-7-git-send-email-b.reynal@virtualopensystems.com \
    --to=b.reynal@virtualopensystems.com \
    --cc=Claudio.Fontana@huawei.com \
    --cc=Jani.Kokkonen@huawei.com \
    --cc=c.pinto@virtualopensystems.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).