From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDXfe-00030Q-IS for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDXfd-0002E2-FF for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:30:42 -0400 From: Kevin Wolf Date: Fri, 19 Oct 2018 18:30:13 +0200 Message-Id: <20181019163013.11787-10-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 09/11] iscsi: Support auto-read-only option 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 If read-only=3Doff, but auto-read-only=3Don is given, open the volume read-write if we have the permissions, but instead of erroring out for read-only volumes, just degrade to read-only. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/iscsi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index bb69faf34a..130ae26f5f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1878,9 +1878,11 @@ static int iscsi_open(BlockDriverState *bs, QDict = *options, int flags, /* Check the write protect flag of the LUN if we want to write */ if (iscsilun->type =3D=3D TYPE_DISK && (flags & BDRV_O_RDWR) && iscsilun->write_protected) { - error_setg(errp, "Cannot open a write protected LUN as read-writ= e"); - ret =3D -EACCES; - goto out; + ret =3D bdrv_apply_auto_read_only(bs, "LUN is write protected", = errp); + if (ret < 0) { + goto out; + } + flags &=3D ~BDRV_O_RDWR; } =20 iscsi_readcapacity_sync(iscsilun, &local_err); --=20 2.19.1