[Libguestfs] [PATCH 11/11] New API: btrfs_qgroup_remove

Hu Tao
Fri, 05 Dec 2014 08:20:42 -0000

btrfs_qgroup_remove removes a qgroup from its parent qgroup.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 daemon/btrfs.c       | 33 +++++++++++++++++++++++++++++++++
 generator/actions.ml |  9 +++++++++
 src/MAX_PROC_NR      |  2 +-
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 0a04dd3..d40c432 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1305,3 +1305,36 @@ int do_btrfs_qgroup_assign (const char *src, const char
*dst, const char *path)

   return 0;
 }
+
+int do_btrfs_qgroup_remove (const char *src, const char *dst, const char *path)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *path_buf = NULL;
+  CLEANUP_FREE char *err = NULL;
+  CLEANUP_FREE char *out = NULL;
+  int r;
+
+  path_buf = sysroot_path (path);
+  if (path_buf == NULL) {
+    reply_with_perror ("malloc");
+    return -1;
+  }
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "qgroup");
+  ADD_ARG (argv, i, "remove");
+  ADD_ARG (argv, i, src);
+  ADD_ARG (argv, i, dst);
+  ADD_ARG (argv, i, path_buf);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", path, err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index deb2d58..c1169cc 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12120,6 +12120,15 @@ usages." };
 Add qgroup C<src> to parent qgroup C<dst>. This command can group
 several qgroups into a parent qgroup to share common limit." };

+  { defaults with
+    name = "btrfs_qgroup_remove";
+    style = RErr, [String "src"; String "dst"; Pathname
"path"], [];
+    proc_nr = Some 435;
+    optional = Some "btrfs"; camel_name =
"BTRFSQgroupRemove";
+    shortdesc = "remove a qgroup from its parent qgroup";
+    longdesc = "\
+Remove qgroup C<src> from the parent qgroup C<dst>." };
+
 ]

 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index e828e5d..5910394 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-434
+435
--
1.9.3