Patchwork [6/7] nbd: disallow nbd-server-add before nbd-server-start

login
register
mail settings
Submitter Paolo Bonzini
Date Nov. 12, 2012, 2:22 p.m.
Message ID <1352730127-32685-7-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/198398/
State New
Headers show

Comments

Paolo Bonzini - Nov. 12, 2012, 2:22 p.m.
It works nicely with the QMP commands, but it adds useless complication
with HMP.  In particular, see the following:

    (qemu) nbd_server_add -w scsi0-hd0
    (qemu) nbd_server_start -a localhost:10809
    NBD server already exporting device scsi0-hd0

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 blockdev-nbd.c | 5 +++++
 1 file modificato, 5 inserzioni(+)

Patch

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index e362572..d1721a3 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -82,6 +82,11 @@  void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
     NBDExport *exp;
     NBDCloseNotifier *n;
 
+    if (server_fd == -1) {
+        error_setg(errp, "NBD server not running");
+        return;
+    }
+
     if (nbd_export_find(device)) {
         error_setg(errp, "NBD server already exporting device '%s'", device);
         return;