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

[Libguestfs] [PATCH v2 1/3] New API: btrfstune_seeding



Use btrfstune_seeding to enable or disable seeding.

Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
---
 daemon/btrfs.c       | 28 ++++++++++++++++++++++++++++
 generator/actions.ml | 17 +++++++++++++++++
 src/MAX_PROC_NR      |  2 +-
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 6b93973..d2d4492 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1929,3 +1929,31 @@ error:
   free (ret);
   return NULL;
 }
+
+int
+do_btrfstune_seeding (const char *device, int svalue)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *err = NULL;
+  CLEANUP_FREE char *out = NULL;
+  int r;
+  const char *s_value = svalue ? "1" : "0";
+
+  ADD_ARG (argv, i, str_btrfstune);
+  ADD_ARG (argv, i, "-S");
+  ADD_ARG (argv, i, s_value);
+  if (svalue == 0)
+    ADD_ARG (argv, i, "-f");
+  ADD_ARG (argv, i, device);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", device, err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index c995787..cb67fc5 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12475,6 +12475,23 @@ Show the status of a running or paused balance on a btrfs filesystem." };
     longdesc = "\
 Show status of running or finished scrub on a btrfs filesystem." };
 
+  { defaults with
+    name = "btrfstune_seeding";
+    style = RErr, [Device "device"; Bool "seeding"], [];
+    proc_nr = Some 450;
+    optional = Some "btrfs"; camel_name = "BTRFSTuneSeeding";
+    tests = [
+      InitPartition, Always, TestRun (
+        [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+         ["btrfstune_seeding"; "/dev/sda1"; "true"];
+         ["btrfstune_seeding"; "/dev/sda1"; "false"]]), []
+    ];
+
+    shortdesc = "enable or disable seeding of a btrfs device";
+    longdesc = "\
+Enable seeding of a btrfs device, this will force a fs readonly
+so that you can use it tto build other filesystems." };
+
 ]
 
 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 2b20fd0..29ba0df 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-449
+450
-- 
2.1.0


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