From patchwork Fri Jan 18 11:53:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 213605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8FE8E2C0080 for ; Fri, 18 Jan 2013 23:25:00 +1100 (EST) Received: from localhost ([::1]:51011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWv-00007R-9Q for incoming@patchwork.ozlabs.org; Fri, 18 Jan 2013 06:54:41 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWH-000711-IX for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:54:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwAWF-0003pF-Dz for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:54:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAWF-0003p2-5n for qemu-devel@nongnu.org; Fri, 18 Jan 2013 06:53:59 -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 r0IBrwjQ001958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Jan 2013 06:53:58 -0500 Received: from trasno.mitica (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0IBrrUk002451; Fri, 18 Jan 2013 06:53:57 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 18 Jan 2013 12:53:52 +0100 Message-Id: <1358510033-17268-4-git-send-email-quintela@redhat.com> In-Reply-To: <1358510033-17268-1-git-send-email-quintela@redhat.com> References: <1358510033-17268-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] ram: reuse ram_save_iterate() for the complete stage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 | 16 ---------------- migration.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/arch_init.c b/arch_init.c index 9f7d44d..9eef10a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -651,23 +651,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque, uint64_t free_space) static int ram_save_complete(QEMUFile *f, void *opaque) { qemu_mutex_lock_ramlist(); - migration_bitmap_sync(); - - /* 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; - } migration_end(); - qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); diff --git a/migration.c b/migration.c index e74ce49..de665f7 100644 --- a/migration.c +++ b/migration.c @@ -717,6 +717,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(s->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(s->file); if (ret < 0) { qemu_mutex_unlock_iothread();