Received: from eggs.gnu.org ([208.118.235.92]:51251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPFg-0007Fh-9C for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:48:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TiPFa-0004XN-Ef for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:48:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TiPFa-0004XH-5E for qemu-devel@nongnu.org; Tue, 11 Dec 2012 07:47:54 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBClrpG004749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 07:47:53 -0500 From: Juan Quintela Date: Tue, 11 Dec 2012 13:47:10 +0100 Message-Id: <1355230031-28233-35-git-send-email-quintela@redhat.com> In-Reply-To: <1355230031-28233-1-git-send-email-quintela@redhat.com> References: <1355230031-28233-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 34/35] ram: reuse ram_save_iterate() for the complete stage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This means that we only have one memory loop for the iterate and complete phase. Signed-off-by: Juan Quintela --- arch_init.c | 17 ----------------- migration.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/arch_init.c b/arch_init.c index 6a4ee24..87aecf8 100644 --- a/arch_init.c +++ b/arch_init.c @@ -675,25 +675,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque, uint64_t free_space) static int ram_save_complete(QEMUFile *f, void *opaque) { - migration_bitmap_sync(); - qemu_mutex_lock_ramlist(); - - /* try transferring iterative blocks of memory */ - - /* flush all remaining blocks regardless of rate limiting */ - while (true) { - int bytes_sent; - - bytes_sent = ram_save_block(f); - /* no more blocks to sent */ - if (bytes_sent == 0) { - break; - } - bytes_transferred += bytes_sent; - } memory_global_dirty_log_stop(); - qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); diff --git a/migration.c b/migration.c index d59f7b4..dd6a401 100644 --- a/migration.c +++ b/migration.c @@ -728,6 +728,18 @@ static void *buffered_file_thread(void *opaque) } else { vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); } + + /* 8 is the size of an end of section mark, so empty section */ + while ((ret = qemu_savevm_state_iterate(m->file, free_space)) + > 8) { + ret = buffered_flush(s); + if (ret < 0) { + qemu_mutex_unlock_iothread(); + break; + } + free_space = s->buffer_capacity - s->buffer_size; + } + ret = qemu_savevm_state_complete(m->file); if (ret < 0) { qemu_mutex_unlock_iothread(); -- 1.7.11.7