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