aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blockdev-nbd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 8031813071..274fba6e46 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;
+ }
}