[Libguestfs] [PATCH 10/11] New API: btrfs_qgroup_assign

Richard W.M. Jones rjones at redhat.com
Fri Dec 5 12:37:06 UTC 2014


On Fri, Dec 05, 2014 at 04:20:41PM +0800, Hu Tao wrote:
> btrfs_qgroup_assign adds a qgroup to a parent qgroup.
> 
> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> ---
>  daemon/btrfs.c       | 33 +++++++++++++++++++++++++++++++++
>  generator/actions.ml | 10 ++++++++++
>  src/MAX_PROC_NR      |  2 +-
>  3 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/daemon/btrfs.c b/daemon/btrfs.c
> index 3d7e79c..0a04dd3 100644
> --- a/daemon/btrfs.c
> +++ b/daemon/btrfs.c
> @@ -1272,3 +1272,36 @@ error:
>  
>    return NULL;
>  }
> +
> +int do_btrfs_qgroup_assign (const char *src, const char *dst, 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, "qgroup");
> +  ADD_ARG (argv, i, "assign");
> +  ADD_ARG (argv, i, src);
> +  ADD_ARG (argv, i, dst);
> +  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 c7df0dd..deb2d58 100644
> --- a/generator/actions.ml
> +++ b/generator/actions.ml
> @@ -12110,6 +12110,16 @@ Destroy a quota group." };
>  Show all subvolume quota groups in a btrfs filesystem, inclding their
>  usages." };
>  
> +  { defaults with
> +    name = "btrfs_qgroup_assign";
> +    style = RErr, [String "src"; String "dst"; Pathname "path"], [];
> +    proc_nr = Some 434;
> +    optional = Some "btrfs"; camel_name = "BTRFSQgroupAssign";
> +    shortdesc = "add a qgroup to a parent qgroup";
> +    longdesc = "\
> +Add qgroup C<src> to parent qgroup C<dst>. This command can group
> +several qgroups into a parent qgroup to share common limit." };
> +
>  ]
>  
>  (* Non-API meta-commands available only in guestfish.
> diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
> index 21fbd2e..e828e5d 100644
> --- a/src/MAX_PROC_NR
> +++ b/src/MAX_PROC_NR
> @@ -1 +1 @@
> -433
> +434

Looks OK, needs a test.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list