]> git.proxmox.com Git - qemu.git/commitdiff
nbd: force read-only export for read-only devices
authorPaolo Bonzini <pbonzini@redhat.com>
Sun, 4 Nov 2012 11:43:37 +0000 (12:43 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 13:38:29 +0000 (14:38 +0100)
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>
blockdev-nbd.c

index 274fba6e46c0d3eae2728e02d4252e0ce76789ec..e362572279649dab78e9e268186d62e684fbdfe5 100644 (file)
@@ -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);