aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2018-01-19 16:57:16 +0300
committerEric Blake <eblake@redhat.com>2018-01-26 09:37:20 -0600
commita3b0dc75829d910073e841539cb5ae4e6f75c09b (patch)
treed2554b82e6bfe8ab281d255916019b688708d162 /blockdev-nbd.c
parentdba49323ea83c8e661a279e8b69737fd18783a19 (diff)
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 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 104789e521..a9f79c6778 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -189,6 +189,30 @@ void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
nbd_export_put(exp);
}
+void qmp_nbd_server_remove(const char *name,
+ bool has_mode, NbdServerRemoveMode mode,
+ Error **errp)
+{
+ NBDExport *exp;
+
+ if (!nbd_server) {
+ error_setg(errp, "NBD server not running");
+ return;
+ }
+
+ exp = nbd_export_find(name);
+ if (exp == NULL) {
+ error_setg(errp, "Export '%s' is not found", name);
+ return;
+ }
+
+ if (!has_mode) {
+ mode = NBD_SERVER_REMOVE_MODE_SAFE;
+ }
+
+ nbd_export_remove(exp, mode, errp);
+}
+
void qmp_nbd_server_stop(Error **errp)
{
nbd_export_close_all();