diff mbox series

[04/18] fuse: Add fuse-export-remove

Message ID 20191219143818.1646168-5-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: Allow exporting BDSs via FUSE | expand

Commit Message

Max Reitz Dec. 19, 2019, 2:38 p.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/fuse.c    | 16 ++++++++++++++++
 qapi/block.json | 15 +++++++++++++++
 2 files changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/block/fuse.c b/block/fuse.c
index f18e8e7591..4e662e6dfb 100644
--- a/block/fuse.c
+++ b/block/fuse.c
@@ -123,6 +123,22 @@  fail:
     close_fuse_session(session);
 }
 
+void qmp_fuse_export_remove(const char *mountpoint, Error **errp)
+{
+    BdrvFuseSession *session = NULL;
+
+    if (sessions) {
+        session = g_hash_table_lookup(sessions, mountpoint);
+    }
+
+    if (!session) {
+        error_setg(errp, "No export found on '%s'", mountpoint);
+        return;
+    }
+
+    g_hash_table_remove(sessions, mountpoint);
+}
+
 /**
  * Drop all FUSE exports.
  */
diff --git a/qapi/block.json b/qapi/block.json
index 03f8d1b537..26768dc8ef 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -340,6 +340,21 @@ 
   },
   'if': 'defined(CONFIG_FUSE)' }
 
+##
+# @fuse-export-remove:
+#
+# Unmount an exported block graph node.
+#
+# @mountpoint: The export path given to fuse-export-add
+#
+# Since: 5.0
+##
+{ 'command': 'fuse-export-remove',
+  'data': {
+      'mountpoint': 'str'
+  },
+  'if': 'defined(CONFIG_FUSE)' }
+
 ##
 # @DEVICE_TRAY_MOVED:
 #