From patchwork Wed Apr 6 07:45:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avishay Traeger1 X-Patchwork-Id: 89994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ACD2D1007D1 for ; Wed, 6 Apr 2011 17:46:41 +1000 (EST) Received: from localhost ([127.0.0.1]:38721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7NRb-0002Sy-Un for incoming@patchwork.ozlabs.org; Wed, 06 Apr 2011 03:46:28 -0400 Received: from [140.186.70.92] (port=41189 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7NQn-0002Sh-RN for qemu-devel@nongnu.org; Wed, 06 Apr 2011 03:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7NQm-0002qR-EB for qemu-devel@nongnu.org; Wed, 06 Apr 2011 03:45:37 -0400 Received: from mtagate4.uk.ibm.com ([194.196.100.164]:44286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7NQm-0002pq-4t for qemu-devel@nongnu.org; Wed, 06 Apr 2011 03:45:36 -0400 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p367jVhB032747 for ; Wed, 6 Apr 2011 07:45:31 GMT Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p367kDwR1360094 for ; Wed, 6 Apr 2011 08:46:13 +0100 Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p367jVqv010456 for ; Wed, 6 Apr 2011 01:45:31 -0600 Received: from d12mc102.megacenter.de.ibm.com (d12nrml1506.megacenter.de.ibm.com [9.149.164.56] (may be forged)) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p367jVx7010451; Wed, 6 Apr 2011 01:45:31 -0600 X-KeepSent: AD44D129:4AF3C869-C225786A:002A612B; type=4; name=$KeepSent To: qemu-devel@nongnu.org X-Mailer: Lotus Notes Build V852_06012010 June 01, 2010 Message-ID: From: Avishay Traeger Date: Wed, 6 Apr 2011 10:45:36 +0300 X-MIMETrack: Serialize by Router on D12MC102/12/M/IBM(Release 8.5.1FP4|July 25, 2010) at 06/04/2011 10:45:36 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 194.196.100.164 Cc: Kevin Wolf , Liran Schour Subject: [Qemu-devel] [PATCH v2] Fix integer overflow in block migration bandwidth calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a negative number, resulting in a negative bandwidth (running on a 32-bit machine). Change order to avoid. Signed-off-by: Avishay Traeger --- block-migration.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector) -- 1.7.0.4 diff --git a/block-migration.c b/block-migration.c index 8218bac..576e55a 100644 --- a/block-migration.c +++ b/block-migration.c @@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time) static inline long double compute_read_bwidth(void) { assert(block_mig_state.total_time != 0); - return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time; + return (block_mig_state.reads / block_mig_state.total_time) * BLOCK_SIZE; }