summaryrefslogtreecommitdiffstats
path: root/nbd
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2018-01-19 14:57:16 +0100
committerEric Blake2018-01-26 16:37:20 +0100
commita3b0dc75829d910073e841539cb5ae4e6f75c09b (patch)
treed2554b82e6bfe8ab281d255916019b688708d162 /nbd
parenthmp: Add name parameter to nbd_server_add (diff)
downloadqemu-a3b0dc75829d910073e841539cb5ae4e6f75c09b.tar.gz
qemu-a3b0dc75829d910073e841539cb5ae4e6f75c09b.tar.xz
qemu-a3b0dc75829d910073e841539cb5ae4e6f75c09b.zip
qapi: add nbd-server-remove
Add command for removing an export. It is needed for cases when we don't want to keep the export after the operation on it was completed. The other example is a temporary node, created with blockdev-add. If we want to delete it we should firstly remove any corresponding NBD export. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20180119135719.24745-3-vsementsov@virtuozzo.com> [eblake: drop dead nb_clients code] Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/server.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/nbd/server.c b/nbd/server.c
index 6caa8d17be..112e3f69df 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1177,6 +1177,19 @@ void nbd_export_close(NBDExport *exp)
nbd_export_put(exp);
}
+void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error **errp)
+{
+ if (mode == NBD_SERVER_REMOVE_MODE_HARD || QTAILQ_EMPTY(&exp->clients)) {
+ nbd_export_close(exp);
+ return;
+ }
+
+ assert(mode == NBD_SERVER_REMOVE_MODE_SAFE);
+
+ error_setg(errp, "export '%s' still in use", exp->name);
+ error_append_hint(errp, "Use mode='hard' to force client disconnect\n");
+}
+
void nbd_export_get(NBDExport *exp)
{
assert(exp->refcount > 0);