qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC] exec: eliminate ram naming issue as migration


From: Jianfeng Tan
Subject: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration
Date: Mon, 5 Feb 2018 14:58:55 +0000

Existing VMs with virtio devices and vhost-kernel as the backend
are always started with mem config:

  "-m xG"
  (with a ram block named "pc.ram")

while new VMs with virtio devices and vhost-user as the backend
are always started with mem config:

  "-m xG -numa node,memdev=pc.ram -object memory-backend-file,id=pc.ram,..."
  (with a ram block named "/object/pc.ram")

As we migrate from vhost-kernel to vhost-user, it failes as:

  Unknown ramblock "pc.ram", cannot accept migration
  error while loading state for instance 0x0 of device 'ram'
  load of migration failed: Invalid argument

Here are some options to fix this:

1. When we do ram name comparison, we truncate the prefix as this patch shows.
It cannot cover the corner case: the source VM could have two ram blocks
with name of "pc.ram" and "/object/pc.ram".

2. We add an alias name to RAMBlock; when we do name comparison, not only
idstr is compared, but also compared to the alias. But this will add more
complexity to upper layer stack OpenStack/libvirt.

Any thoughts?

Cc: Jason Wang <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Cc: Maxime Coquelin <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Suggested-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Jianfeng Tan <address@hidden>
---
 exec.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index 4722e52..d294e5c 100644
--- a/exec.c
+++ b/exec.c
@@ -2334,13 +2334,24 @@ found:
 RAMBlock *qemu_ram_block_by_name(const char *name)
 {
     RAMBlock *block;
+    char *name1, *id1;
+    char *name2, *id2;
+
+    name1 = strdup(name);
+    id1 = basename(name1);
 
     RAMBLOCK_FOREACH(block) {
-        if (!strcmp(name, block->idstr)) {
+        name2 = strdup(block->idstr);
+       id2 = basename(name2);
+        if (!strcmp(id1, id2)) {
+            free(name1);
+           free(name2);
             return block;
         }
+       free(name2);
     }
 
+    free(name1);
     return NULL;
 }
 
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]