From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: vsementsov@virtuozzo.com, jsnow@redhat.com,
qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v3 2/8] nbd: Forbid nbd-server-stop when server is not running
Date: Fri, 11 Jan 2019 13:47:14 -0600 [thread overview]
Message-ID: <20190111194720.15671-3-eblake@redhat.com> (raw)
In-Reply-To: <20190111194720.15671-1-eblake@redhat.com>
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>
---
v3: new patch
---
blockdev-nbd.c | 5 +++++
tests/qemu-iotests/223 | 2 +-
tests/qemu-iotests/223.out | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 1d170c80b82..ca584919194 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -214,6 +214,11 @@ void qmp_nbd_server_remove(const char *name,
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);
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
index 61b46a2f066..a4016091b21 100755
--- a/tests/qemu-iotests/223
+++ b/tests/qemu-iotests/223
@@ -172,7 +172,7 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
"arguments":{"name":"n2"}}' "error" # Attempt duplicate clean
_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return" # Oops
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "error" # Again
_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
# success, all done
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
index e6ede0591cd..8a4d63a4fc2 100644
--- a/tests/qemu-iotests/223.out
+++ b/tests/qemu-iotests/223.out
@@ -69,6 +69,6 @@ read 2097152/2097152 bytes at offset 2097152
{"return": {}}
{"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}}
{"return": {}}
-{"return": {}}
+{"error": {"class": "GenericError", "desc": "NBD server not running"}}
{"return": {}}
*** done
--
2.20.1
next prev parent reply other threads:[~2019-01-11 19:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 19:47 [Qemu-devel] [PATCH v3 0/8] Promote x-nbd-server-add-bitmap to stable Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 1/8] nbd: Add some error case testing to iotests 223 Eric Blake
2019-01-14 8:25 ` Vladimir Sementsov-Ogievskiy
2019-01-14 15:42 ` Eric Blake
2019-01-11 19:47 ` Eric Blake [this message]
2019-01-14 8:39 ` [Qemu-devel] [PATCH v3 2/8] nbd: Forbid nbd-server-stop when server is not running Vladimir Sementsov-Ogievskiy
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 3/8] nbd: Only require disabled bitmap for read-only exports Eric Blake
2019-01-14 9:49 ` Vladimir Sementsov-Ogievskiy
2019-01-14 15:58 ` Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 4/8] nbd: Merge nbd_export_set_name into nbd_export_new Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 5/8] nbd: Allow bitmap export during QMP nbd-server-add Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 6/8] nbd: Remove x-nbd-server-add-bitmap Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 7/8] nbd: Merge nbd_export_bitmap into nbd_export_new Eric Blake
2019-01-11 19:47 ` [Qemu-devel] [PATCH v3 8/8] qemu-nbd: Add --bitmap=NAME option Eric Blake
2019-01-11 19:57 ` [Qemu-devel] [PATCH v3 0/8] Promote x-nbd-server-add-bitmap to stable Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190111194720.15671-3-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).