[Libguestfs] [PATCH 5/5] New API: btrfstune_set_uuid_random

Pino Toscano ptoscano at redhat.com
Wed Jun 24 10:57:37 UTC 2015


In data mercoledì 24 giugno 2015 15:54:07, Chen Hanxiao ha scritto:
> Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
> ---
>  daemon/btrfs.c       | 21 +++++++++++++++++++++
>  generator/actions.ml | 18 ++++++++++++++++++
>  src/MAX_PROC_NR      |  2 +-
>  3 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/daemon/btrfs.c b/daemon/btrfs.c
> index b82c1b9..e4d8b64 100644
> --- a/daemon/btrfs.c
> +++ b/daemon/btrfs.c
> @@ -867,6 +867,27 @@ btrfstune_set_uuid (const char *device, const char *uuid)
>    return 0;
>  }
>  
> +int
> +do_btrfstune_set_uuid_random (const char *device)
> +{
> +  CLEANUP_FREE char *err = NULL;
> +  int r;
> +  int has_uuid_opts = test_btrftune_uuid_opt();
> +
> +  if (has_uuid_opts == 0) {
> +    reply_with_error ("btrfstune do not support '-u'");
> +    return -1;
> +  }
> +
> +  r = commandr (NULL, &err, str_btrfstune, "-u", device, NULL);
> +  if (r == -1) {
> +    reply_with_error("%s: %s", device, err);
> +    return -1;
> +  }
> +
> +  return 0;
> +}
> +
>  /* Takes optional arguments, consult optargs_bitmask. */
>  int
>  do_btrfs_fsck (const char *device, int64_t superblock, int repair)
> diff --git a/generator/actions.ml b/generator/actions.ml
> index d5e5ccf..329b388 100644
> --- a/generator/actions.ml
> +++ b/generator/actions.ml
> @@ -12593,6 +12593,24 @@ numbered C<partnum> on device C<device>.
>  
>  It returns C<primary>, C<logical>, or C<extended>." };
>  
> +  { defaults with
> +    name = "btrfstune_set_uuid_random"; added = (1, 29, 47);
> +    style = RErr, [Device "device"], [];
> +    proc_nr = Some 455;
> +    optional = Some "btrfs"; camel_name = "BTRFSTuneSetUuidRandom";
> +    tests = [
> +      InitPartition, Always, TestRun (
> +        [["part_init"; "/dev/sda"; "mbr"];
> +         ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
> +         ["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
> +         ["btrfstune_set_uuid_random"; "/dev/sda1"]]), []
> +    ];
> +
> +    shortdesc = "change fsid to a random generated UUID";

"set a random UUID for the filesystem"

> +    longdesc = "\
> +    Change fsid to a randomly generated UUID or continue previous fsid change
> +    operation in case it was interrupted." };
> +
>  ]
>  
>  (* Non-API meta-commands available only in guestfish.
> diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
> index 515f19a..4930863 100644
> --- a/src/MAX_PROC_NR
> +++ b/src/MAX_PROC_NR
> @@ -1 +1 @@
> -454
> +455

See current comment in daemon/uuids.c:e2uuid about particular UUID
operations. In case we want to allow these operations, they should be
doable whichever filesystem it is, just like set_uuid: i.e. a new
set_uuid_random, implemented for ext, xfs, and btrfs.

-- 
Pino Toscano




More information about the Libguestfs mailing list