Chen Hanxiao
2015-Jul-01 09:21 UTC
[Libguestfs] [PATCH v5 0/3] uuid: add btrfs uuid change support and set_uuid_random
- Btrfs-progs v4.1 introduced new feature of changing uuid of btrfs partition. This patch add support of this. - Introduce set_uuid_random - uuids.c did a lot of deplicated work for changing uuid of fs. Use existing functions. v5: use NOT_SUPPORTED macro improve testcases v4: introduce get_random_uuid improve testcases squash internal API patches v3.1: fix typos v3: set errno if feature is not available. Chen Hanxiao (3): uuid: add support to change uuid of btrfs partition uuid: use newly introduced swap_set_uuid New API: set_uuid_random daemon/btrfs.c | 77 ++++++++++++++++++++++++++++++++++++++++++ daemon/daemon.h | 8 +++++ daemon/ext2.c | 6 ++++ daemon/swap.c | 16 +++++++++ daemon/uuids.c | 56 ++++++++++++++++++------------ daemon/xfs.c | 7 ++++ generator/actions.ml | 16 +++++++++ src/MAX_PROC_NR | 2 +- tests/btrfs/test-btrfs-misc.pl | 35 +++++++++++++++++++ 9 files changed, 201 insertions(+), 22 deletions(-) -- 2.1.0
Chen Hanxiao
2015-Jul-01 09:21 UTC
[Libguestfs] [PATCH v5 1/3] uuid: add support to change uuid of btrfs partition
btrfs-progs v4.1 add support to change uuid of btrfs fs. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- v5: use NOT_SUPPORTED macro improve testcases v4: although btrfstune did not had '--help', pass it anyway improve testcases v3: set errno as ENOTSUP when btrfstune -u is not available v2: put btrfs operation back to daemon/btrfs.c move tests to tests/btrfs daemon/btrfs.c | 58 ++++++++++++++++++++++++++++++++++++++++++ daemon/daemon.h | 1 + daemon/uuids.c | 6 ++--- tests/btrfs/test-btrfs-misc.pl | 20 +++++++++++++++ 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index cedea31..28a48cf 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -797,6 +797,44 @@ do_btrfs_device_delete (char *const *devices, const char *fs) return 0; } + +/* btrfstune command add two new options + * -U UUID change fsid to UUID + * -u change fsid, use a random one + * since v4.1 + * We could check wheter 'btrfstune' support + * '-u' and '-U UUID' option by checking the output of + * 'btrfstune' command. + */ +static int +test_btrfstune_uuid_opt (void) +{ + static int result = -1; + if (result != -1) + return result; + + CLEANUP_FREE char *err = NULL; + + int r = commandr (NULL, &err, str_btrfstune, "--help", NULL); + + if (r == -1) { + reply_with_error ("btrfstune: %s", err); + return -1; + } + + /* FIXME currently btrfstune do not support '--help'. + * If got an invalid options, it will print its usage + * in stderr. + * We had to check it there. + */ + if (strstr (err, "-U") == NULL || strstr (err, "-u") == NULL) + result = 0; + else + result = 1; + + return result; +} + int do_btrfs_set_seeding (const char *device, int svalue) { @@ -814,6 +852,26 @@ do_btrfs_set_seeding (const char *device, int svalue) return 0; } +int +btrfs_set_uuid (const char *device, const char *uuid) +{ + CLEANUP_FREE char *err = NULL; + int r; + int has_uuid_opts = test_btrfstune_uuid_opt (); + + if (has_uuid_opts <= 0) + NOT_SUPPORTED(-1, "btrfs filesystems' UUID cannot be changed"); + + r = commandr (NULL, &err, str_btrfstune, "-f", "-U", uuid, 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/daemon/daemon.h b/daemon/daemon.h index fce7b57..f9e8d45 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -273,6 +273,7 @@ extern char *debug_bmap_device (const char *subcmd, size_t argc, char *const *co /*-- in btrfs.c --*/ extern char *btrfs_get_label (const char *device); +extern int btrfs_set_uuid (const char *device, const char *uuid); /*-- in ntfs.c --*/ extern char *ntfs_get_label (const char *device); diff --git a/daemon/uuids.c b/daemon/uuids.c index 7635e76..dce0d60 100644 --- a/daemon/uuids.c +++ b/daemon/uuids.c @@ -90,10 +90,8 @@ do_set_uuid (const char *device, const char *uuid) else if (STREQ (vfs_type, "swap")) r = swapuuid (device, uuid); - else if (STREQ (vfs_type, "btrfs")) { - reply_with_error ("btrfs filesystems' UUID cannot be changed"); - r = -1; - } + else if (STREQ (vfs_type, "btrfs")) + r = btrfs_set_uuid (device, uuid); else { reply_with_error ("don't know how to set the UUID for '%s' filesystems", diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl index 2fe7c59..b637b17 100755 --- a/tests/btrfs/test-btrfs-misc.pl +++ b/tests/btrfs/test-btrfs-misc.pl @@ -20,6 +20,7 @@ use strict; use warnings; +use Errno; use Sys::Guestfs; @@ -47,5 +48,24 @@ my $label = $g->vfs_label ("/dev/sda1"); die "unexpected label: expecting 'newlabel' but got '$label'" unless $label eq "newlabel"; +# Setting btrfs UUID +eval { + $g->set_uuid ("/dev/sda1", "12345678-1234-1234-1234-123456789012"); +}; + +if ($@) { + my $err = $g->last_errno (); + if ($err == Errno::ENOTSUP()) { + warn "$0: skipping test for btrfs UUID change feature is not available"; + } else { + die $@; + } +} else { + my $uuid = $g->vfs_uuid ("/dev/sda1"); + die "unexpected uuid expecting + '12345678-1234-1234-1234-123456789012' but got '$uuid'" + unless $uuid eq "12345678-1234-1234-1234-123456789012"; +} + $g->shutdown (); $g->close (); -- 2.1.0
Chen Hanxiao
2015-Jul-01 09:21 UTC
[Libguestfs] [PATCH v5 2/3] uuid: use newly introduced swap_set_uuid
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- v3: move swapuuid to swap.c rename it as swap_set_uuid daemon/daemon.h | 3 +++ daemon/swap.c | 16 ++++++++++++++++ daemon/uuids.c | 18 +----------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index f9e8d45..f8441d1 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -278,6 +278,9 @@ extern int btrfs_set_uuid (const char *device, const char *uuid); /*-- in ntfs.c --*/ extern char *ntfs_get_label (const char *device); +/*-- in swap.c --*/ +extern int swap_set_uuid (const char *device, const char *uuid); + /* ordinary daemon functions use these to indicate errors * NB: you don't need to prefix the string with the current command, * it is added automatically by the client-side RPC stubs. diff --git a/daemon/swap.c b/daemon/swap.c index 83f4d7c..26fe30d 100644 --- a/daemon/swap.c +++ b/daemon/swap.c @@ -33,6 +33,7 @@ GUESTFSD_EXT_CMD(str_mkswap, mkswap); GUESTFSD_EXT_CMD(str_swapon, swapon); GUESTFSD_EXT_CMD(str_swapoff, swapoff); +GUESTFSD_EXT_CMD(str_swaplabel, swaplabel); /* Confirmed this is true for Linux swap partitions from the Linux sources. */ #define SWAP_LABEL_MAX 16 @@ -239,3 +240,18 @@ do_swapoff_uuid (const char *uuid) { return swaponoff (str_swapoff, "-U", uuid); } + +int +swap_set_uuid (const char *device, const char *uuid) +{ + int r; + CLEANUP_FREE char *err = NULL; + + r = command (NULL, &err, str_swaplabel, "-U", uuid, device, NULL); + if (r == -1) { + reply_with_error ("%s", err); + return -1; + } + + return 0; +} diff --git a/daemon/uuids.c b/daemon/uuids.c index dce0d60..5238f3e 100644 --- a/daemon/uuids.c +++ b/daemon/uuids.c @@ -27,7 +27,6 @@ #include "actions.h" #include "optgroups.h" -GUESTFSD_EXT_CMD(str_swaplabel, swaplabel); static int e2uuid (const char *device, const char *uuid) @@ -56,21 +55,6 @@ xfsuuid (const char *device, const char *uuid) return xfs_set_uuid (device, uuid); } -static int -swapuuid (const char *device, const char *uuid) -{ - int r; - CLEANUP_FREE char *err = NULL; - - r = command (NULL, &err, str_swaplabel, "-U", uuid, device, NULL); - if (r == -1) { - reply_with_error ("%s", err); - return -1; - } - - return 0; -} - int do_set_uuid (const char *device, const char *uuid) { @@ -88,7 +72,7 @@ do_set_uuid (const char *device, const char *uuid) r = xfsuuid (device, uuid); else if (STREQ (vfs_type, "swap")) - r = swapuuid (device, uuid); + r = swap_set_uuid (device, uuid); else if (STREQ (vfs_type, "btrfs")) r = btrfs_set_uuid (device, uuid); -- 2.1.0
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> --- v5: 1. improve testcases 2. rename set_uuid_random to ext_set_uuid_random 3. drop swap_set_uuid_random, call swap_set_uuid + get_random_uuid daemon/btrfs.c | 19 +++++++++++++++++++ daemon/daemon.h | 4 ++++ daemon/ext2.c | 6 ++++++ daemon/uuids.c | 32 ++++++++++++++++++++++++++++++++ daemon/xfs.c | 7 +++++++ generator/actions.ml | 16 ++++++++++++++++ src/MAX_PROC_NR | 2 +- tests/btrfs/test-btrfs-misc.pl | 15 +++++++++++++++ 8 files changed, 100 insertions(+), 1 deletion(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 28a48cf..8fcfd81 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -872,6 +872,25 @@ btrfs_set_uuid (const char *device, const char *uuid) return 0; } +int +btrfs_set_uuid_random (const char *device) +{ + CLEANUP_FREE char *err = NULL; + int r; + int has_uuid_opts = test_btrfstune_uuid_opt(); + + if (has_uuid_opts <= 0) + NOT_SUPPORTED(-1, "btrfs filesystems' UUID cannot be changed"); + + r = commandr (NULL, &err, str_btrfstune, "-f", "-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/daemon/daemon.h b/daemon/daemon.h index f8441d1..377afbc 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -223,6 +223,7 @@ extern int sync_disks (void); /* Confirmed this is true up to ext4 from the Linux sources. */ #define EXT2_LABEL_MAX 16 extern int fstype_is_extfs (const char *fstype); +extern int ext_set_e2uuid_random (const char *device); /*-- in blkid.c --*/ extern char *get_blkid_tag (const char *device, const char *tag); @@ -265,6 +266,7 @@ extern int copy_xattrs (const char *src, const char *dest); /* Documented in xfs_admin(8). */ #define XFS_LABEL_MAX 12 extern int xfs_set_uuid (const char *device, const char *uuid); +extern int xfs_set_uuid_random (const char *device); /*-- debug-bmap.c --*/ extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv); @@ -274,12 +276,14 @@ extern char *debug_bmap_device (const char *subcmd, size_t argc, char *const *co /*-- in btrfs.c --*/ extern char *btrfs_get_label (const char *device); extern int btrfs_set_uuid (const char *device, const char *uuid); +extern int btrfs_set_uuid_random (const char *device); /*-- in ntfs.c --*/ extern char *ntfs_get_label (const char *device); /*-- in swap.c --*/ extern int swap_set_uuid (const char *device, const char *uuid); +extern int swap_set_uuid_random (const char *device); /* ordinary daemon functions use these to indicate errors * NB: you don't need to prefix the string with the current command, diff --git a/daemon/ext2.c b/daemon/ext2.c index 8ef6d5f..8c8bd94 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -159,6 +159,12 @@ do_set_e2uuid (const char *device, const char *uuid) return 0; } +int +ext_set_e2uuid_random (const char *device) +{ + return do_set_e2uuid(device, "random"); +} + char * do_get_e2uuid (const char *device) { diff --git a/daemon/uuids.c b/daemon/uuids.c index 5238f3e..002f595 100644 --- a/daemon/uuids.c +++ b/daemon/uuids.c @@ -85,3 +85,35 @@ do_set_uuid (const char *device, const char *uuid) return r; } + +int +do_set_uuid_random (const char *device) +{ + int r; + + /* How we set the UUID depends on the filesystem type. */ + CLEANUP_FREE char *vfs_type = get_blkid_tag (device, "TYPE"); + if (vfs_type == NULL) + return -1; + + CLEANUP_FREE char *uuid_random = get_random_uuid (); + if (uuid_random == NULL) + return -1; + + if (fstype_is_extfs (vfs_type)) + r = ext_set_e2uuid_random (device); + + else if (STREQ (vfs_type, "xfs")) + r = xfs_set_uuid_random (device); + + else if (STREQ (vfs_type, "swap")) + r = swap_set_uuid (device, uuid_random); + + else if (STREQ (vfs_type, "btrfs")) + r = btrfs_set_uuid_random (device); + + else + NOT_SUPPORTED(-1, "don't know how to set the random UUID for '%s' filesystems", + vfs_type); + return r; +} diff --git a/daemon/xfs.c b/daemon/xfs.c index fb7acb4..2c93311 100644 --- a/daemon/xfs.c +++ b/daemon/xfs.c @@ -463,6 +463,13 @@ xfs_set_uuid (const char *device, const char *uuid) } int +xfs_set_uuid_random (const char *device) +{ + optargs_bitmask = GUESTFS_XFS_ADMIN_UUID_BITMASK; + return do_xfs_admin (device, 0, 0, 0, 0, 0, NULL, "generate"); +} + +int do_xfs_admin (const char *device, int extunwritten, int imgfile, int v2log, int projid32bit, diff --git a/generator/actions.ml b/generator/actions.ml index b1865e0..b214c37 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12636,6 +12636,22 @@ removed from the filesystem. The C<targetdev> needs to be same size or larger than the C<srcdev>. Devices which are currently mounted are never allowed to be used as the C<targetdev>." }; + { defaults with + name = "set_uuid_random"; added = (1, 29, 48); + style = RErr, [Device "device"], []; + proc_nr = Some 456; + tests = [ + InitBasicFS, Always, TestRun ( + [["set_uuid_random"; "/dev/sda1"]]), []; + ]; + shortdesc = "set a random UUID for the filesystem"; + longdesc = "\ +Set the filesystem UUID on C<device> to a random UUID. + +Only some filesystem types support setting UUIDs. + +To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 4930863..8d38505 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -455 +456 diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl index b637b17..fa778ab 100755 --- a/tests/btrfs/test-btrfs-misc.pl +++ b/tests/btrfs/test-btrfs-misc.pl @@ -67,5 +67,20 @@ if ($@) { unless $uuid eq "12345678-1234-1234-1234-123456789012"; } +# Setting btrfs random UUID. +eval { + $g->set_uuid_random ("/dev/sda1") +}; + + +if ($@) { + my $err = $g->last_errno (); + if ($err == Errno::ENOTSUP()) { + warn "$0: skipping test for btrfs UUID change feature is not available"; + } else { + die $@; + } +} + $g->shutdown (); $g->close (); -- 2.1.0
Pino Toscano
2015-Jul-02 09:15 UTC
Re: [Libguestfs] [PATCH v5 3/3] New API: set_uuid_random
On Wednesday 01 July 2015 17:21:14 Chen Hanxiao wrote:> Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> > --- > v5: 1. improve testcases > 2. rename set_uuid_random to ext_set_uuid_random > 3. drop swap_set_uuid_random, > call swap_set_uuid + get_random_uuid > > daemon/btrfs.c | 19 +++++++++++++++++++ > daemon/daemon.h | 4 ++++ > daemon/ext2.c | 6 ++++++ > daemon/uuids.c | 32 ++++++++++++++++++++++++++++++++ > daemon/xfs.c | 7 +++++++ > generator/actions.ml | 16 ++++++++++++++++ > src/MAX_PROC_NR | 2 +- > tests/btrfs/test-btrfs-misc.pl | 15 +++++++++++++++ > 8 files changed, 100 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index 28a48cf..8fcfd81 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -872,6 +872,25 @@ btrfs_set_uuid (const char *device, const char *uuid) > return 0; > } > > +int > +btrfs_set_uuid_random (const char *device) > +{ > + CLEANUP_FREE char *err = NULL; > + int r; > + int has_uuid_opts = test_btrfstune_uuid_opt(); > + > + if (has_uuid_opts <= 0) > + NOT_SUPPORTED(-1, "btrfs filesystems' UUID cannot be changed"); > + > + r = commandr (NULL, &err, str_btrfstune, "-f", "-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/daemon/daemon.h b/daemon/daemon.h > index f8441d1..377afbc 100644 > --- a/daemon/daemon.h > +++ b/daemon/daemon.h > @@ -223,6 +223,7 @@ extern int sync_disks (void); > /* Confirmed this is true up to ext4 from the Linux sources. */ > #define EXT2_LABEL_MAX 16 > extern int fstype_is_extfs (const char *fstype); > +extern int ext_set_e2uuid_random (const char *device);ext_set_uuid_random.> /*-- in blkid.c --*/ > extern char *get_blkid_tag (const char *device, const char *tag); > @@ -265,6 +266,7 @@ extern int copy_xattrs (const char *src, const char *dest); > /* Documented in xfs_admin(8). */ > #define XFS_LABEL_MAX 12 > extern int xfs_set_uuid (const char *device, const char *uuid); > +extern int xfs_set_uuid_random (const char *device); > > /*-- debug-bmap.c --*/ > extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv); > @@ -274,12 +276,14 @@ extern char *debug_bmap_device (const char *subcmd, size_t argc, char *const *co > /*-- in btrfs.c --*/ > extern char *btrfs_get_label (const char *device); > extern int btrfs_set_uuid (const char *device, const char *uuid); > +extern int btrfs_set_uuid_random (const char *device); > > /*-- in ntfs.c --*/ > extern char *ntfs_get_label (const char *device); > > /*-- in swap.c --*/ > extern int swap_set_uuid (const char *device, const char *uuid); > +extern int swap_set_uuid_random (const char *device);This seems missing?> /* ordinary daemon functions use these to indicate errors > * NB: you don't need to prefix the string with the current command, > diff --git a/daemon/ext2.c b/daemon/ext2.c > index 8ef6d5f..8c8bd94 100644 > --- a/daemon/ext2.c > +++ b/daemon/ext2.c > @@ -159,6 +159,12 @@ do_set_e2uuid (const char *device, const char *uuid) > return 0; > } > > +int > +ext_set_e2uuid_random (const char *device) > +{ > + return do_set_e2uuid(device, "random");Minor style note: space between function and opening round bracket.> +} > + > char * > do_get_e2uuid (const char *device) > { > diff --git a/daemon/uuids.c b/daemon/uuids.c > index 5238f3e..002f595 100644 > --- a/daemon/uuids.c > +++ b/daemon/uuids.c > @@ -85,3 +85,35 @@ do_set_uuid (const char *device, const char *uuid) > > return r; > } > + > +int > +do_set_uuid_random (const char *device) > +{ > + int r; > + > + /* How we set the UUID depends on the filesystem type. */ > + CLEANUP_FREE char *vfs_type = get_blkid_tag (device, "TYPE"); > + if (vfs_type == NULL) > + return -1; > + > + CLEANUP_FREE char *uuid_random = get_random_uuid (); > + if (uuid_random == NULL) > + return -1; > + > + if (fstype_is_extfs (vfs_type)) > + r = ext_set_e2uuid_random (device); > + > + else if (STREQ (vfs_type, "xfs")) > + r = xfs_set_uuid_random (device); > + > + else if (STREQ (vfs_type, "swap")) > + r = swap_set_uuid (device, uuid_random); > + > + else if (STREQ (vfs_type, "btrfs")) > + r = btrfs_set_uuid_random (device); > + > + else > + NOT_SUPPORTED(-1, "don't know how to set the random UUID for '%s' filesystems", > + vfs_type); > + return r; > +} > diff --git a/daemon/xfs.c b/daemon/xfs.c > index fb7acb4..2c93311 100644 > --- a/daemon/xfs.c > +++ b/daemon/xfs.c > @@ -463,6 +463,13 @@ xfs_set_uuid (const char *device, const char *uuid) > } > > int > +xfs_set_uuid_random (const char *device) > +{ > + optargs_bitmask = GUESTFS_XFS_ADMIN_UUID_BITMASK; > + return do_xfs_admin (device, 0, 0, 0, 0, 0, NULL, "generate"); > +} > + > +int > do_xfs_admin (const char *device, > int extunwritten, int imgfile, int v2log, > int projid32bit, > diff --git a/generator/actions.ml b/generator/actions.ml > index b1865e0..b214c37 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12636,6 +12636,22 @@ removed from the filesystem. > The C<targetdev> needs to be same size or larger than the C<srcdev>. Devices > which are currently mounted are never allowed to be used as the C<targetdev>." }; > > + { defaults with > + name = "set_uuid_random"; added = (1, 29, 48); > + style = RErr, [Device "device"], []; > + proc_nr = Some 456; > + tests = [ > + InitBasicFS, Always, TestRun ( > + [["set_uuid_random"; "/dev/sda1"]]), []; > + ]; > + shortdesc = "set a random UUID for the filesystem"; > + longdesc = "\ > +Set the filesystem UUID on C<device> to a random UUID. > + > +Only some filesystem types support setting UUIDs. > + > +To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." };Forgot to say, that it should be mentioned that if this fails and the last_errno is ENOTSUP, then there is no support for changing the UUID for the type of the specified filesystem.> + > ] > > (* Non-API meta-commands available only in guestfish. > diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR > index 4930863..8d38505 100644 > --- a/src/MAX_PROC_NR > +++ b/src/MAX_PROC_NR > @@ -1 +1 @@ > -455 > +456 > diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl > index b637b17..fa778ab 100755 > --- a/tests/btrfs/test-btrfs-misc.pl > +++ b/tests/btrfs/test-btrfs-misc.pl > @@ -67,5 +67,20 @@ if ($@) { > unless $uuid eq "12345678-1234-1234-1234-123456789012"; > } > > +# Setting btrfs random UUID. > +eval { > + $g->set_uuid_random ("/dev/sda1") > +}; > + > +Extra empty lines.> +if ($@) { > + my $err = $g->last_errno (); > + if ($err == Errno::ENOTSUP()) { > + warn "$0: skipping test for btrfs UUID change feature is not available"; > + } else { > + die $@; > + } > +} > + > $g->shutdown (); > $g->close ();Thanks, -- Pino Toscano
Pino Toscano
2015-Jul-02 09:45 UTC
Re: [Libguestfs] [PATCH v5 0/3] uuid: add btrfs uuid change support and set_uuid_random
On Wednesday 01 July 2015 17:21:11 Chen Hanxiao wrote:> uuid: add support to change uuid of btrfs partition > uuid: use newly introduced swap_set_uuidThese patches LGTM, so I pushed them. Thanks, -- Pino Toscano
Reasonably Related Threads
- [PATCH v6] New API: set_uuid_random
- [PATCH v4 0/7] uuid: add btrfs uuid change support and set_uuid_random
- [PATCH v3.1 0/9] uuid: add btrfs uuid change support and set_uuid_random
- [PATCH v3 0/4] uuid: add btrfs uuid change support and some rework
- [PATCH v5 3/3] New API: set_uuid_random