All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org, Hani Benhabiles <kroosec@gmail.com>
Subject: [Qemu-devel] [PULL 1/5] nbd: Don't export a block device with no medium.
Date: Fri, 27 Jun 2014 16:11:42 +0200	[thread overview]
Message-ID: <1403878306-22683-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1403878306-22683-1-git-send-email-pbonzini@redhat.com>

From: Hani Benhabiles <kroosec@gmail.com>

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>
---
 blockdev-nbd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index b60b66d..18dc528 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;
-- 
1.8.3.1

  reply	other threads:[~2014-06-27 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 14:11 [Qemu-devel] [PULL 0/5] NBD changes for 2014-06-27 Paolo Bonzini
2014-06-27 14:11 ` Paolo Bonzini [this message]
2014-06-27 14:11 ` [Qemu-devel] [PULL 2/5] nbd: Don't validate from and len in NBD_CMD_DISC Paolo Bonzini
2014-06-27 14:11 ` [Qemu-devel] [PULL 3/5] nbd: Shutdown socket before closing Paolo Bonzini
2014-06-27 14:11 ` [Qemu-devel] [PULL 4/5] nbd: Handle fixed new-style clients Paolo Bonzini
2014-06-27 14:11 ` [Qemu-devel] [PULL 5/5] nbd: Handle NBD_OPT_LIST option Paolo Bonzini
2014-06-29 11:45 ` [Qemu-devel] [PULL 0/5] NBD changes for 2014-06-27 Peter Maydell
2014-06-29 11:55   ` Hani Benhabiles
2014-06-30 12:36     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403878306-22683-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kroosec@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.