diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-11-12 14:12:54 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-11-12 14:38:29 +0100 |
commit | fc6467eaf22f974620b5dd046afca04e619f9be9 (patch) | |
tree | 82b2d9ef560b8121dc721cc3447dbb0f2ce73d80 /blockdev-nbd.c | |
parent | 1d7d2a9d2191c34bd1ad69b420db9b47faa3fb8c (diff) | |
download | qemu-fc6467eaf22f974620b5dd046afca04e619f9be9.zip qemu-fc6467eaf22f974620b5dd046afca04e619f9be9.tar.gz qemu-fc6467eaf22f974620b5dd046afca04e619f9be9.tar.bz2 |
nbd: fix nbd_server_stop crash when no server was running
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>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r-- | blockdev-nbd.c | 8 |
1 files changed, 5 insertions, 3 deletions
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; + } } |