|
|
ae23c9 |
From 83f682c20418e556f2ef280b0cddfd2df41f8d9f Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Thu, 10 Jan 2019 12:44:35 +0000
|
|
|
ae23c9 |
Subject: [PATCH 05/14] nbd: Support auto-read-only option
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20190110124442.30132-6-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 83953
|
|
|
ae23c9 |
O-Subject: [RHEL-8.0 qemu-kvm PATCH 05/12] nbd: Support auto-read-only option
|
|
|
ae23c9 |
Bugzilla: 1644996
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
If read-only=off, but auto-read-only=on is given, open a read-write NBD
|
|
|
ae23c9 |
connection if the server provides a read-write export, but instead of
|
|
|
ae23c9 |
erroring out for read-only exports, just degrade to read-only.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 6c2e581d4d7751f035e9bac0384703879c8a1538)
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/nbd-client.c | 10 +++++-----
|
|
|
ae23c9 |
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/nbd-client.c b/block/nbd-client.c
|
|
|
ae23c9 |
index 98637c0..80d3625 100644
|
|
|
ae23c9 |
--- a/block/nbd-client.c
|
|
|
ae23c9 |
+++ b/block/nbd-client.c
|
|
|
ae23c9 |
@@ -988,11 +988,11 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
ae23c9 |
logout("Failed to negotiate with the NBD server\n");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
|
|
|
ae23c9 |
- !bdrv_is_read_only(bs)) {
|
|
|
ae23c9 |
- error_setg(errp,
|
|
|
ae23c9 |
- "request for write access conflicts with read-only export");
|
|
|
ae23c9 |
- return -EACCES;
|
|
|
ae23c9 |
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
|
|
|
ae23c9 |
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
|
|
|
ae23c9 |
+ if (ret < 0) {
|
|
|
ae23c9 |
+ return ret;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
if (client->info.flags & NBD_FLAG_SEND_FUA) {
|
|
|
ae23c9 |
bs->supported_write_flags = BDRV_REQ_FUA;
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|