]> git.proxmox.com Git - qemu.git/commitdiff
nbd: fix nbd_server_stop crash when no server was running
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 13:12:54 +0000 (14:12 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Nov 2012 13:38:29 +0000 (14:38 +0100)
This failed on the new assertion of qemu_set_fd_handler2:

qemu-system-x86_64: /home/pbonzini/work/upstream/qemu/iohandler.c:60: qemu_set_fd_handler2: Assertion `fd >= 0' failed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
blockdev-nbd.c

index 803181307194a100f5f467d94a11f925a3684f06..274fba6e46c0d3eae2728e02d4252e0ce76789ec 100644 (file)
@@ -113,7 +113,9 @@ void qmp_nbd_server_stop(Error **errp)
         nbd_close_notifier(&cn->n, nbd_export_get_blockdev(cn->exp));
     }
 
-    qemu_set_fd_handler2(server_fd, NULL, NULL, NULL, NULL);
-    close(server_fd);
-    server_fd = -1;
+    if (server_fd != -1) {
+        qemu_set_fd_handler2(server_fd, NULL, NULL, NULL, NULL);
+        close(server_fd);
+        server_fd = -1;
+    }
 }