From patchwork Thu Mar 31 13:52:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avishay Traeger1 X-Patchwork-Id: 89079 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 867B5B6F7C for ; Fri, 1 Apr 2011 00:53:20 +1100 (EST) Received: from localhost ([127.0.0.1]:60084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5IJI-0003pw-UN for incoming@patchwork.ozlabs.org; Thu, 31 Mar 2011 09:53:16 -0400 Received: from [140.186.70.92] (port=42027 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5IIV-0003pq-CH for qemu-devel@nongnu.org; Thu, 31 Mar 2011 09:52:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5IIT-0002Fd-HJ for qemu-devel@nongnu.org; Thu, 31 Mar 2011 09:52:27 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:56425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5IIT-0002Eu-AC for qemu-devel@nongnu.org; Thu, 31 Mar 2011 09:52:25 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2VDqEYg017659 for ; Thu, 31 Mar 2011 13:52:14 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2VDqoah1876088 for ; Thu, 31 Mar 2011 14:52:50 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2VDqEmn011548 for ; Thu, 31 Mar 2011 07:52:14 -0600 Received: from d12mc102.megacenter.de.ibm.com (d12nrml1506.megacenter.de.ibm.com [9.149.165.56] (may be forged)) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p2VDqDXE011540 for ; Thu, 31 Mar 2011 07:52:14 -0600 X-KeepSent: BBFDA642:7A3B3819-C2257864:004A9649; 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: Thu, 31 Mar 2011 15:52:19 +0200 X-MIMETrack: Serialize by Router on D12MC102/12/M/IBM(Release 8.5.1FP4|July 25, 2010) at 31/03/2011 15:52:19 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.161 Cc: Liran Schour Subject: [Qemu-devel] [PATCH] 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). Cast 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..ffc92ee 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 ((long long)block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time; }