From patchwork Fri Feb 5 10:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 579434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DDE861402C9 for ; Fri, 5 Feb 2016 22:02:40 +1100 (AEDT) Received: from localhost ([::1]:47492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRe9u-0003B2-QQ for incoming@patchwork.ozlabs.org; Fri, 05 Feb 2016 06:02:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRe9N-00027T-K5 for qemu-devel@nongnu.org; Fri, 05 Feb 2016 06:02:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRe9M-0003yN-Iy for qemu-devel@nongnu.org; Fri, 05 Feb 2016 06:02:05 -0500 Received: from smtp3.mundo-r.com ([212.51.32.191]:14701 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRe9M-0003jc-DF; Fri, 05 Feb 2016 06:02:04 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CoAgAzgLRW/5tjdVteGQEBAQEPAQEBAY0ksQ0NgWaGDQKBODgUAQEBAQEBAYEKhEIBBXkQPxI8GxmIHwHAB4gHiy4FlnONUI5zjj8eAkKDZopkAQEB X-IPAS-Result: A2CoAgAzgLRW/5tjdVteGQEBAQEPAQEBAY0ksQ0NgWaGDQKBODgUAQEBAQEBAYEKhEIBBXkQPxI8GxmIHwHAB4gHiy4FlnONUI5zjj8eAkKDZopkAQEB X-IronPort-AV: E=Sophos;i="5.22,399,1449529200"; d="scan'208";a="81163409" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 05 Feb 2016 11:59:48 +0100 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1aRe78-0007eQ-Hz; Fri, 05 Feb 2016 11:59:46 +0100 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1aRe6v-0007dH-9V; Fri, 05 Feb 2016 12:59:33 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 5 Feb 2016 12:59:15 +0200 Message-Id: X-Mailer: git-send-email 2.7.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 05/13] throttle: Set always an average value when setting a maximum value 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 When testing the ranges of valid values, set_cfg_value() creates sometimes invalid throttling configurations by setting bucket.max while leaving bucket.avg uninitialized. While this doesn't break the current tests, it will as soon as we unify all functions that check the validity of the throttling configuration. This patch ensures that the value of bucket.avg is valid when setting bucket.max. Signed-off-by: Alberto Garcia --- tests/test-throttle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 5f0b7d4..5031eb7 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -221,6 +221,8 @@ static void set_cfg_value(bool is_max, int index, int value) { if (is_max) { cfg.buckets[index].max = value; + /* If max is set, avg should never be 0 */ + cfg.buckets[index].avg = MAX(cfg.buckets[index].avg, 1); } else { cfg.buckets[index].avg = value; }