[Libguestfs] [PATCH 07/16] New API: btrfs_balance_resume

Hu Tao hutao at cn.fujitsu.com
Fri Jan 16 02:23:42 UTC 2015


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

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 1053b98..cdf3982 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1502,3 +1502,35 @@ do_btrfs_balance_cancel (const char *path)
 
   return 0;
 }
+
+int
+do_btrfs_balance_resume (const char *path)
+{
+  const size_t MAX_ARGS = 64;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
+  CLEANUP_FREE char *path_buf = NULL;
+  CLEANUP_FREE char *err = NULL;
+  CLEANUP_FREE char *out = NULL;
+  int r;
+
+  path_buf = sysroot_path (path);
+  if (path_buf == NULL) {
+    reply_with_perror ("malloc");
+    return -1;
+  }
+
+  ADD_ARG (argv, i, str_btrfs);
+  ADD_ARG (argv, i, "balance");
+  ADD_ARG (argv, i, "resume");
+  ADD_ARG (argv, i, path_buf);
+  ADD_ARG (argv, i, NULL);
+
+  r = commandv (&out, &err, argv);
+  if (r == -1) {
+    reply_with_error ("%s: %s", path, err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 17dbd78..df083a1 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12308,6 +12308,15 @@ Pause a running balance on a btrfs filesystem." };
     longdesc = "\
 Cancel a running balance on a btrfs filesystem." };
 
+{ defaults with
+    name = "btrfs_balance_resume";
+    style = RErr, [Pathname "path"], [];
+    proc_nr = Some 440;
+    optional = Some "btrfs"; camel_name = "BTRFSBalanceResume";
+    test_excuse = "test disk isn't large enough that btrfs_balance completes before we can pause and resume it";
+    shortdesc = "resume a paused balance";
+    longdesc = "\
+Resume a paused balance on a btrfs filesystem." };
 ]
 
 (* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 99dea3b..534a21e 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-439
+440
-- 
2.1.0




More information about the Libguestfs mailing list