[Libguestfs] [PATCH 3/5] btrfs: add optional parameter `qgroupid' to btrfs_subvolume_create

Hu Tao hutao at cn.fujitsu.com
Wed Nov 26 09:04:06 UTC 2014


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

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

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 2b6735f..754fdcd 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -288,7 +288,7 @@ do_btrfs_subvolume_delete (const char *subvolume)
 }
 
 int
-do_btrfs_subvolume_create (const char *dest)
+do_btrfs_subvolume_create (const char *dest, const char *qgroupid)
 {
   const size_t MAX_ARGS = 64;
   const char *argv[MAX_ARGS];
@@ -306,6 +306,14 @@ do_btrfs_subvolume_create (const char *dest)
   ADD_ARG (argv, i, str_btrfs);
   ADD_ARG (argv, i, "subvolume");
   ADD_ARG (argv, i, "create");
+
+  /* Optional arguments. */
+  if (optargs_bitmask & GUESTFS_BTRFS_SUBVOLUME_CREATE_QGROUPID_BITMASK) {
+    ADD_ARG (argv, i, "-i");
+    ADD_ARG (argv, i, qgroupid);
+  }
+
+
   ADD_ARG (argv, i, dest_buf);
   ADD_ARG (argv, i, NULL);
 
diff --git a/generator/actions.ml b/generator/actions.ml
index e2b3cf5..a35fe50 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10226,9 +10226,9 @@ See C<guestfs_get_e2generation>." };
         [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
          ["mount"; "/dev/sda1"; "/"];
          ["mkdir"; "/dir"];
-         ["btrfs_subvolume_create"; "/test1"];
-         ["btrfs_subvolume_create"; "/test2"];
-         ["btrfs_subvolume_create"; "/dir/test3"];
+         ["btrfs_subvolume_create"; "/test1"; "NOARG"];
+         ["btrfs_subvolume_create"; "/test2"; "NOARG"];
+         ["btrfs_subvolume_create"; "/dir/test3"; "NOARG"];
          ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test5"; "true"; "NOARG"];
          ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test6"; ""; "0/1000"]]), []
     ];
@@ -10251,7 +10251,7 @@ newly created snapshot will be added to." };
       InitPartition, Always, TestRun (
         [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
          ["mount"; "/dev/sda1"; "/"];
-         ["btrfs_subvolume_create"; "/test1"];
+         ["btrfs_subvolume_create"; "/test1"; "NOARG"];
          ["btrfs_subvolume_delete"; "/test1"]]), []
     ];
     shortdesc = "delete a btrfs subvolume or snapshot";
@@ -10260,13 +10260,16 @@ Delete the named btrfs subvolume or snapshot." };
 
   { defaults with
     name = "btrfs_subvolume_create";
-    style = RErr, [Pathname "dest"], [];
+    style = RErr, [Pathname "dest"], [OString "qgroupid"];
     proc_nr = Some 324;
+    once_had_no_optargs = true;
     optional = Some "btrfs"; camel_name = "BTRFSSubvolumeCreate";
     shortdesc = "create a btrfs subvolume";
     longdesc = "\
 Create a btrfs subvolume.  The C<dest> argument is the destination
-directory and the name of the subvolume, in the form C</path/to/dest/name>." };
+directory and the name of the subvolume, in the form C</path/to/dest/name>.
+The optional parameter C<qgroupid> represents the qgroup which the newly
+created subvolume will be added to." };
 
   { defaults with
     name = "btrfs_subvolume_list";
@@ -10300,7 +10303,7 @@ get a list of subvolumes." };
       InitPartition, Always, TestRun (
         [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
          ["mount"; "/dev/sda1"; "/"];
-         ["btrfs_subvolume_create"; "/test1"];
+         ["btrfs_subvolume_create"; "/test1"; "NOARG"];
          ["btrfs_filesystem_sync"; "/test1"];
          ["btrfs_filesystem_balance"; "/test1"]]), []
     ];
-- 
1.9.3




More information about the Libguestfs mailing list