From 88238c80f3875dbac1acfae338e025e2f52259e7 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Fri, 1 Apr 2016 13:44:29 +0200 Subject: [PATCH] Add XenPool._reset_volume --- qubes/storage/xen.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qubes/storage/xen.py b/qubes/storage/xen.py index 144082a3..dc1bced6 100644 --- a/qubes/storage/xen.py +++ b/qubes/storage/xen.py @@ -188,6 +188,26 @@ class XenPool(Pool): f_cow.close() f_root.close() os.umask(old_umask) + return volume + + def start(self, volume): + if volume.volume_type == 'volatile': + self._reset_volume(volume) + return volume + + def _reset_volume(self, volume): + ''' Remove and recreate a volatile volume ''' + assert volume.volume_type == 'volatile', "Not a volatile volume" + + size = self.vm.volume_config[volume.name]['size'] + assert size + + if os.path.exists(volume.path): + os.remove(volume.path) + + with open(volume.path, "w") as f_volatile: + f_volatile.truncate(volume.size) + return volume def reset_volatile_storage(self): try: