|
|
7711c0 |
From 4c382f6bee06a3af0b05e321beca89e39b6caa1f Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 27 Mar 2019 17:22:27 +0100
|
|
|
7711c0 |
Subject: [PATCH 088/163] nbd: Forbid nbd-server-stop when server is not
|
|
|
7711c0 |
running
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190327172308.31077-15-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85187
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 14/55] nbd: Forbid nbd-server-stop when server is not running
|
|
|
7711c0 |
Bugzilla: 1691009
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Since we already forbid other nbd-server commands when not
|
|
|
7711c0 |
in the right state, it is unlikely that any caller was relying
|
|
|
7711c0 |
on a second stop to behave as a silent no-op. Update iotest
|
|
|
7711c0 |
223 to show the improved behavior.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Message-Id: <20190111194720.15671-3-eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
(cherry picked from commit 7801c3a7fd7042fd2f9435af4b9a6d2094073174)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
blockdev-nbd.c | 5 +++++
|
|
|
7711c0 |
tests/qemu-iotests/223 | 2 +-
|
|
|
7711c0 |
tests/qemu-iotests/223.out | 2 +-
|
|
|
7711c0 |
3 files changed, 7 insertions(+), 2 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
|
|
|
7711c0 |
index 1d170c8..ca58491 100644
|
|
|
7711c0 |
--- a/blockdev-nbd.c
|
|
|
7711c0 |
+++ b/blockdev-nbd.c
|
|
|
7711c0 |
@@ -214,6 +214,11 @@ void qmp_nbd_server_remove(const char *name,
|
|
|
7711c0 |
|
|
|
7711c0 |
void qmp_nbd_server_stop(Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
+ if (!nbd_server) {
|
|
|
7711c0 |
+ error_setg(errp, "NBD server not running");
|
|
|
7711c0 |
+ return;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+
|
|
|
7711c0 |
nbd_export_close_all();
|
|
|
7711c0 |
|
|
|
7711c0 |
nbd_server_free(nbd_server);
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
|
|
|
7711c0 |
index 61b46a2..a401609 100755
|
|
|
7711c0 |
--- a/tests/qemu-iotests/223
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/223
|
|
|
7711c0 |
@@ -172,7 +172,7 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
|
|
|
7711c0 |
_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
|
|
|
7711c0 |
"arguments":{"name":"n2"}}' "error" # Attempt duplicate clean
|
|
|
7711c0 |
_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
|
|
|
7711c0 |
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return" # Oops
|
|
|
7711c0 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "error" # Again
|
|
|
7711c0 |
_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
|
|
|
7711c0 |
|
|
|
7711c0 |
# success, all done
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
|
|
|
7711c0 |
index c1eed62..7d28c1a 100644
|
|
|
7711c0 |
--- a/tests/qemu-iotests/223.out
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/223.out
|
|
|
7711c0 |
@@ -69,6 +69,6 @@ read 2097152/2097152 bytes at offset 2097152
|
|
|
7711c0 |
{"return": {}}
|
|
|
7711c0 |
{"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}}
|
|
|
7711c0 |
{"return": {}}
|
|
|
7711c0 |
-{"return": {}}
|
|
|
7711c0 |
+{"error": {"class": "GenericError", "desc": "NBD server not running"}}
|
|
|
7711c0 |
{"return": {}}
|
|
|
7711c0 |
*** done
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|