diff mbox

[RFC,3/4] migration: extend shared migration type

Message ID 1458825402-9592-4-git-send-email-b.reynal@virtualopensystems.com
State New
Headers show

Commit Message

Baptiste Reynal March 24, 2016, 1:16 p.m. UTC
shared migration now supports shared or network memory.

Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
---
 migration/shared.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/migration/shared.c b/migration/shared.c
index 1371a71..eb13eb9 100644
--- a/migration/shared.c
+++ b/migration/shared.c
@@ -6,6 +6,7 @@ 
 #include "migration/qemu-file.h"
 #include "block/block.h"
 #include "sysemu/hostmem-shared.h"
+#include "sysemu/hostmem-network.h"
 
 static void shared_accept_incoming_migration(void *opaque)
 {
@@ -18,16 +19,29 @@  static void shared_accept_incoming_migration(void *opaque)
 
 void shared_start_incoming_migration(const char *id, Error **errp)
 {
+    HostMemoryBackendNetwork *shmn;
     HostMemoryBackendShared *shm = (HostMemoryBackendShared *)
         object_resolve_path_type(id, TYPE_MEMORY_BACKEND_SHARED, NULL);
     QEMUFile *f;
+    int event = 0;
 
-    if (shm == NULL) {
+    if (!shm) {
+        shmn = (HostMemoryBackendNetwork *) object_resolve_path_type(id,
+                TYPE_MEMORY_BACKEND_NETWORK, NULL);
+
+        if (shmn) {
+            event = shmn->event;
+        }
+    } else {
+        event = shm->event;
+    }
+
+    if (!event) {
         printf("Error: Cannot find shared memory %s\n", id);
         exit(-1);
     }
 
-    f = qemu_fdopen(shm->event, "rb");
+    f = qemu_fdopen(event, "rb");
 
-    qemu_set_fd_handler(shm->event, shared_accept_incoming_migration, NULL, f);
+    qemu_set_fd_handler(event, shared_accept_incoming_migration, NULL, f);
 }