From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFgP4-0001cL-JW for qemu-devel@nongnu.org; Tue, 18 Feb 2014 03:51:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFgOv-0001k4-KK for qemu-devel@nongnu.org; Tue, 18 Feb 2014 03:51:46 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:36348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFgOv-0001jx-EM for qemu-devel@nongnu.org; Tue, 18 Feb 2014 03:51:37 -0500 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Feb 2014 01:51:36 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 9D17A3E4003F for ; Tue, 18 Feb 2014 01:51:34 -0700 (MST) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by b03cxnp08025.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1I8pY5u9699684 for ; Tue, 18 Feb 2014 09:51:34 +0100 Received: from d03av05.boulder.ibm.com (localhost [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1I8pX7r007502 for ; Tue, 18 Feb 2014 01:51:34 -0700 From: mrhines@linux.vnet.ibm.com Date: Tue, 18 Feb 2014 16:50:29 +0800 Message-Id: <1392713429-18201-13-git-send-email-mrhines@linux.vnet.ibm.com> In-Reply-To: <1392713429-18201-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1392713429-18201-1-git-send-email-mrhines@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH v2 12/12] mc: activate and use MC if requested List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: GILR@il.ibm.com, SADEKJ@il.ibm.com, pbonzini@redhat.com, quintela@redhat.com, EREZH@il.ibm.com, owasserm@redhat.com, junqing.wang@cs2c.com.cn, onom@us.ibm.com, abali@us.ibm.com, isaku.yamahata@gmail.com, gokul@us.ibm.com, dbulkow@gmail.com, hinesmr@cn.ibm.com, BIRAN@il.ibm.com, lig.fnst@cn.fujitsu.com, "Michael R. Hines" From: "Michael R. Hines" Once the initial migration has completed, we kickoff the migration_thread, which never dies. Additionally, we register load/save functions for MC which allow us to inform the destination that we are requesting a micro-checkpointing session without needing to add additional command-line switches on the destination side. Signed-off-by: Michael R. Hines --- include/migration/migration.h | 2 +- include/migration/qemu-file.h | 1 + migration.c | 33 ++++++++++++++++++++++++++++----- vl.c | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index f18ff5e..1695e9e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -46,7 +46,7 @@ struct MigrationState int64_t bandwidth_limit; size_t bytes_xfer; size_t xfer_limit; - QemuThread thread; + QemuThread *thread; QEMUBH *cleanup_bh; QEMUFile *file; diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index c50de0d..89e7c19 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -148,6 +148,7 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); QEMUFile *qemu_fopen(const char *filename, const char *mode); QEMUFile *qemu_fdopen(int fd, const char *mode); QEMUFile *qemu_fopen_socket(int fd, const char *mode); +QEMUFile *qemu_fopen_mc(void *opaque, const char *mode); QEMUFile *qemu_popen_cmd(const char *command, const char *mode); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); diff --git a/migration.c b/migration.c index 0ccbeaa..1a6fdbd 100644 --- a/migration.c +++ b/migration.c @@ -93,6 +93,9 @@ static void process_incoming_migration_co(void *opaque) int ret; ret = qemu_loadvm_state(f); + if (ret >= 0) { + mc_process_incoming_checkpoints_if_requested(f); + } qemu_fclose(f); free_xbzrle_decoded_buf(); if (ret < 0) { @@ -313,14 +316,17 @@ static void migrate_fd_cleanup(void *opaque) { MigrationState *s = opaque; - qemu_bh_delete(s->cleanup_bh); - s->cleanup_bh = NULL; + if(s->cleanup_bh) { + qemu_bh_delete(s->cleanup_bh); + s->cleanup_bh = NULL; + } if (s->file) { DPRINTF("closing file\n"); qemu_mutex_unlock_iothread(); - qemu_thread_join(&s->thread); + qemu_thread_join(s->thread); qemu_mutex_lock_iothread(); + g_free(s->thread); qemu_fclose(s->file); s->file = NULL; @@ -695,11 +701,27 @@ static void *migration_thread(void *opaque) s->downtime = end_time - start_time; runstate_set(RUN_STATE_POSTMIGRATE); } else { + if(migrate_use_mc()) { + qemu_fflush(s->file); + if (migrate_use_mc_net()) { + if (mc_enable_buffering() < 0 || + mc_start_buffer() < 0) { + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR); + } + } + } + if (old_vm_running) { vm_start(); } } - qemu_bh_schedule(s->cleanup_bh); + + if (migrate_use_mc() && s->state != MIG_STATE_ERROR) { + mc_init_checkpointer(s); + } else { + qemu_bh_schedule(s->cleanup_bh); + } + qemu_mutex_unlock_iothread(); return NULL; @@ -720,6 +742,7 @@ void migrate_fd_connect(MigrationState *s) /* Notify before starting migration thread */ notifier_list_notify(&migration_state_notifiers, s); - qemu_thread_create(&s->thread, migration_thread, s, + s->thread = g_malloc0(sizeof(*s->thread)); + qemu_thread_create(s->thread, migration_thread, s, QEMU_THREAD_JOINABLE); } diff --git a/vl.c b/vl.c index 2fb5b1f..093eb20 100644 --- a/vl.c +++ b/vl.c @@ -4145,6 +4145,8 @@ int main(int argc, char **argv, char **envp) default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL); + register_savevm(NULL, "mc", -1, MC_VERSION, mc_info_save, + mc_info_load, NULL); if (nb_numa_nodes > 0) { int i; -- 1.8.1.2