[Libguestfs] [PATCH 2/4] New API: btrfstune_S_disable

Chen, Hanxiao chenhanxiao at cn.fujitsu.com
Sun Mar 1 05:44:20 UTC 2015



> -----Original Message-----
> From: Richard W.M. Jones [mailto:rjones at redhat.com]
> Sent: Friday, February 27, 2015 9:40 PM
> To: Chen, Hanxiao/陈 晗霄
> Cc: libguestfs at redhat.com
> Subject: Re: [Libguestfs] [PATCH 2/4] New API: btrfstune_S_disable
> 
> On Sat, Feb 21, 2015 at 08:23:19PM +0800, Chen Hanxiao wrote:
> > Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
> > ---
> >  daemon/btrfs.c       | 26 ++++++++++++++++++++++++++
> >  generator/actions.ml | 18 ++++++++++++++++++
> >  src/MAX_PROC_NR      |  2 +-
> >  3 files changed, 45 insertions(+), 1 deletion(-)
> >
> > diff --git a/daemon/btrfs.c b/daemon/btrfs.c
> > index c94c11a..a129e2e 100644
> > --- a/daemon/btrfs.c
> > +++ b/daemon/btrfs.c
> > @@ -2115,3 +2115,29 @@ do_btrfstune_S_enable (const char *device)
> >
> >    return 0;
> >  }
> > +
> > +int
> > +do_btrfstune_S_disable (const char *device)
> > +{
> > +  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;
> > +
> > +  ADD_ARG (argv, i, str_btrfstune);
> > +  ADD_ARG (argv, i, "-S");
> > +  ADD_ARG (argv, i, "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 6dccb5c..3c906a4 100644
> > --- a/generator/actions.ml
> > +++ b/generator/actions.ml
> > @@ -12547,6 +12547,24 @@ Get path on a btrfs filesystem for the logical address." };
> >  Enable seeding of a btrfs device, this will force a fs readonly
> >  so that you can use it tto build other filesystems." };
> >
> > +  { defaults with
> > +    name = "btrfstune_S_disable";
> > +    style = RErr, [Device "device"], [];
> > +    proc_nr = Some 455;
> > +    optional = Some "btrfs"; camel_name = "BTRFSTuneSDisable";
> > +    tests = [
> > +      InitPartition, Always, TestRun (
> > +        [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; "";
> ""];
> > +         ["btrfstune_S_enable"; "/dev/sda1"];
> > +         ["btrfstune_S_disable"; "/dev/sda1"]]), []
> > +    ];
> > +
> > +    shortdesc = "disable seeding of a btrfs device";
> > +    longdesc = "\
> > +    This will disable seeding of a btrfs device.
> > +    Warning: This is dangerous, clearing the seeding flag
> > +    may cause the derived device not to be mountable!" };
> > +
> 
> Sorry for the delayed reply.
> 
> How do you feel about combining btrfstune_S_enable &
> btrfstune_S_disable into a single call:
> 
>   name = "btrfstune_seeding";
>   style = RErr, [Device "device", Bool "enable"], [];
> 
> where you can enable or disable by setting the boolean?
> 

Sure, will be changed in v2.

Regards,
- Chen

> The two patches look otherwise fine to me.
> 
> Rich.
> 
> --
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> Read my programming and virtualization blog: http://rwmj.wordpress.com
> Fedora Windows cross-compiler. Compile Windows programs, test, and
> build Windows installers. Over 100 libraries supported.
> http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list