[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/5] btrfs: add optional parameter `qgroupid' to btrfs_subvolume_snapshot



Parameter `qgroupid' is for adding the created snapshot to a qgroup.

Signed-off-by: Hu Tao <hutao cn fujitsu com>
---
 daemon/btrfs.c       | 8 +++++++-
 generator/actions.ml | 9 ++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 9b48a5d..2b6735f 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -208,7 +208,8 @@ do_mkfs_btrfs (char *const *devices,
 }
 
 int
-do_btrfs_subvolume_snapshot (const char *source, const char *dest, int ro)
+do_btrfs_subvolume_snapshot (const char *source, const char *dest, int ro,
+                             const char *qgroupid)
 {
   const size_t MAX_ARGS = 64;
   const char *argv[MAX_ARGS];
@@ -237,6 +238,11 @@ do_btrfs_subvolume_snapshot (const char *source, const char *dest, int ro)
       ro)
     ADD_ARG (argv, i, "-r");
 
+  if (optargs_bitmask & GUESTFS_BTRFS_SUBVOLUME_SNAPSHOT_QGROUPID_BITMASK) {
+    ADD_ARG (argv, i, "-i");
+    ADD_ARG (argv, i, qgroupid);
+  }
+
   ADD_ARG (argv, i, source_buf);
   ADD_ARG (argv, i, dest_buf);
   ADD_ARG (argv, i, NULL);
diff --git a/generator/actions.ml b/generator/actions.ml
index 47a98e3..e2b3cf5 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10217,7 +10217,7 @@ See C<guestfs_get_e2generation>." };
 
   { defaults with
     name = "btrfs_subvolume_snapshot";
-    style = RErr, [Pathname "source"; Pathname "dest"], [OBool "ro"];
+    style = RErr, [Pathname "source"; Pathname "dest"], [OBool "ro"; OString "qgroupid"];
     proc_nr = Some 322;
     once_had_no_optargs = true;
     optional = Some "btrfs"; camel_name = "BTRFSSubvolumeSnapshot";
@@ -10229,7 +10229,8 @@ See C<guestfs_get_e2generation>." };
          ["btrfs_subvolume_create"; "/test1"];
          ["btrfs_subvolume_create"; "/test2"];
          ["btrfs_subvolume_create"; "/dir/test3"];
-         ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test5"; "true"]]), []
+         ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test5"; "true"; "NOARG"];
+         ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test6"; ""; "0/1000"]]), []
     ];
     shortdesc = "create a btrfs snapshot";
     longdesc = "\
@@ -10237,7 +10238,9 @@ Create a snapshot of the btrfs subvolume C<source>.
 The C<dest> argument is the destination directory and the name
 of the snapshot, in the form C</path/to/dest/name>. By default
 the newly created snapshot is writable, if the value of optional
-parameter C<ro> is true, then a readonly snapshot is created." };
+parameter C<ro> is true, then a readonly snapshot is created. The
+optional parameter C<qgroupid> represents the qgroup which the
+newly created snapshot will be added to." };
 
   { defaults with
     name = "btrfs_subvolume_delete";
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]