]> git.proxmox.com Git - mirror_qemu.git/commitdiff
nbd: disallow nbd-server-add before nbd-server-start
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 13:25:17 +0000 (14:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 13:38:29 +0000 (14:38 +0100)
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

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