@@ -364,7 +364,10 @@ def run_guestfs_mount(image_path, mount_target):
364
364
g .close ()
365
365
366
366
367
- def diff_metal (diff_from , diff_to ):
367
+ # Generator that will mount up metal image filesystems and yield
368
+ # the paths to be used for analysis and then clean up once given back
369
+ # control.
370
+ def diff_metal_helper (diff_from , diff_to ):
368
371
metal_from = get_metal_path (diff_from )
369
372
metal_to = get_metal_path (diff_to )
370
373
@@ -397,8 +400,8 @@ def diff_metal(diff_from, diff_to):
397
400
if not p .is_alive ():
398
401
raise Exception (f"A guestfs process for { os .path .basename (d )} died unexpectedly." )
399
402
400
- # Now that the mounts are live, we can diff them
401
- git_diff ( mount_dir_from , mount_dir_to )
403
+ # Allow the caller to operate on these values
404
+ yield mount_dir_from , mount_dir_to
402
405
403
406
finally :
404
407
# Unmount the FUSE binds, this will make the guestfs mount calls return
@@ -416,6 +419,11 @@ def diff_metal(diff_from, diff_to):
416
419
shutdown_process (p_to )
417
420
418
421
422
+ def diff_metal (diff_from , diff_to ):
423
+ for mount_dir_from , mount_dir_to in diff_metal_helper (diff_from , diff_to ):
424
+ git_diff (mount_dir_from , mount_dir_to )
425
+
426
+
419
427
def diff_cmd_outputs (cmd , path_from , path_to , strategy : DiffCmdOutputStrategy = DiffCmdOutputStrategy .TEMPLATE ):
420
428
workingdir = None
421
429
with tempfile .NamedTemporaryFile (prefix = cmd [0 ] + '-' ) as from_output , \
0 commit comments