guestfs_set_uuid wants device as argument.
Moreover, btrfstune -U is unable to set uuid for subvolumes,
only unmounted partitions are supported.

Here we skip btrfs subvolumes.
---
 sysprep/sysprep_operation_fs_uuids.ml | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sysprep/sysprep_operation_fs_uuids.ml 
b/sysprep/sysprep_operation_fs_uuids.ml
index ed4e81a..f125eb0 100644
--- a/sysprep/sysprep_operation_fs_uuids.ml
+++ b/sysprep/sysprep_operation_fs_uuids.ml
@@ -30,13 +30,15 @@ let rec fs_uuids_perform g root side_effects =
   List.iter (function
   | _, "unknown" -> ()
   | dev, typ ->
-    let new_uuid = Common_utils.uuidgen () in
-    try
-      g#set_uuid dev new_uuid
-    with
-      G.Error msg ->
-        warning (f_"cannot set random UUID on filesystem %s type %s: %s")
-          dev typ msg
+    if not (is_btrfs_subvolume g dev) then (
+      let new_uuid = Common_utils.uuidgen () in
+      try
+        g#set_uuid dev new_uuid
+      with
+        G.Error msg ->
+          warning (f_"cannot set random UUID on filesystem %s type %s: %s")
+            dev typ msg
+    )
   ) fses
 
 let op = {
-- 
1.8.3.1

_______________________________________________
Libguestfs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to