nbd: Forbid nbd-server-stop when server is not running
Since we already forbid other nbd-server commands when not
in the right state, it is unlikely that any caller was relying
on a second stop to behave as a silent no-op. Update iotest
223 to show the improved behavior.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190111194720.15671-3-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 1d170c8..ca58491 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -214,6 +214,11 @@
void qmp_nbd_server_stop(Error **errp)
{
+ if (!nbd_server) {
+ error_setg(errp, "NBD server not running");
+ return;
+ }
+
nbd_export_close_all();
nbd_server_free(nbd_server);