From ec51673f21230a09b4847afefc350c200fad5314 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Wed, 25 Nov 2020 15:08:13 -0500 Subject: [PATCH] Fix export locking If qubesd has restarted then _export_lock will be None --- qubes/storage/file.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/qubes/storage/file.py b/qubes/storage/file.py index 102bbafd..7a89d8e1 100644 --- a/qubes/storage/file.py +++ b/qubes/storage/file.py @@ -183,7 +183,7 @@ class FileVolume(qubes.storage.Volume): self.dir_path = dir_path assert self.dir_path, "dir_path not specified" self._revisions_to_keep = 0 - self._locked = None + self._export_lock = None super().__init__(**kwargs) if self.snap_on_start: @@ -268,17 +268,17 @@ class FileVolume(qubes.storage.Volume): return self def export(self): - if self._locked is not None: - assert self._locked is FileVolume._marker_running, \ + if self._export_lock is not None: + assert self._export_lock is FileVolume._marker_running, \ 'nested calls to export()' self._not_implemented('exporting a dirty volume') - self._locked = FileVolume._marker_exported + self._export_lock = FileVolume._marker_exported return self.path def export_end(self, path): - assert self._locked is FileVolume._marker_exported, \ - 'cannot end an export that never began' - self._locked = None + assert self._export_lock is not FileVolume._marker_running, \ + 'ending an export on a running volume?' + self._export_lock = None @asyncio.coroutine def import_volume(self, src_volume): @@ -322,13 +322,13 @@ class FileVolume(qubes.storage.Volume): return self def start(self): - if self._locked is not None: - assert self._locked is FileVolume._marker_exported, \ + if self._export_lock is not None: + assert self._export_lock is FileVolume._marker_exported, \ 'nested calls to start()' self._not_implemented('starting a VM with an exported volume') if self.is_dirty(): self._not_implemented('exporting a dirty volume') - self._locked = FileVolume._marker_running + self._export_lock = FileVolume._marker_running if not self.save_on_stop and not self.snap_on_start: self.reset() else: @@ -346,15 +346,15 @@ class FileVolume(qubes.storage.Volume): return self def stop(self): - assert self._locked is FileVolume._marker_running, \ - 'cannot stop a volume that has not been started' + assert self._export_lock is not FileVolume._marker_exported, \ + 'trying to stop exported file volume?' if self.save_on_stop: self.commit() elif self.snap_on_start: _remove_if_exists(self.path_cow) else: _remove_if_exists(self.path) - self._locked = None + self._export_lock = None return self @property