Hu Tao
2014-Nov-28 07:58 UTC
[Libguestfs] [PATCH 1/3] uuid: add support to change uuid of swap partition
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
daemon/uuids.c | 19 +++++++++++++++++++
sysprep/sysprep_operation_fs_uuids.ml | 2 --
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/daemon/uuids.c b/daemon/uuids.c
index 672f3db..431d867 100644
--- a/daemon/uuids.c
+++ b/daemon/uuids.c
@@ -29,6 +29,7 @@
GUESTFSD_EXT_CMD(str_tune2fs, tune2fs);
GUESTFSD_EXT_CMD(str_xfs_admin, xfs_admin);
+GUESTFSD_EXT_CMD(str_swaplabel, swaplabel);
static int
e2uuid (const char *device, const char *uuid)
@@ -75,6 +76,21 @@ xfsuuid (const char *device, const char *uuid)
return 0;
}
+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)
{
@@ -91,6 +107,9 @@ do_set_uuid (const char *device, const char *uuid)
else if (STREQ (vfs_type, "xfs"))
r = xfsuuid (device, uuid);
+ else if (STREQ (vfs_type, "swap"))
+ r = swapuuid (device, uuid);
+
else {
reply_with_error ("don't know how to set the UUID for '%s'
filesystems",
vfs_type);
diff --git a/sysprep/sysprep_operation_fs_uuids.ml
b/sysprep/sysprep_operation_fs_uuids.ml
index ccd8ef6..b67c131 100644
--- a/sysprep/sysprep_operation_fs_uuids.ml
+++ b/sysprep/sysprep_operation_fs_uuids.ml
@@ -29,8 +29,6 @@ let rec fs_uuids_perform ~verbose ~quiet g root side_effects
let fses = g#list_filesystems () in
List.iter (function
| _, "unknown" -> ()
- | _, "swap" ->
- (* XXX Not implemented *) ()
| dev, typ ->
let new_uuid = Common_utils.uuidgen ~prog () in
try
--
1.9.3
Hu Tao
2014-Nov-28 07:58 UTC
[Libguestfs] [PATCH 2/3] uuid: cannot change btrfs filesystem's UUID
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
daemon/uuids.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/daemon/uuids.c b/daemon/uuids.c
index 431d867..06b33e9 100644
--- a/daemon/uuids.c
+++ b/daemon/uuids.c
@@ -110,6 +110,11 @@ 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 {
reply_with_error ("don't know how to set the UUID for '%s'
filesystems",
vfs_type);
--
1.9.3
Hu Tao
2014-Nov-28 07:58 UTC
[Libguestfs] [PATCH 3/3] uuid: make alias get-uuid for vfs_uuid
Because get-uuid looks more like a counterpart to set-uuid, and is
more likely come to mind if one knows set-uuid.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
generator/actions.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/generator/actions.ml b/generator/actions.ml
index a35fe50..385b620 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -8540,6 +8540,7 @@ To find a filesystem from the label, use
C<guestfs_findfs_label>." };
{ defaults with
name = "vfs_uuid";
style = RString "uuid", [Mountable "mountable"], [];
+ fish_alias = ["get-uuid"];
proc_nr = Some 254;
tests (let uuid = uuidgen () in [
--
1.9.3
Richard W.M. Jones
2014-Nov-28 14:20 UTC
Re: [Libguestfs] [PATCH 1/3] uuid: add support to change uuid of swap partition
On Fri, Nov 28, 2014 at 03:58:05PM +0800, Hu Tao wrote:> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>ACK series. I'll push this shortly. 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
Maybe Matching Threads
- [PATCH v4 4/7] uuid: use newly introduced swap_set_uuid
- [PATCH] uuid: add support to change uuid of btrfs partition
- Re: [PATCH] uuid: add support to change uuid of btrfs partition
- [PATCH 4/5] uuid: use existed do_mkswap_U
- [PATCH v3 0/4] uuid: add btrfs uuid change support and some rework