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
|
self.dir_path = dir_path
|
||||||
assert self.dir_path, "dir_path not specified"
|
assert self.dir_path, "dir_path not specified"
|
||||||
self._revisions_to_keep = 0
|
self._revisions_to_keep = 0
|
||||||
self._locked = None
|
self._export_lock = None
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
if self.snap_on_start:
|
if self.snap_on_start:
|
||||||
@ -268,17 +268,17 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
if self._locked is not None:
|
if self._export_lock is not None:
|
||||||
assert self._locked is FileVolume._marker_running, \
|
assert self._export_lock is FileVolume._marker_running, \
|
||||||
'nested calls to export()'
|
'nested calls to export()'
|
||||||
self._not_implemented('exporting a dirty volume')
|
self._not_implemented('exporting a dirty volume')
|
||||||
self._locked = FileVolume._marker_exported
|
self._export_lock = FileVolume._marker_exported
|
||||||
return self.path
|
return self.path
|
||||||
|
|
||||||
def export_end(self, path):
|
def export_end(self, path):
|
||||||
assert self._locked is FileVolume._marker_exported, \
|
assert self._export_lock is not FileVolume._marker_running, \
|
||||||
'cannot end an export that never began'
|
'ending an export on a running volume?'
|
||||||
self._locked = None
|
self._export_lock = None
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def import_volume(self, src_volume):
|
def import_volume(self, src_volume):
|
||||||
@ -322,13 +322,13 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self._locked is not None:
|
if self._export_lock is not None:
|
||||||
assert self._locked is FileVolume._marker_exported, \
|
assert self._export_lock is FileVolume._marker_exported, \
|
||||||
'nested calls to start()'
|
'nested calls to start()'
|
||||||
self._not_implemented('starting a VM with an exported volume')
|
self._not_implemented('starting a VM with an exported volume')
|
||||||
if self.is_dirty():
|
if self.is_dirty():
|
||||||
self._not_implemented('exporting a dirty volume')
|
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:
|
if not self.save_on_stop and not self.snap_on_start:
|
||||||
self.reset()
|
self.reset()
|
||||||
else:
|
else:
|
||||||
@ -346,15 +346,15 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
assert self._locked is FileVolume._marker_running, \
|
assert self._export_lock is not FileVolume._marker_exported, \
|
||||||
'cannot stop a volume that has not been started'
|
'trying to stop exported file volume?'
|
||||||
if self.save_on_stop:
|
if self.save_on_stop:
|
||||||
self.commit()
|
self.commit()
|
||||||
elif self.snap_on_start:
|
elif self.snap_on_start:
|
||||||
_remove_if_exists(self.path_cow)
|
_remove_if_exists(self.path_cow)
|
||||||
else:
|
else:
|
||||||
_remove_if_exists(self.path)
|
_remove_if_exists(self.path)
|
||||||
self._locked = None
|
self._export_lock = None
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user