From patchwork Thu Oct 18 07:30:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 192214 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 C4D532C0093 for ; Thu, 18 Oct 2012 18:41:00 +1100 (EST) Received: from localhost ([::1]:42229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkaQ-0006hI-Bf for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 03:32:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZO-0005PF-Cs for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOkZK-0000fX-3J for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOkZJ-0000fN-Pv for qemu-devel@nongnu.org; Thu, 18 Oct 2012 03:31:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9I7V147030089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Oct 2012 03:31:01 -0400 Received: from trasno.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9I7URna020816; Thu, 18 Oct 2012 03:30:59 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 09:30:13 +0200 Message-Id: <1350545426-23172-18-git-send-email-quintela@redhat.com> In-Reply-To: <1350545426-23172-1-git-send-email-quintela@redhat.com> References: <1350545426-23172-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 17/30] migration: move migration_fd_put_ready() 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 Put it near its use and un-export it. Signed-off-by: Juan Quintela --- migration.c | 132 ++++++++++++++++++++++++++++++------------------------------ migration.h | 1 - 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/migration.c b/migration.c index b1567f3..a99653e 100644 --- a/migration.c +++ b/migration.c @@ -300,72 +300,6 @@ ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, return ret; } -bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size) -{ - int ret; - static bool first_time = true; - uint64_t pending_size; - bool last_round = false; - - qemu_mutex_lock_iothread(); - if (s->state != MIG_STATE_ACTIVE) { - DPRINTF("put_ready returning because of non-active state\n"); - qemu_mutex_unlock_iothread(); - return false; - } - if (first_time) { - first_time = false; - DPRINTF("beginning savevm\n"); - ret = qemu_savevm_state_begin(s->file, &s->params); - if (ret < 0) { - DPRINTF("failed, %d\n", ret); - migrate_fd_error(s); - qemu_mutex_unlock_iothread(); - return false; - } - } - - 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 >= max_size) { - ret = qemu_savevm_state_iterate(s->file); - if (ret < 0) { - migrate_fd_error(s); - } - } else { - int old_vm_running = runstate_is_running(); - int64_t start_time, end_time; - - DPRINTF("done iterating\n"); - start_time = qemu_get_clock_ms(rt_clock); - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); - if (old_vm_running) { - vm_stop(RUN_STATE_FINISH_MIGRATE); - } else { - vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); - } - - if (qemu_savevm_state_complete(s->file) < 0) { - migrate_fd_error(s); - } else { - migrate_fd_completed(s); - } - end_time = qemu_get_clock_ms(rt_clock); - s->total_time = end_time - s->total_time; - s->downtime = end_time - start_time; - if (s->state != MIG_STATE_COMPLETED) { - if (old_vm_running) { - vm_start(); - } - } - last_round = true; - } - qemu_mutex_unlock_iothread(); - - return last_round; -} - static void migrate_fd_cancel(MigrationState *s) { if (s->state != MIG_STATE_ACTIVE) @@ -718,6 +652,72 @@ static int64_t buffered_get_rate_limit(void *opaque) return s->xfer_limit; } +static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size) +{ + int ret; + static bool first_time = true; + uint64_t pending_size; + bool last_round = false; + + qemu_mutex_lock_iothread(); + if (s->state != MIG_STATE_ACTIVE) { + DPRINTF("put_ready returning because of non-active state\n"); + qemu_mutex_unlock_iothread(); + return false; + } + if (first_time) { + first_time = false; + DPRINTF("beginning savevm\n"); + ret = qemu_savevm_state_begin(s->file, &s->params); + if (ret < 0) { + DPRINTF("failed, %d\n", ret); + migrate_fd_error(s); + qemu_mutex_unlock_iothread(); + return false; + } + } + + 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 >= max_size) { + ret = qemu_savevm_state_iterate(s->file); + if (ret < 0) { + migrate_fd_error(s); + } + } else { + int old_vm_running = runstate_is_running(); + int64_t start_time, end_time; + + DPRINTF("done iterating\n"); + start_time = qemu_get_clock_ms(rt_clock); + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); + if (old_vm_running) { + vm_stop(RUN_STATE_FINISH_MIGRATE); + } else { + vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); + } + + if (qemu_savevm_state_complete(s->file) < 0) { + migrate_fd_error(s); + } else { + migrate_fd_completed(s); + } + end_time = qemu_get_clock_ms(rt_clock); + s->total_time = end_time - s->total_time; + s->downtime = end_time - start_time; + if (s->state != MIG_STATE_COMPLETED) { + if (old_vm_running) { + vm_start(); + } + } + last_round = true; + } + qemu_mutex_unlock_iothread(); + + return last_round; +} + /* 100ms xfer_limit is the limit that we should write each 100ms */ #define BUFFER_DELAY 100 diff --git a/migration.h b/migration.h index 40c8e9c..f4c4d1e 100644 --- a/migration.h +++ b/migration.h @@ -81,7 +81,6 @@ void migrate_fd_connect(MigrationState *s); ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, size_t size); -bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size); int migrate_fd_close(MigrationState *s); void add_migration_state_change_notifier(Notifier *notify);