storage/callback: add a post_volume_start callback

This commit is contained in:
3hhh 2020-07-05 17:53:52 +02:00
parent bf8ece8a0c
commit 57e7a02912
No known key found for this signature in database
GPG Key ID: EB03A691DB2F0833
2 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@
"post_volume_remove": "Called after removal of a volume of the pool. Same as above otherwise.",
"pre_volume_resize": "Called before resizing a volume of the pool. Same as above otherwise.",
"pre_volume_start": "Called before starting a volume of the pool. Same as above otherwise.",
"post_volume_start": "Called after starting a volume of the pool. Same as above otherwise.",
"post_volume_stop": "Called after stopping a volume of the pool. Same as above otherwise.",
"pre_volume_import": "Called before importing a volume from elsewhere. Same as above otherwise.",
"pre_volume_import_data": "Called before importing a volume from elsewhere. Same as above otherwise.",

View File

@ -85,13 +85,13 @@ class CallbackPool(qubes.storage.Pool):
qvm-volume | grep test-vm
grep test-vm /var/lib/qubes/qubes.xml
ls /mnt/test02/appvms/
cat /tmp/callback.log (2x pre_volume_start should be added)
cat /tmp/callback.log (2x pre_volume_start & 2x post_volume_start should be added)
qvm-shutdown test-vm
cat /tmp/callback.log (2x post_volume_stop should be added)
#reboot
cat /tmp/callback.log (only (!) post_ctor should be there)
qvm-start test-vm
cat /tmp/callback.log (pre_sinit & 2x pre_volume_start should be added)
cat /tmp/callback.log (pre_sinit & 2x pre_volume_start & 2x post_volume_start should be added)
qvm-shutdown --wait test-vm && qvm-remove test-vm
qvm-pool -r test && sudo rm -rf /mnt/test02
less /tmp/callback.log (2x post_volume_stop, 2x post_volume_remove, post_destroy should be added)
@ -468,7 +468,9 @@ class CallbackVolume(qubes.storage.Volume):
def start(self):
yield from self._assert_initialized()
yield from self._callback('pre_volume_start')
return (yield from coro_maybe(self._cb_impl.start()))
ret = yield from coro_maybe(self._cb_impl.start())
yield from self._callback('post_volume_start')
return ret
@asyncio.coroutine
def stop(self):