diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-10-08 17:27:18 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-11-05 15:09:55 +0100 |
commit | 8f3bf50d340372662a35564c669e567c6c846943 (patch) | |
tree | 8042b0b30d8dbebda34a3434a9a287442cf16001 /block | |
parent | 54ea21bd16202c4a3e43c67b573b5d1aa2ec1c0c (diff) |
iscsi: Support auto-read-only option
If read-only=off, but auto-read-only=on 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 <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/iscsi.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/block/iscsi.c b/block/iscsi.c index 73998c2860..727dee50bf 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 == TYPE_DISK && (flags & BDRV_O_RDWR) && iscsilun->write_protected) { - error_setg(errp, "Cannot open a write protected LUN as read-write"); - ret = -EACCES; - goto out; + ret = bdrv_apply_auto_read_only(bs, "LUN is write protected", errp); + if (ret < 0) { + goto out; + } + flags &= ~BDRV_O_RDWR; } iscsi_readcapacity_sync(iscsilun, &local_err); |