[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH for-2.10 8/9] block/rbd: do not blindly set bs->read
From: |
Jeff Cody |
Subject: |
[Qemu-block] [PATCH for-2.10 8/9] block/rbd: do not blindly set bs->read_only |
Date: |
Wed, 5 Apr 2017 14:28:50 -0400 |
We do not want to just blindly set bs->read_only. The only time
we need to set it with the current rbd driver, is if we are using an
rbd snapshot. In that case, we must set it to read-only.
Signed-off-by: Jeff Cody <address@hidden>
---
block/rbd.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index c5e1aeb..35853c9 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -635,6 +635,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict
*options, int flags,
goto failed_shutdown;
}
+ /* rbd_open is always r/w */
r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
if (r < 0) {
error_setg_errno(errp, -r, "error reading header from %s",
@@ -642,10 +643,14 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict
*options, int flags,
goto failed_open;
}
- r = bdrv_set_read_only(bs, (s->snap != NULL), &local_err);
- if (r < 0) {
- error_propagate(errp, local_err);
- goto failed_open;
+ /* If we are using an rbd snapshot, we must be r/o, otherwise
+ * leave as-is */
+ if (s->snap != NULL) {
+ r = bdrv_set_read_only(bs, true, &local_err);
+ if (r < 0) {
+ error_propagate(errp, local_err);
+ goto failed_open;
+ }
}
qemu_opts_del(opts);
--
2.9.3