[virt-tools-list] [virt-manager PATCH 06/12] installertreemedia: Cleanup process id & unattended cache dirs

Fabiano Fidêncio fidencio at redhat.com
Thu Jun 6 14:11:37 UTC 2019


Any unattended installation creates a (or similar to)
~/.cache/virt-manager/$pid/unattended directory where the unattended
installations related files are stored.

Let's clean those dirs up during the clean up process.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 virtinst/installertreemedia.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
index ea522904..adfc0aca 100644
--- a/virtinst/installertreemedia.py
+++ b/virtinst/installertreemedia.py
@@ -211,6 +211,15 @@ class InstallerTreeMedia(object):
         for f in self._tmpfiles:
             logging.debug("Removing %s", str(f))
             os.unlink(f)
+        unattended_cache_dir = util.get_unattended_cache_dir()
+        if os.path.exists(unattended_cache_dir):
+            logging.debug("Removing %s", unattended_cache_dir)
+            os.rmdir(unattended_cache_dir)
+
+            pid_cache_dir = os.path.join(util.get_cache_dir(),
+                                         str(os.getpid()))
+            logging.debug("Removing %s", pid_cache_dir)
+            os.rmdir(pid_cache_dir)
 
         for vol in self._tmpvols:
             logging.debug("Removing volume '%s'", vol.name())
-- 
2.21.0




More information about the virt-tools-list mailing list