From patchwork Tue Apr 5 15:41:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8753211 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33B59C0553 for ; Tue, 5 Apr 2016 15:44:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93389202D1 for ; Tue, 5 Apr 2016 15:44:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D099D20212 for ; Tue, 5 Apr 2016 15:44:33 +0000 (UTC) Received: from localhost ([::1]:37930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anT9d-0000fn-AV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Apr 2016 11:44:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anT6u-00045g-Is for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anT6o-0001lx-SC for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:41:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anT6o-0001lt-Mg for qemu-devel@nongnu.org; Tue, 05 Apr 2016 11:41:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 522CF64388; Tue, 5 Apr 2016 15:41:38 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u35FfXBt020325; Tue, 5 Apr 2016 11:41:37 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 5 Apr 2016 17:41:26 +0200 Message-Id: <1459870888-9246-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1459870888-9246-1-git-send-email-kwolf@redhat.com> References: <1459870888-9246-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Apr 2016 15:41:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 2/4] block: Forbid I/O throttling on nodes with multiple parents for 2.6 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As the patches to move I/O throttling to BlockBackend didn't make it in time for the 2.6 release, but the release adds new ways of configuring VMs whose behaviour would change once the move is done, we need to outlaw such configurations temporarily. The problem exists whenever a BDS has more users than just its BB, for example it is used as a backing file for another node. (This wasn't possible in 2.5 yet as we introduced node references to specify a backing file only recently.) In these cases, the throttling would apply to these other users now, but after moving throttling to the BlockBackend the other users wouldn't be throttled any more. This patch prevents making new references to a throttled node as well as using monitor commands to throttle a node with multiple parents. Compared to 2.5 this changes behaviour in some corner cases where references were allowed before, like bs->file or Quorum children. It seems reasonable to assume that users didn't use I/O throttling on such low level nodes. With the upcoming move of throttling into BlockBackend, such configurations won't be possible anyway. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 7 +++++++ blockdev.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/block.c b/block.c index d36eb75..d4939b4 100644 --- a/block.c +++ b/block.c @@ -1526,6 +1526,13 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, if (!bs) { return -ENODEV; } + + if (bs->throttle_state) { + error_setg(errp, "Cannot reference an existing block device for " + "which I/O throttling is enabled"); + return -EINVAL; + } + bdrv_ref(bs); *pbs = bs; return 0; diff --git a/blockdev.c b/blockdev.c index 332068a..f1f520a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2661,6 +2661,13 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, goto out; } + /* The BlockBackend must be the only parent */ + assert(QLIST_FIRST(&bs->parents)); + if (QLIST_NEXT(QLIST_FIRST(&bs->parents), next_parent)) { + error_setg(errp, "Cannot throttle device with multiple parents"); + goto out; + } + throttle_config_init(&cfg); cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps; cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;