From bae111d5a350063a5501c49a7b347c4b3b8c167e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 5 Apr 2016 09:59:29 -0700 Subject: [PATCH] livemedia-creator: Simplify cleanup for no-virt If an anaconda no-virt run crashes it can leave things mounted under /mnt/sysimage. Previously anaconda-cleanup was used to handle this, but it will also try to cleanup host mountpoints which isn't desired. --- src/sbin/livemedia-creator | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator index a0b49a6d..a52d4562 100755 --- a/src/sbin/livemedia-creator +++ b/src/sbin/livemedia-creator @@ -672,6 +672,23 @@ def novirt_log_check(log_check, proc): return False +def anaconda_cleanup(dirinstall_path): + """ + Cleanup any leftover mounts from anaconda + + :param str dirinstall_path: Path where anaconda mounts things + + If anaconda crashes it may leave things mounted under this path. It will + typically be set to /mnt/sysimage/ + """ + dirinstall_path = os.path.abspath(dirinstall_path) + # unmount filesystems + for mounted in reversed(open("/proc/mounts").readlines()): + (_device, mountpoint, _rest) = mounted.split(" ", 2) + if mountpoint.startswith(dirinstall_path): + umount(mountpoint) + + def novirt_install(opts, disk_img, disk_size): """ Use Anaconda to install to a disk image @@ -754,8 +771,8 @@ def novirt_install(opts, disk_img, disk_size): finally: log_monitor.shutdown() - # If anaconda failed there may be things needing cleanup - execWithRedirect("anaconda-cleanup", []) + # Make sure any leftover anaconda mounts have been cleaned up + anaconda_cleanup(dirinstall_path) # Move the anaconda logs over to a log directory log_dir = os.path.abspath(os.path.dirname(opts.logfile))