From nobody Thu Nov 6 08:27:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539853316484621.1693039027615; Thu, 18 Oct 2018 02:01:56 -0700 (PDT) Received: from localhost ([::1]:41157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD4Be-0001zV-5Q for importer@patchew.org; Thu, 18 Oct 2018 05:01:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD49c-00010q-0Z for qemu-devel@nongnu.org; Thu, 18 Oct 2018 04:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD49Z-0008H2-84 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 04:59:39 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:55298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gD49Y-0007ju-FF; Thu, 18 Oct 2018 04:59:36 -0400 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gD49O-0002eA-KH; Thu, 18 Oct 2018 10:59:26 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gD495-00046b-9h; Thu, 18 Oct 2018 11:59:07 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=mShf7+2d/ko57IgWNWQPlxz/InbuFbMg8r+L+fuUBYM=; b=CRmg2LOFTOATwJEanICard54fwPiT60hF2CVMkQs9kqvXuS5Unu06Mt3mtgkQ2igYR9AuTnZbx2rVHSLquDFnRmnKSLPUuN2dMtWwSnhoZm0YxAMWQhfScGaUhBMNHB/RC07xjTvys5aag3FNIQD3As4gDeP85euIPzvtMC/fwte9vokUVEuHuBLZHlBrXlvUxjtWw0Hgw+FV0mFaYZlwUinD/YIk1Fwa/nfOoLu6sXe6o1gx9NMrHwkmgoIfvdQRmaoEhubdo+wr3SeX5fEENy0laHgGLr1aMITza69UEkNzonIgcr6GyTwrrMMAmVt+KbxAmwQmJ/zpVKJs0fOJQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 11:59:03 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 1/2] quorum: Forbid adding children in blkverify mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The blkverify mode of Quorum only works when the number of children is exactly two, so any attempt to add a new one must return an error. quorum_del_child() on the other hand doesn't need any additional check because decreasing the number of children would make it go under the vote threshold. Signed-off-by: Alberto Garcia Reported-by: Kevin Wolf --- block/quorum.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 6188ff6666..16b3c8067c 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -992,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, Blo= ckDriverState *child_bs, char indexstr[32]; int ret; =20 + if (s->is_blkverify) { + error_setg(errp, "Cannot add a child to a quorum in blkverify mode= "); + return; + } + assert(s->num_children <=3D INT_MAX / sizeof(BdrvChild *)); if (s->num_children =3D=3D INT_MAX / sizeof(BdrvChild *) || s->next_child_index =3D=3D UINT_MAX) { @@ -1046,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, Bd= rvChild *child, return; } =20 + /* We know now that num_children > threshold, so blkverify must be fal= se */ + assert(!s->is_blkverify); + bdrv_drained_begin(bs); =20 /* We can safely remove this child now */ --=20 2.11.0