Add the NEW API btrfs-tune to support the seeding-device feature for btrfs.
Signed-off-by: Wanlong Gao <[email protected]> --- daemon/btrfs.c | 19 +++++++++++++++++++ generator/generator_actions.ml | 10 ++++++++++ src/MAX_PROC_NR | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index b0218bc..c5dfd48 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -600,3 +600,22 @@ do_btrfs_device_delete (char *const *devices, const char *fs) return 0; } + +int +do_btrfs_tune (int svalue, const char *device) +{ + char *err; + int r; + + const char *s_value = svalue ? "1" : "0"; + + r = commandr (NULL, &err, "btrfstune", "-S", s_value, device, NULL); + if (r == -1) { + reply_with_error ("%s: %s", device, err); + free (err); + return -1; + } + + free (err); + return r; +} diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 6948dab..b898c7a 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -7222,6 +7222,16 @@ mounted at C<fs>. If C<devices> is an empty list, this does nothing."); Remove the C<devices> from the btrfs filesystem mounted at C<fs>. If C<devices> is an empty list, this does nothing."); + ("btrfs_tune", (RErr, [Bool "svalue"; Device "device"], []), 331, [], + [InitPartition, IfAvailable "btrfs", TestRun ( + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; + ["btrfs_tune"; "true"; "/dev/sda1"]; + ["btrfs_tune"; "false"; "/dev/sda1"]])], + "enable/disable seeding feature of device", + "\ +Enable or disable the seeding feature of device which with btrfs +filesystem on it."); + ] let all_functions = non_daemon_functions @ daemon_functions diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index db2cef5..ec6cab0 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -330 +331 -- 1.7.10 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
