[Libguestfs] [PATCH 2/2] NEW API: add new api btrfs-tune for seeding device

Richard W.M. Jones rjones at redhat.com
Mon May 14 12:18:17 UTC 2012


On Mon, May 14, 2012 at 06:38:25PM +0800, Wanlong Gao wrote:
> Add the NEW API btrfs-tune to support the seeding-device feature
> for btrfs.
> 
> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
> ---
>  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

Thanks.  This is fine and I will push it shortly.

However I made a few small changes:

* I renamed it 'btrfs-set-seeding', since the 'btrfstune' program
doesn't have any other options, and we may want to add a
'btrfs-get-seeding' function in future.

* I changed the order of the parameters: device, boolean

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the Libguestfs mailing list