From nobody Wed Apr 16 08:17:03 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558369889; cv=none; d=zoho.com; s=zohoarc; b=UkGigcjVyef47vffx6AnkXr4lbakmGc81/1m2O48bT+fV4pDtLqO1uofyk2gNbFJMMVwZ5e1VKzfu+m/jw+eiIDthLKbhk+OKK5C2mhxtTiFh6MCmEiT8DfbZEX+IWFIjK2oybLmNru2czdun0CALR3kR0xAnLIKGC3FBxuNlTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558369889; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zbNjh4RBKlcKG+dBSXJJWCNZdhWqZPzaYeyHAe5XYeg=; b=kqTo4QscqOOM95eshESAzggXDdAo2v7PAnV6bMPiEYextAF9C5vpwY5L9OBYcafmQGHJ0BCbKKNEnIQG/sW+wqf8qqsZQUcEeXlpE/TKJWMev2YDdjWEKIhww00ihiuZLWSXgtegerdE9mTSG32pDQTCkyEJ6GC2nkSyeZ6wjL4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558369889011574.0548006167819; Mon, 20 May 2019 09:31:29 -0700 (PDT) Received: from localhost ([127.0.0.1]:38251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSlC3-00057J-Tu for importer@patchew.org; Mon, 20 May 2019 12:31:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSkxG-0000FK-7M for qemu-devel@nongnu.org; Mon, 20 May 2019 12:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSkxE-0003nZ-L3 for qemu-devel@nongnu.org; Mon, 20 May 2019 12:16:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hSkx6-0003hu-G4; Mon, 20 May 2019 12:15:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 588163092664; Mon, 20 May 2019 16:15:47 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-208.ams2.redhat.com [10.36.117.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70ECF75261; Mon, 20 May 2019 16:15:45 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 20 May 2019 18:14:50 +0200 Message-Id: <20190520161453.30723-22-kwolf@redhat.com> In-Reply-To: <20190520161453.30723-1-kwolf@redhat.com> References: <20190520161453.30723-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 20 May 2019 16:15:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 21/24] block: Improve "Block node is read-only" message 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Max Reitz This message does not make any sense when it appears as the response to making an R/W node read-only. We should detect that case and emit a different message, then. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 1e5230f98e..cb11537029 100644 --- a/block.c +++ b/block.c @@ -1709,6 +1709,8 @@ static int bdrv_child_check_perm(BdrvChild *c, BlockR= eopenQueue *q, GSList *ignore_children, Error **errp); static void bdrv_child_abort_perm_update(BdrvChild *c); static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shar= ed); +static void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm, + uint64_t *shared_perm); =20 typedef struct BlockReopenQueueEntry { bool prepared; @@ -1795,7 +1797,20 @@ static int bdrv_check_perm(BlockDriverState *bs, Blo= ckReopenQueue *q, if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) && !bdrv_is_writable_after_reopen(bs, q)) { - error_setg(errp, "Block node is read-only"); + if (!bdrv_is_writable_after_reopen(bs, NULL)) { + error_setg(errp, "Block node is read-only"); + } else { + uint64_t current_perms, current_shared; + bdrv_get_cumulative_perm(bs, ¤t_perms, ¤t_shared); + if (current_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED= )) { + error_setg(errp, "Cannot make block node read-only, there = is " + "a writer on it"); + } else { + error_setg(errp, "Cannot make block node read-only and cre= ate " + "a writer on it"); + } + } + return -EPERM; } =20 --=20 2.20.1