Skip to contentSkip to conversation

migration/postcopy: Disable shared RAM

PATCH Superseded Dr. David Alan Gilbert (git) 2 participants 5 messages Mar 7, 2017 – Mar 8, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover migration/postcopy: Disable shared RAM

From: "Dr. David Alan Gilbert" <[email protected]>

Disable postcopy migration when there's shared RAM, we're still figuring out the details. Without this patch there's a chance it might appear to succeed in some cases.

Dr. David Alan Gilbert (2):
RAMBlocks: qemu_ram_is_shared
postcopy: Check for shared memory

 exec.c                    |  5 +++++
 include/exec/cpu-common.h |  1 +
 migration/postcopy-ram.c  | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/2 RAMBlocks: qemu_ram_is_shared

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a helper to say whether a RAMBlock was created as a shared mapping.

---
 exec.c                    | 5 +++++
 include/exec/cpu-common.h | 1 +
 2 files changed, 6 insertions(+)
exec.c +5 -0
index aabb035..c2cc455 100644
@@ -1560,6 +1560,11 @@ const char *qemu_ram_get_idstr(RAMBlock *rb)
     return rb->idstr;
 }
 
+bool qemu_ram_is_shared(RAMBlock *rb)
+{
+    return rb->flags & RAM_SHARED;
+}
+
 /* Called with iothread lock held.  */
 void qemu_ram_set_idstr(RAMBlock *new_block, const char *name, DeviceState *dev)
 {
include/exec/cpu-common.h +1 -0
index b62f0d8..4d45a72 100644
@@ -69,6 +69,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
 void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
 void qemu_ram_unset_idstr(RAMBlock *block);
 const char *qemu_ram_get_idstr(RAMBlock *rb);
+bool qemu_ram_is_shared(RAMBlock *rb);
 size_t qemu_ram_pagesize(RAMBlock *block);
 size_t qemu_ram_pagesize_largest(void);
 
Signature · 1 line
2.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] RAMBlocks: qemu_ram_is_shared

Quoted 16 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a helper to say whether a RAMBlock was created as a shared mapping.

---
 exec.c                    | 5 +++++
 include/exec/cpu-common.h | 1 +
 2 files changed, 6 insertions(+)
exec.c +0 -0
index aabb035..c2cc455 100644

exec.c const char *qemu_ram_get_idstr(RAMBlock *rb) · line 1565

Quoted 6 lines
exec.c +3 -0
@@ -1560,6 +1560,11 @@ const char *qemu_ram_get_idstr(RAMBlock *rb)
     return rb->idstr;
 }
 
+bool qemu_ram_is_shared(RAMBlock *rb)
+{
+    return rb->flags & RAM_SHARED;

Hm, it appears to me RAM_SHARED is defined conditionally, that's within #if !defined(CONFIG_USER_ONLY)
#endif

The function however seems to be defined and using RAM_SHARED unconditionally. Either one or the other seems inappropriate to me.

Regards,
Halil

#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] RAMBlocks: qemu_ram_is_shared

Quoted 30 lines · * Halil Pasic ([email protected]) wrote:
Quoted 16 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Provide a helper to say whether a RAMBlock was created as a shared mapping.

---
 exec.c                    | 5 +++++
 include/exec/cpu-common.h | 1 +
 2 files changed, 6 insertions(+)
exec.c +0 -0
index aabb035..c2cc455 100644

exec.c const char *qemu_ram_get_idstr(RAMBlock *rb) · line 1565

Quoted 6 lines
exec.c +3 -0
@@ -1560,6 +1560,11 @@ const char *qemu_ram_get_idstr(RAMBlock *rb)
     return rb->idstr;
 }
 
+bool qemu_ram_is_shared(RAMBlock *rb)
+{
+    return rb->flags & RAM_SHARED;

Hm, it appears to me RAM_SHARED is defined conditionally, that's within #if !defined(CONFIG_USER_ONLY)
#endif

Quoted 2 lines

The function however seems to be defined and using RAM_SHARED unconditionally. Either one or the other seems inappropriate to me.

Oops! Thanks for spotting that; I'll go and fix that.

Dave

Quoted 3 lines

Regards,
Halil

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw

PATCH 2/2 postcopy: Check for shared memory

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Postcopy doesn't support migration of RAM shared with another process yet (we've got a bunch of things to understand).
Check for the case and don't allow postcopy to be enabled.

---
 migration/postcopy-ram.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
migration/postcopy-ram.c +18 -0
index effbeb6..dc80dbb 100644
@@ -95,6 +95,19 @@ static bool ufd_version_check(int ufd)
     return true;
 }
 
+/* Callback from postcopy_ram_supported_by_host block iterator.
+ */
+static int test_range_shared(const char *block_name, void *host_addr,
+                             ram_addr_t offset, ram_addr_t length, void *opaque)
+{
+    if (qemu_ram_is_shared(qemu_ram_block_by_name(block_name))) {
+        error_report("Postcopy on shared RAM (%s) is not yet supported",
+                     block_name);
+        return 1;
+    }
+    return 0;
+}
+
 /*
  * Note: This has the side effect of munlock'ing all of RAM, that's
  * normally fine since if the postcopy succeeds it gets turned back on at the
@@ -127,6 +140,11 @@ bool postcopy_ram_supported_by_host(void)
         goto out;
     }
 
+    /* We don't support postcopy with shared RAM yet */
+    if (qemu_ram_foreach_block(test_range_shared, NULL)) {
+        goto out;
+    }
+
     /*
      * userfault and mlock don't go together; we'll put it back later if
      * it was enabled.
Signature · 1 line
2.9.3