Merge remote-tracking branch 'origin/pr/375'
* origin/pr/375: Fix line lengths Return better error messages from file pool Fix bugs found by Rusty Bird Fix export locking Re-add dirty check in case qubesd is restarted File volumes are started NAND exported file pool: snapshotting dirty volume not supported Always snapshot in the FILE pool
This commit is contained in:
commit
7ab1703a06
@ -176,11 +176,14 @@ class FilePool(qubes.storage.Pool):
|
|||||||
class FileVolume(qubes.storage.Volume):
|
class FileVolume(qubes.storage.Volume):
|
||||||
''' Parent class for the xen volumes implementation which expects a
|
''' Parent class for the xen volumes implementation which expects a
|
||||||
`target_dir` param on initialization. '''
|
`target_dir` param on initialization. '''
|
||||||
|
_marker_running = object()
|
||||||
|
_marker_exported = object()
|
||||||
|
|
||||||
def __init__(self, dir_path, **kwargs):
|
def __init__(self, dir_path, **kwargs):
|
||||||
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._export_lock = None
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
if self.snap_on_start:
|
if self.snap_on_start:
|
||||||
@ -265,10 +268,22 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
# FIXME: this should rather return snapshot(self.path, self.path_cow)
|
if self._export_lock is not None:
|
||||||
# if domain is running
|
assert self._export_lock is FileVolume._marker_running, \
|
||||||
|
'nested calls to export()'
|
||||||
|
raise qubes.storage.StoragePoolException(
|
||||||
|
'file pool cannot export running volumes')
|
||||||
|
if self.is_dirty():
|
||||||
|
raise qubes.storage.StoragePoolException(
|
||||||
|
'file pool cannot export dirty volumes')
|
||||||
|
self._export_lock = FileVolume._marker_exported
|
||||||
return self.path
|
return self.path
|
||||||
|
|
||||||
|
def export_end(self, path):
|
||||||
|
assert self._export_lock is not FileVolume._marker_running, \
|
||||||
|
'ending an export on a running volume?'
|
||||||
|
self._export_lock = None
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def import_volume(self, src_volume):
|
def import_volume(self, src_volume):
|
||||||
if src_volume.snap_on_start:
|
if src_volume.snap_on_start:
|
||||||
@ -311,6 +326,12 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
if self._export_lock is not None:
|
||||||
|
assert self._export_lock is FileVolume._marker_exported, \
|
||||||
|
'nested calls to start()'
|
||||||
|
raise qubes.storage.StoragePoolException(
|
||||||
|
'file pool cannot start a VM with an exported volume')
|
||||||
|
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:
|
||||||
@ -328,12 +349,15 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
assert self._export_lock is not FileVolume._marker_exported, \
|
||||||
|
'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._export_lock = None
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user