@@ -356,7 +356,10 @@ def run_guestfs_mount(image_path, mount_target):
356356 g .close ()
357357
358358
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 ):
360363 metal_from = get_metal_path (diff_from )
361364 metal_to = get_metal_path (diff_to )
362365
@@ -389,8 +392,8 @@ def diff_metal(diff_from, diff_to):
389392 if not p .is_alive ():
390393 raise Exception (f"A guestfs process for { os .path .basename (d )} died unexpectedly." )
391394
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
394397
395398 finally :
396399 # Unmount the FUSE binds, this will make the guestfs mount calls return
@@ -408,6 +411,11 @@ def diff_metal(diff_from, diff_to):
408411 shutdown_process (p_to )
409412
410413
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+
411419def diff_cmd_outputs (cmd , path_from , path_to , strategy = 'template' ):
412420 workingdir = os .getcwd ()
413421 with tempfile .NamedTemporaryFile (prefix = cmd [0 ] + '-' ) as from_output , \
0 commit comments