From patchwork Mon Apr 4 15:26:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 605898 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qdwnW1Vf3z9s9x for ; Tue, 5 Apr 2016 01:26:39 +1000 (AEST) Received: from localhost ([::1]:59347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an6Oj-0001u4-DO for incoming@patchwork.ozlabs.org; Mon, 04 Apr 2016 11:26:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an6ON-0001RI-U9 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 11:26:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1an6OM-0007qp-WE for qemu-devel@nongnu.org; Mon, 04 Apr 2016 11:26:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an6OG-0007pf-O6; Mon, 04 Apr 2016 11:26:08 -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 681C05D; Mon, 4 Apr 2016 15:26:08 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u34FQ5HQ017004; Mon, 4 Apr 2016 11:26:06 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 4 Apr 2016 17:26:02 +0200 Message-Id: <1459783562-28859-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, stefanha@redhat.com Subject: [Qemu-devel] [PATCH for-2.6] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 both 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 Reviewed-by: Alberto Garcia --- 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;