Skip to content

Commit

Permalink
storage/callback: add a post_volume_start callback
Browse files Browse the repository at this point in the history
  • Loading branch information
3hhh committed Jul 16, 2020
1 parent bf8ece8 commit 57e7a02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions qubes/storage/callback.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 5 additions & 3 deletions qubes/storage/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -468,7 +468,9 @@ def resize(self, size):
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):
Expand Down

0 comments on commit 57e7a02

Please sign in to comment.