aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-11-04 12:43:37 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-11-12 14:38:29 +0100
commite644473445177671ec408dfdec705cf931657998 (patch)
tree2dcdbfbb181138f0dd378f5f158a313ce11dbf0c /blockdev-nbd.c
parentfc6467eaf22f974620b5dd046afca04e619f9be9 (diff)
nbd: force read-only export for read-only devices
This is the desired behavior for HMP, but it is a better choice for QMP as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 274fba6e46..e362572279 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -93,6 +93,13 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
return;
}
+ if (!has_writable) {
+ writable = true;
+ }
+ if (bdrv_is_read_only(bs)) {
+ writable = false;
+ }
+
exp = nbd_export_new(bs, 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY,
nbd_server_put_ref);