aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
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();