[Pkg-libvirt-commits] [libguestfs] 106/384: New API: btrfs_qgroup_limit

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 16:55:53 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit a325f887b35618c141ea79b826b4bf9f64a644e2
Author: Hu Tao <hutao at cn.fujitsu.com>
Date:   Fri Dec 12 15:03:28 2014 +0800

    New API: btrfs_qgroup_limit
    
    btrfs_qgroup_limit limits the size of a qgroup.
    
    Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
---
 daemon/btrfs.c       | 35 +++++++++++++++++++++++++++++++++++
 generator/actions.ml | 22 ++++++++++++++++++++++
 src/MAX_PROC_NR      |  2 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 4eef131..173420d 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1085,3 +1085,38 @@ error:
     return -1;
   return r;
 }
+
+int
+do_btrfs_qgroup_limit (const char *subvolume, int64_t 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;
+  char size_str[32];
+  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");
+  snprintf (size_str, sizeof size_str, "%" PRIi64, size);
+  ADD_ARG (argv, i, size_str);
+  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 9c61ff7..5fe592c 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12131,6 +12131,28 @@ Enable or 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"; Int64 "size"], [];
+    proc_nr = Some 429;
+    optional = Some "btrfs"; camel_name = "BTRFSQgroupLimit";
+    tests = [
+      InitPartition, Always, TestRun (
+        [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+         ["mount"; "/dev/sda1"; "/"];
+         ["btrfs_quota_enable"; "/"; "true"];
+         ["btrfs_qgroup_limit"; "/"; "10737418240"]]), [];
+      InitPartition, Always, TestLastFail (
+        [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+         ["mount"; "/dev/sda1"; "/"];
+         ["btrfs_quota_enable"; "/"; "false"];
+         ["btrfs_qgroup_limit"; "/"; "10737418240"]]), [];
+    ];
+    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 43d371a..3560666 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-428
+429

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list