aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-05-18 11:50:04 +0100
committerMichael Roth <mdroth@linux.vnet.ibm.com>2014-07-15 19:28:01 -0500
commit3c3d8c6d19f704796de9a7873b13ba723161d3bd (patch)
tree94773393c92636e21ba6fc4ea8627403b340535b
parent62c754e67cc5eb74a176e4de71028f1fc8638bb5 (diff)
downloadqemu-3c3d8c6d19f704796de9a7873b13ba723161d3bd.zip
qemu-3c3d8c6d19f704796de9a7873b13ba723161d3bd.tar.gz
qemu-3c3d8c6d19f704796de9a7873b13ba723161d3bd.tar.bz2
nbd: Don't export a block device with no medium.
The device is exported with erroneous values and can't be read. Before the patch: $ sudo nbd-client localhost -p 10809 /dev/nbd0 -name floppy0 Negotiation: ..size = 17592186044415MB bs=1024, sz=18446744073709547520 bytes $ sudo mount /dev/nbd0 /mnt/tmp/ mount: block device /dev/nbd0 is write-protected, mounting read-only mount: /dev/nbd0: can't read superblock After the patch: (qemu) nbd_server_add ide0-hd0 (qemu) nbd_server_add floppy0 Device 'floppy0' has no medium Signed-off-by: Hani Benhabiles <kroosec@gmail.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 60fe4fac22895576973e317d7148b084c31cc64c) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--blockdev-nbd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf56..a700d52 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -91,6 +91,10 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
+ if (!bdrv_is_inserted(bs)) {
+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ return;
+ }
if (!has_writable) {
writable = false;