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
Subject: [Qemu-devel] [RFC v2 2/6] migration: add shared migration type
Date: Fri, 18 Mar 2016 10:13:54 +0100	[thread overview]
Message-ID: <1458292438-13909-3-git-send-email-b.reynal@virtualopensystems.com> (raw)
In-Reply-To: <1458292438-13909-1-git-send-email-b.reynal@virtualopensystems.com>

A QEMU instance can now wait for the instantiation of the memory by the
master while shared-memory backend is used.

Use:
-incoming "shared:<shared-memory_id>"

Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
---
 backends/hostmem-shared.c     |  6 ++++++
 include/migration/migration.h |  2 ++
 migration/Makefile.objs       |  2 +-
 migration/migration.c         |  2 ++
 migration/shared.c            | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 migration/shared.c

diff --git a/backends/hostmem-shared.c b/backends/hostmem-shared.c
index b45a87b..e703c30 100644
--- a/backends/hostmem-shared.c
+++ b/backends/hostmem-shared.c
@@ -11,6 +11,7 @@
  */
 
 #include "sysemu/hostmem-shared.h"
+#include "migration/vmstate.h"
 
 static void shm_map(HostMemoryBackendShared *shm, size_t size, off_t offset)
 {
@@ -96,6 +97,11 @@ shared_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
                     set_shared_memory, shm);
         }
     }
+
+    shm->levent = g_new(EventNotifier, 1);
+    event_notifier_init(shm->levent, 0);
+
+    shm->event = event_notifier_get_fd(shm->levent);
 }
 
 static void
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 8334621..0d4efa5 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -114,6 +114,8 @@ void migrate_fd_connect(MigrationState *s);
 
 int migrate_fd_close(MigrationState *s);
 
+void shared_start_incoming_migration(const char *name, Error **errp);
+
 void add_migration_state_change_notifier(Notifier *notify);
 void remove_migration_state_change_notifier(Notifier *notify);
 bool migration_in_setup(MigrationState *);
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
index d929e96..08c96f7 100644
--- a/migration/Makefile.objs
+++ b/migration/Makefile.objs
@@ -7,4 +7,4 @@ common-obj-$(CONFIG_RDMA) += rdma.o
 common-obj-$(CONFIG_POSIX) += exec.o unix.o fd.o
 
 common-obj-y += block.o
-
+common-obj-y += shared.o
diff --git a/migration/migration.c b/migration/migration.c
index 662e77e..798801c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -249,6 +249,8 @@ void qemu_start_incoming_migration(const char *uri, Error **errp)
         deferred_incoming_migration(errp);
     } else if (strstart(uri, "tcp:", &p)) {
         tcp_start_incoming_migration(p, errp);
+    } else if (strstart(uri, "shared:", &p)) {
+        shared_start_incoming_migration(p, errp);
 #ifdef CONFIG_RDMA
     } else if (strstart(uri, "rdma:", &p)) {
         rdma_start_incoming_migration(p, errp);
diff --git a/migration/shared.c b/migration/shared.c
new file mode 100644
index 0000000..1371a71
--- /dev/null
+++ b/migration/shared.c
@@ -0,0 +1,33 @@
+#include "qemu-common.h"
+#include "qemu/main-loop.h"
+#include "qemu/sockets.h"
+#include "migration/migration.h"
+#include "monitor/monitor.h"
+#include "migration/qemu-file.h"
+#include "block/block.h"
+#include "sysemu/hostmem-shared.h"
+
+static void shared_accept_incoming_migration(void *opaque)
+{
+    QEMUFile *f = opaque;
+    printf("Start !\n");
+
+    qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL);
+    vm_start();
+}
+
+void shared_start_incoming_migration(const char *id, Error **errp)
+{
+    HostMemoryBackendShared *shm = (HostMemoryBackendShared *)
+        object_resolve_path_type(id, TYPE_MEMORY_BACKEND_SHARED, NULL);
+    QEMUFile *f;
+
+    if (shm == NULL) {
+        printf("Error: Cannot find shared memory %s\n", id);
+        exit(-1);
+    }
+
+    f = qemu_fdopen(shm->event, "rb");
+
+    qemu_set_fd_handler(shm->event, shared_accept_incoming_migration, NULL, f);
+}
-- 
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 ` Baptiste Reynal [this message]
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 ` [Qemu-devel] [RFC v2 6/6] qemu: numa Baptiste Reynal
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-3-git-send-email-b.reynal@virtualopensystems.com \
    --to=b.reynal@virtualopensystems.com \
    --cc=Claudio.Fontana@huawei.com \
    --cc=Jani.Kokkonen@huawei.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).