From: Lei Li <lilei@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aarcange@redhat.com, aliguori@us.ibm.com,
Lei Li <lilei@linux.vnet.ibm.com>,
quintela@redhat.com, mrhines@linux.vnet.ibm.com,
lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 16/18] migration-local: implementation of incoming part
Date: Wed, 21 Aug 2013 15:18:54 +0800 [thread overview]
Message-ID: <1377069536-12658-18-git-send-email-lilei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com>
Implementation of incoming part of localhost migration.
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
include/migration/migration.h | 2 +
include/migration/qemu-file.h | 8 ++--
migration-local.c | 99 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 4 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index a04f050..232f1d5 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -94,6 +94,8 @@ void rdma_start_incoming_migration(const char *host_port, Error **errp);
void local_start_outgoing_migration(void *opaque, const char *uri, Error **errp);
+void local_start_incoming_migration(const char *uri, Error **errp);
+
void migrate_fd_error(MigrationState *s);
void migrate_fd_connect(MigrationState *s);
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 0f757fb..a34d418 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -77,10 +77,10 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque, uint64_t flags);
* is saved (such as RDMA, for example.)
*/
typedef size_t (QEMURamSaveFunc)(QEMUFile *f, void *opaque,
- ram_addr_t block_offset,
- ram_addr_t offset,
- size_t size,
- int *bytes_sent);
+ ram_addr_t block_offset,
+ ram_addr_t offset,
+ size_t size,
+ int *bytes_sent);
typedef struct QEMUFileOps {
QEMUFilePutBufferFunc *put_buffer;
diff --git a/migration-local.c b/migration-local.c
index cf4a091..501371a 100644
--- a/migration-local.c
+++ b/migration-local.c
@@ -294,3 +294,102 @@ fail:
g_free(local);
migrate_fd_error(s);
}
+
+
+/**********************************************************************
+ * Incoming part
+ */
+
+static void unix_accept_local_incoming(void *opaque)
+{
+ struct sockaddr_un addr;
+ socklen_t addrlen = sizeof(addr);
+ int s = (intptr_t)opaque;
+ QEMUFile *f;
+ int c;
+
+ do {
+ c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
+ } while (c == -1 && errno == EINTR);
+
+ qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+ close(s);
+
+ DPRINTF("accepted migration\n");
+
+ if (c == -1) {
+ fprintf(stderr, "could not accept migration connection\n");
+ goto out;
+ }
+
+ f = qemu_fopen_local(c, "rb");
+ if (f == NULL) {
+ fprintf(stderr, "could not qemu_fopen socket\n");
+ goto out;
+ }
+
+ start_local_incoming_migration(f);
+
+ return;
+
+out:
+ close(c);
+}
+
+static void unix_local_incoming_connect(const char *path, Error **errp)
+{
+ int ret;
+
+ ret = unix_listen(path, NULL, 0, errp);
+ if (ret < 0) {
+ return;
+ }
+
+ qemu_set_fd_handler2(ret, NULL, unix_accept_local_incoming, NULL,
+ (void *)(intptr_t)ret);
+}
+void local_start_incoming_migration(const char *uri, Error **errp)
+{
+ QEMUFileLocal *s = g_malloc0(sizeof(*s));
+ Error *local_err = NULL;
+
+ DPRINTF("Starting local incoming migration\n");
+
+ if (uri) {
+ unix_local_incoming_connect(uri, errp);
+ } else {
+ goto err;
+ }
+
+ DPRINTF("unix_listen success\n");
+
+ return;
+
+err:
+ error_propagate(errp, local_err);
+ g_free(s);
+}
+
+static void start_local_incoming_migration(QEMUFile *f)
+{
+ int ret;
+
+ ret = qemu_loadvm_state(f);
+ if (ret < 0) {
+ fprintf(stderr, "load of migration failed\n");
+ exit(EXIT_FAILURE);
+ }
+ qemu_announce_self();
+
+ DPRINTF("successfully loaded vm state\n");
+
+ bdrv_clear_incoming_migration_all();
+ /* Make sure all file formats flush their mutable metadata */
+ bdrv_invalidate_cache_all();
+
+ if (autostart) {
+ vm_start();
+ } else {
+ runstate_set(RUN_STATE_PAUSED);
+ }
+}
--
1.7.7.6
next prev parent reply other threads:[~2013-08-21 7:21 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 7:18 [Qemu-devel] [PATCH 0/18 RFC v3] Localhost migration Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 01/18] migration: export MIG_STATE_xxx flags Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 02/18] savevm: export qemu_save_device_state() Lei Li
2013-08-21 11:13 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 03/18] rename is_active to is_block_active Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 04/18] savevm: set right return value for qemu_file_rate_limit Lei Li
2013-08-21 10:42 ` Paolo Bonzini
2013-08-23 3:18 ` Lei Li
2013-08-23 5:34 ` Paolo Bonzini
2013-08-23 9:11 ` Lei Li
2013-08-23 9:14 ` Paolo Bonzini
2013-08-23 9:18 ` Lei Li
2013-08-23 9:22 ` Paolo Bonzini
2013-08-23 9:25 ` Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 05/18] savevm: add comments for qemu_file_get_error() Lei Li
2013-08-21 10:43 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 06/18] bugfix: wrong error set by ram_control_load_hook() Lei Li
2013-08-21 10:40 ` Paolo Bonzini
2013-08-23 3:22 ` Lei Li
2013-08-23 5:34 ` Paolo Bonzini
2013-08-23 6:31 ` Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 07/18] arch_init: export RAM_SAVE_xxx flags Lei Li
2013-08-21 10:49 ` Paolo Bonzini
2013-08-22 20:14 ` Michael R. Hines
2013-08-23 7:36 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 08/18] migration-local: introduce qemu_fopen_local() Lei Li
2013-08-22 20:42 ` Michael R. Hines
2013-08-23 7:44 ` Lei Li
2013-08-28 3:26 ` Lei Li
2013-08-28 6:37 ` Paolo Bonzini
2013-08-29 8:28 ` Lei Li
2013-08-29 14:05 ` Michael R. Hines
2013-08-21 7:18 ` [Qemu-devel] [PATCH 09/18] exec: export qemu_get_ram_block() Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 10/18] migration-local: implementation of outgoing part Lei Li
2013-08-21 10:44 ` Paolo Bonzini
2013-08-22 20:49 ` Michael R. Hines
2013-08-21 7:18 ` [Qemu-devel] [PATCH 11/18] migration: introduce capability localhost Lei Li
2013-08-21 15:08 ` Eric Blake
2013-08-28 4:22 ` Lei Li
2013-08-21 15:18 ` Paolo Bonzini
2013-08-22 20:50 ` Michael R. Hines
2013-08-23 7:40 ` Paolo Bonzini
2013-08-23 7:51 ` Lei Li
2013-08-23 8:01 ` Paolo Bonzini
2013-08-23 9:21 ` Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 12/18] arch_init: factor out ram_save_blocks() Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 13/18] arch_init: adjust ram_save_setup() for migrate_is_localhost Lei Li
2013-08-21 10:48 ` Paolo Bonzini
2013-08-23 6:25 ` Lei Li
2013-08-23 7:48 ` Paolo Bonzini
2013-08-23 7:57 ` Alex Bligh
2013-08-23 8:06 ` Paolo Bonzini
2013-08-23 9:00 ` Lei Li
2013-08-23 9:12 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 14/18] arch_init: skip migration_bitmap_sync for local migration Lei Li
2013-08-21 10:50 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 15/18] migration: adjust migration_thread " Lei Li
2013-08-21 10:47 ` Paolo Bonzini
2013-08-21 7:18 ` [Qemu-devel] [PATCH 16/18] migration-local: implementation of incoming part Lei Li
2013-08-21 7:18 ` Lei Li [this message]
2013-08-21 7:18 ` [Qemu-devel] [PATCH 17/18] migration: add prefix for local migration to incoming migration Lei Li
2013-08-21 10:52 ` Paolo Bonzini
2013-08-23 14:02 ` Lei Li
2013-08-21 7:18 ` [Qemu-devel] [PATCH 18/18] hmp: better fomat for info migrate_capabilities Lei Li
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=1377069536-12658-18-git-send-email-lilei@linux.vnet.ibm.com \
--to=lilei@linux.vnet.ibm.com \
--cc=aarcange@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=lagarcia@br.ibm.com \
--cc=mrhines@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rcj@linux.vnet.ibm.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).