Fix export locking
If qubesd has restarted then _export_lock will be None
This commit is contained in:
parent
e53d040051
commit
ec51673f21
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user