@@ -356,7 +356,10 @@ def run_guestfs_mount(image_path, mount_target):
356
356
g .close ()
357
357
358
358
359
- def diff_metal (diff_from , diff_to ):
359
+ # Generator that will mount up metal image filesystems and yield
360
+ # the paths to be used for analysis and then clean up once given back
361
+ # control.
362
+ def diff_metal_helper (diff_from , diff_to ):
360
363
metal_from = get_metal_path (diff_from )
361
364
metal_to = get_metal_path (diff_to )
362
365
@@ -389,8 +392,8 @@ def diff_metal(diff_from, diff_to):
389
392
if not p .is_alive ():
390
393
raise Exception (f"A guestfs process for { os .path .basename (d )} died unexpectedly." )
391
394
392
- # Now that the mounts are live, we can diff them
393
- git_diff ( mount_dir_from , mount_dir_to )
395
+ # Allow the caller to operate on these values
396
+ yield mount_dir_from , mount_dir_to
394
397
395
398
finally :
396
399
# Unmount the FUSE binds, this will make the guestfs mount calls return
@@ -408,6 +411,11 @@ def diff_metal(diff_from, diff_to):
408
411
shutdown_process (p_to )
409
412
410
413
414
+ def diff_metal (diff_from , diff_to ):
415
+ for mount_dir_from , mount_dir_to in diff_metal_helper (diff_from , diff_to ):
416
+ git_diff (mount_dir_from , mount_dir_to )
417
+
418
+
411
419
def diff_cmd_outputs (cmd , path_from , path_to , strategy = 'template' ):
412
420
workingdir = os .getcwd ()
413
421
with tempfile .NamedTemporaryFile (prefix = cmd [0 ] + '-' ) as from_output , \
0 commit comments