From patchwork Mon Nov 12 14:22:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/7] nbd: fix nbd_server_stop crash when no server was running From: Paolo Bonzini X-Patchwork-Id: 198397 Message-Id: <1352730127-32685-5-git-send-email-pbonzini@redhat.com> To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com Date: Mon, 12 Nov 2012 15:22:04 +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 --- blockdev-nbd.c | 8 +++++--- 1 file modificato, 5 inserzioni(+), 3 rimozioni(-) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 8031813..274fba6 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -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; + } }