From bb2e1f2870e93f72046a29d80d5f984f6e622652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 21 May 2016 04:12:27 +0200 Subject: [PATCH] qubes/vm: handle VM toplevel directory in QubesVM object not Storage This directory is not only for disk images (in fact disk images may be elsewhere depending on choosen volume pool), so it would be cleaner to handle (create/remove) it directly in QubesVM class. --- qubes/storage/__init__.py | 3 +-- qubes/vm/qubesvm.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 3c7c2883..0aaf0790 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -149,8 +149,6 @@ class Storage(object): old_umask = os.umask(002) - self.log.info('Creating directory: {0}'.format(self.vm.dir_path)) - os.makedirs(self.vm.dir_path) for name, volume in self.vm.volumes.items(): source_volume = None if source_template and hasattr(source_template, 'volumes'): @@ -195,6 +193,7 @@ class Storage(object): Errors on removal are catched and logged. ''' for name, volume in self.vm.volumes.items(): + self.log.info('Removing volume %s: %s' % (name, volume.vid)) try: self.get_pool(volume).remove(volume) except (IOError, OSError) as e: diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 2a72d11e..b3927308 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -1092,6 +1092,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): # pylint: disable=no-member source_template = self.template + self.log.info('Creating directory: {0}'.format(self.dir_path)) + os.makedirs(self.dir_path, mode=0o775) + self.storage.create_on_disk(source_template) self.log.info('Creating icon symlink: {} -> {}'.format(