From 57e7a0291245cd090aa6e4574daa872bcc9e4186 Mon Sep 17 00:00:00 2001 From: 3hhh Date: Sun, 5 Jul 2020 17:53:52 +0200 Subject: [PATCH] storage/callback: add a post_volume_start callback --- qubes/storage/callback.json.example | 1 + qubes/storage/callback.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qubes/storage/callback.json.example b/qubes/storage/callback.json.example index 90ae5ca6..2dd97460 100644 --- a/qubes/storage/callback.json.example +++ b/qubes/storage/callback.json.example @@ -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.", diff --git a/qubes/storage/callback.py b/qubes/storage/callback.py index 4c2fb494..0593ec75 100644 --- a/qubes/storage/callback.py +++ b/qubes/storage/callback.py @@ -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):