From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC2jB-0001Hm-Dz for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VC2j2-00016U-1M for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:21:13 -0400 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:60251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC2j1-00015r-FN for qemu-devel@nongnu.org; Wed, 21 Aug 2013 03:21:03 -0400 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Aug 2013 12:45:08 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 3C68F394004E for ; Wed, 21 Aug 2013 12:50:48 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7L7KpOK42991708 for ; Wed, 21 Aug 2013 12:50:52 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7L7KrCR028253 for ; Wed, 21 Aug 2013 12:50:54 +0530 From: Lei Li Date: Wed, 21 Aug 2013 15:18:52 +0800 Message-Id: <1377069536-12658-16-git-send-email-lilei@linux.vnet.ibm.com> In-Reply-To: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> References: <1377069536-12658-1-git-send-email-lilei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 15/18] migration: adjust migration_thread for local migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, aliguori@us.ibm.com, Lei Li , quintela@redhat.com, mrhines@linux.vnet.ibm.com, lagarcia@br.ibm.com, pbonzini@redhat.com, rcj@linux.vnet.ibm.com Integrate localhost migration thread to migration_thread. As the mechanism of local migration is different than the current migration, and it does not need to do iterate. So the whole thread can split into two stages, it will send all the ram pages in qemu_savevm_state_begin stage, and send the device states in qemu_save_device_state stage. Signed-off-by: Lei Li --- migration.c | 73 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 45 insertions(+), 28 deletions(-) diff --git a/migration.c b/migration.c index 2f85358..2471664 100644 --- a/migration.c +++ b/migration.c @@ -565,37 +565,54 @@ static void *migration_thread(void *opaque) while (s->state == MIG_STATE_ACTIVE) { int64_t current_time; uint64_t pending_size; + int ret; - if (!qemu_file_rate_limit(s->file)) { - DPRINTF("iterate\n"); - pending_size = qemu_savevm_state_pending(s->file, max_size); - DPRINTF("pending size %lu max %lu\n", pending_size, max_size); - if (pending_size && pending_size >= max_size) { - qemu_savevm_state_iterate(s->file); - } else { - int ret; - - DPRINTF("done iterating\n"); - qemu_mutex_lock_iothread(); - start_time = qemu_get_clock_ms(rt_clock); - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); - old_vm_running = runstate_is_running(); - - ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); - if (ret >= 0) { - qemu_file_set_rate_limit(s->file, INT_MAX); - qemu_savevm_state_complete(s->file); - } - qemu_mutex_unlock_iothread(); + if (s->enabled_capabilities[MIGRATION_CAPABILITY_LOCALHOST]) { + DPRINTF("local migration start\n"); - if (ret < 0) { - migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR); - break; - } + ret = qemu_save_device_state(s->file); + if (ret < 0) { + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR); + break; + } - if (!qemu_file_get_error(s->file)) { - migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); - break; + if (!qemu_file_get_error(s->file)) { + DPRINTF("local migration completed\n"); + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); + break; + } + } else { + if (!qemu_file_rate_limit(s->file)) { + DPRINTF("iterate\n"); + pending_size = qemu_savevm_state_pending(s->file, max_size); + DPRINTF("pending size %lu max %lu\n", pending_size, max_size); + if (pending_size && pending_size >= max_size) { + qemu_savevm_state_iterate(s->file); + } else { + int ret; + + DPRINTF("done iterating\n"); + qemu_mutex_lock_iothread(); + start_time = qemu_get_clock_ms(rt_clock); + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); + old_vm_running = runstate_is_running(); + + ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); + if (ret >= 0) { + qemu_file_set_rate_limit(s->file, INT_MAX); + qemu_savevm_state_complete(s->file); + } + qemu_mutex_unlock_iothread(); + + if (ret < 0) { + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR); + break; + } + + if (!qemu_file_get_error(s->file)) { + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); + break; + } } } } -- 1.7.7.6