Skip to content

Commit

Permalink
Fix export locking
Browse files Browse the repository at this point in the history
If qubesd has restarted then _export_lock will be None
  • Loading branch information
DemiMarie committed Nov 25, 2020
1 parent e53d040 commit ec51673
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions qubes/storage/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(self, dir_path, **kwargs):
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:
Expand Down Expand Up @@ -268,17 +268,17 @@ def commit(self):
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):
Expand Down Expand Up @@ -322,13 +322,13 @@ def reset(self):
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:
Expand All @@ -346,15 +346,15 @@ def start(self):
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
Expand Down

0 comments on commit ec51673

Please sign in to comment.