From patchwork Wed Dec 19 12:33:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 207378 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 083392C0085 for ; Thu, 20 Dec 2012 01:54:54 +1100 (EST) Received: from localhost ([::1]:33136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlIsB-0005f1-1F for incoming@patchwork.ozlabs.org; Wed, 19 Dec 2012 07:35:43 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlIr3-0004e5-Er for qemu-devel@nongnu.org; Wed, 19 Dec 2012 07:34:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TlIr0-0004LI-V3 for qemu-devel@nongnu.org; Wed, 19 Dec 2012 07:34:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlIr0-0004LB-MH for qemu-devel@nongnu.org; Wed, 19 Dec 2012 07:34:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBJCYU5S004106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Dec 2012 07:34:30 -0500 Received: from trasno.mitica (ovpn-113-59.phx2.redhat.com [10.3.113.59]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBJCXwuk027690; Wed, 19 Dec 2012 07:34:28 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 19 Dec 2012 13:33:45 +0100 Message-Id: <1355920437-29882-23-git-send-email-quintela@redhat.com> In-Reply-To: <1355920437-29882-1-git-send-email-quintela@redhat.com> References: <1355920437-29882-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini Subject: [Qemu-devel] [PATCH 22/34] migration: add XFER_LIMIT_RATIO 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 The "magic" divisions by 10 are there because of the value of BUFFER_DELAY. Introduce a constant to explain them better. Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- migration.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/migration.c b/migration.c index 26bb85e..a233215 100644 --- a/migration.c +++ b/migration.c @@ -44,6 +44,11 @@ enum { #define MAX_THROTTLE (32 << 20) /* Migration speed throttling */ +/* Amount of time to allocate to each "chunk" of bandwidth-throttled + * data. */ +#define BUFFER_DELAY 100 +#define XFER_LIMIT_RATIO (1000 / BUFFER_DELAY) + /* Migration XBZRLE default cache size */ #define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024) @@ -743,9 +748,6 @@ static int64_t buffered_get_rate_limit(void *opaque) return s->xfer_limit; } -/* 100ms xfer_limit is the limit that we should write each 100ms */ -#define BUFFER_DELAY 100 - static void *buffered_file_thread(void *opaque) { QEMUFileBuffered *s = opaque; @@ -808,7 +810,7 @@ void qemu_fopen_ops_buffered(MigrationState *migration_state) s = g_malloc0(sizeof(*s)); s->migration_state = migration_state; - s->xfer_limit = migration_state->bandwidth_limit / 10; + s->xfer_limit = s->migration_state->bandwidth_limit / XFER_LIMIT_RATIO; s->migration_state->complete = false; s->file = qemu_fopen_ops(s, &buffered_file_ops);