[Libguestfs] [PATCH 6/8] New API: btrfs_qgroup_limit

Hu Tao hutao at cn.fujitsu.com
Tue Dec 2 09:33:36 UTC 2014


btrfs_qgroup_limit limits the size of a qgroup.

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

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 6918d4f..033d460 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1088,3 +1088,35 @@ int do_btrfs_quota_rescan (const char *path)
 
   return 0;
 }
+
+int do_btrfs_qgroup_limit (const char *subvolume, const char *size)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *subvolume_buf = NULL;
+  CLEANUP_FREE char *err = NULL;
+  CLEANUP_FREE char *out = NULL;
+  int r;
+
+  subvolume_buf = sysroot_path (subvolume);
+  if (subvolume_buf == NULL) {
+    reply_with_perror ("malloc");
+    return -1;
+  }
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "qgroup");
+  ADD_ARG (argv, i, "limit");
+  ADD_ARG (argv, i, size);
+  ADD_ARG (argv, i, subvolume_buf);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", subvolume, err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index f24d5d7..5d64350 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12072,6 +12072,16 @@ Disable subvolume quota support for filesystem which contains C<path>." };
     longdesc = "\
 Trash all qgroup numbers and scan the metadata again with the current config." };
 
+  { defaults with
+    name = "btrfs_qgroup_limit";
+    style = RErr, [Pathname "subvolume"; String "size"], [];
+    proc_nr = Some 430;
+    optional = Some "btrfs"; camel_name = "BTRFSQgroupLimit";
+    shortdesc = "limit the size of a subvolume";
+    longdesc = "\
+Limit the size of a subvolume which's path is C<subvolume>. C<size>
+can have suffix of G, M, or K. " };
+
 ]
 
 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 3560666..c15fb93 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-429
+430
-- 
1.9.3




More information about the Libguestfs mailing list