@@ -364,7 +364,10 @@ def run_guestfs_mount(image_path, mount_target):
364364 g .close ()
365365
366366
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 ):
368371 metal_from = get_metal_path (diff_from )
369372 metal_to = get_metal_path (diff_to )
370373
@@ -397,8 +400,8 @@ def diff_metal(diff_from, diff_to):
397400 if not p .is_alive ():
398401 raise Exception (f"A guestfs process for { os .path .basename (d )} died unexpectedly." )
399402
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
402405
403406 finally :
404407 # Unmount the FUSE binds, this will make the guestfs mount calls return
@@ -416,6 +419,11 @@ def diff_metal(diff_from, diff_to):
416419 shutdown_process (p_to )
417420
418421
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+
419427def diff_cmd_outputs (cmd , path_from , path_to , strategy : DiffCmdOutputStrategy = DiffCmdOutputStrategy .TEMPLATE ):
420428 workingdir = None
421429 with tempfile .NamedTemporaryFile (prefix = cmd [0 ] + '-' ) as from_output , \
0 commit comments