From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDXfb-0002ub-5W for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDXfW-00020s-Jo for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:38 -0400 From: Kevin Wolf Date: Fri, 19 Oct 2018 18:30:05 +0200 Message-Id: <20181019163013.11787-2-kwolf@redhat.com> In-Reply-To: <20181019163013.11787-1-kwolf@redhat.com> References: <20181019163013.11787-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 01/11] block: Update flags in bdrv_set_read_only() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org To fully change the read-only state of a node, we must not only change bs->read_only, but also update bs->open_flags. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index 0d6e5f1a76..d7bd6d29b4 100644 --- a/block.c +++ b/block.c @@ -281,6 +281,13 @@ int bdrv_set_read_only(BlockDriverState *bs, bool re= ad_only, Error **errp) } =20 bs->read_only =3D read_only; + + if (read_only) { + bs->open_flags &=3D ~BDRV_O_RDWR; + } else { + bs->open_flags |=3D BDRV_O_RDWR; + } + return 0; } =20 --=20 2.19.1