From patchwork Wed Feb 13 15:53:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 220182 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 08AAE2C007C for ; Thu, 14 Feb 2013 03:00:39 +1100 (EST) Received: from localhost ([::1]:51236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5efE-0005S8-5N for incoming@patchwork.ozlabs.org; Wed, 13 Feb 2013 10:54:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5eem-0004NX-8I for qemu-devel@nongnu.org; Wed, 13 Feb 2013 10:54:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5eee-0008At-Qr for qemu-devel@nongnu.org; Wed, 13 Feb 2013 10:54:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5eee-0008AU-HP for qemu-devel@nongnu.org; Wed, 13 Feb 2013 10:53:52 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1DFrpx2016406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Feb 2013 10:53:51 -0500 Received: from localhost (ovpn-112-21.ams2.redhat.com [10.36.112.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1DFro5o025483; Wed, 13 Feb 2013 10:53:51 -0500 From: Stefan Hajnoczi To: Date: Wed, 13 Feb 2013 16:53:43 +0100 Message-Id: <1360770823-29046-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1360770823-29046-1-git-send-email-stefanha@redhat.com> References: <1360770823-29046-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 2/2] block: refuse negative iops and bps values 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 Negative I/O throttling iops and bps values do not make sense so reject them with an error message. Signed-off-by: Stefan Hajnoczi --- blockdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/blockdev.c b/blockdev.c index 9b03513..ba3759c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -274,6 +274,16 @@ static bool do_check_io_limits(BlockIOLimit *io_limits, Error **errp) return false; } + if (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] < 0 || + io_limits->bps[BLOCK_IO_LIMIT_WRITE] < 0 || + io_limits->bps[BLOCK_IO_LIMIT_READ] < 0 || + io_limits->iops[BLOCK_IO_LIMIT_TOTAL] < 0 || + io_limits->iops[BLOCK_IO_LIMIT_WRITE] < 0 || + io_limits->iops[BLOCK_IO_LIMIT_READ] < 0) { + error_setg(errp, "bps and iops values must be 0 or greater"); + return false; + } + return true; }