From patchwork Thu May 16 20:59:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 244423 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 860D52C00A9 for ; Fri, 17 May 2013 07:00:30 +1000 (EST) Received: from localhost ([::1]:32941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud5Ho-0007XM-SY for incoming@patchwork.ozlabs.org; Thu, 16 May 2013 17:00:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud5HW-0007X3-K7 for qemu-devel@nongnu.org; Thu, 16 May 2013 17:00:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ud5HT-0005hd-Jh for qemu-devel@nongnu.org; Thu, 16 May 2013 17:00:10 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:44456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud5HT-0005gq-1U for qemu-devel@nongnu.org; Thu, 16 May 2013 17:00:07 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 May 2013 06:53:37 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 17 May 2013 06:53:35 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 2B9A82BB0023 for ; Fri, 17 May 2013 06:59:58 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4GKjtrk19595410 for ; Fri, 17 May 2013 06:45:56 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4GKxuxB030925 for ; Fri, 17 May 2013 06:59:56 +1000 Received: from titi.austin.ibm.com (titi.austin.ibm.com [9.41.105.234]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r4GKxs4l030883; Fri, 17 May 2013 06:59:55 +1000 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Thu, 16 May 2013 15:59:54 -0500 Message-Id: <1368737994-15630-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13051620-7014-0000-0000-00000308A61D X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.148 Cc: Anthony Liguori , Mike Roth , Juan Quintela Subject: [Qemu-devel] [PATCH] migration: fix divide-by-zero introduced by sleep time accounting 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 If current_time == (initial_time + sleep_time), since sleep_time == BUFFER_DELAY, time_spent will be 0 resulting in a divide-by-zero when computing bandwidth. This was introduced by: commit 7161082c8d8cf167c508976887a0a63f4db92b51 Author: Juan Quintela Date: Fri Feb 1 12:41:38 2013 +0100 migration: don't account sleep time for calculating bandwidth Cc: Juan Quintela Reported-by: Mike Roth Signed-off-by: Anthony Liguori --- migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration.c b/migration.c index 3eb0fad..70ae7a9 100644 --- a/migration.c +++ b/migration.c @@ -539,7 +539,7 @@ static void *migration_thread(void *opaque) break; } current_time = qemu_get_clock_ms(rt_clock); - if (current_time >= initial_time + BUFFER_DELAY) { + if ((current_time - sleep_time) >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes; uint64_t time_spent = current_time - initial_time - sleep_time; double bandwidth = transferred_bytes / time_spent;