aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-10-08 17:27:18 +0200
committerKevin Wolf <kwolf@redhat.com>2018-11-05 15:09:55 +0100
commit6c2e581d4d7751f035e9bac0384703879c8a1538 (patch)
treefa7435f4f6ef587d7df116606e0741d8c69e5e77 /block
parenteaa2410f1ea864609090c0a5fda9e0ce9499da79 (diff)
downloadqemu-6c2e581d4d7751f035e9bac0384703879c8a1538.zip
qemu-6c2e581d4d7751f035e9bac0384703879c8a1538.tar.gz
qemu-6c2e581d4d7751f035e9bac0384703879c8a1538.tar.bz2
nbd: Support auto-read-only option
If read-only=off, but auto-read-only=on is given, open a read-write NBD connection if the server provides a read-write export, but instead of erroring out for read-only exports, 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/nbd-client.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 9686ecb..76e9ca3 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -992,11 +992,11 @@ int nbd_client_init(BlockDriverState *bs,
logout("Failed to negotiate with the NBD server\n");
return ret;
}
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
- !bdrv_is_read_only(bs)) {
- error_setg(errp,
- "request for write access conflicts with read-only export");
- return -EACCES;
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
+ if (ret < 0) {
+ return ret;
+ }
}
if (client->info.flags & NBD_FLAG_SEND_FUA) {
bs->supported_write_flags = BDRV_REQ_FUA;