storage/callback: more succinct callback names
[pre|post]_[operation] should be more clear than on_[operation]
This commit is contained in:
		
							parent
							
								
									9de54ab242
								
							
						
					
					
						commit
						bf8ece8a0c
					
				| @ -6,20 +6,20 @@ | ||||
|             "arg name 1": "arg value 1", | ||||
|             "arg name 2": "arg value 2" | ||||
|         }, | ||||
|         "cmd": "Default command to call when the on_[op] operations are not specified (default: None). The command is called as such: `[cmd] [name] [bdriver] [operation] [ctor params]`. [name]: name of the pool, [operation]: any of the `on_` operations from below including its arguments, [bdriver]: backend driver of the pool, [ctor params]: Parameters passed to the `bdriver` constructor in JSON format. Each parameter is on a single line for easy parsing.", | ||||
|         "cmd": "Default command to call when the [pre|post]_[op] operations are not specified (default: None). The command is called as such: `[cmd] [name] [bdriver] [operation] [ctor params]`. [name]: name of the pool, [operation]: any of the `[pre|post]_` operations from below including its arguments, [bdriver]: backend driver of the pool, [ctor params]: Parameters passed to the `bdriver` constructor in JSON format. Each parameter is on a single line for easy parsing.", | ||||
|         "signal_back": "Boolean (true|false) to allow the executed commands to send signals back to the callback driver (default: false). Signals must be on a dedicated line on stdout. Currently only `SIGNAL_setup` is supported. When found, it causes the callback driver to re-setup the backend pool.", | ||||
|         "on_sinit": "Command to call before one-time storage initialization/first usage (default: None). Called exactly once for every `qubesd` start. Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.", | ||||
|         "on_ctor": "Command to call after object construction (default: None). Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.", | ||||
|         "on_setup": "Called before creation of a new pool. Same as above otherwise.", | ||||
|         "on_destroy": "Called after removal of an existing pool. Same as above otherwise.", | ||||
|         "on_volume_create": "Called before creation of a volume for the pool. Same as above otherwise.", | ||||
|         "on_volume_remove": "Called after removal of a volume of the pool. Same as above otherwise.", | ||||
|         "on_volume_resize": "Called before resizing a volume of the pool. Same as above otherwise.", | ||||
|         "on_volume_start": "Called before starting a volume of the pool. Same as above otherwise.", | ||||
|         "on_volume_stop": "Called after stopping a volume of the pool. Same as above otherwise.", | ||||
|         "on_volume_import": "Called before importing a volume from elsewhere. Same as above otherwise.", | ||||
|         "on_volume_import_data": "Called before importing a volume from elsewhere. Same as above otherwise.", | ||||
|         "on_volume_import_data_end": "Called after finishing an `import_data` action. Same as above otherwise.", | ||||
|         "pre_sinit": "Command to call before one-time storage initialization/first usage (default: None). Called exactly once for every `qubesd` start. Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.", | ||||
|         "post_ctor": "Command to call after object construction (default: None). Can be used to override `cmd`. Pass `-` to ignore this callback entirely even if `cmd` is specified.", | ||||
|         "pre_setup": "Called before creation of a new pool. Same as above otherwise.", | ||||
|         "post_destroy": "Called after removal of an existing pool. Same as above otherwise.", | ||||
|         "pre_volume_create": "Called before creation of a volume for the pool. Same as above otherwise.", | ||||
|         "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_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.", | ||||
|         "post_volume_import_data_end": "Called after finishing an `import_data` action. Same as above otherwise.", | ||||
|         "description": "Optional description for your personal reference." | ||||
|     }, | ||||
| "testing-fail-missing-all": | ||||
| @ -56,10 +56,10 @@ | ||||
|             "dir_path": "/mnt/test03" | ||||
|         }, | ||||
|         "cmd": "exit 1", | ||||
|         "on_ctor": "testCbLogArgs on_ctor", | ||||
|         "on_sinit": "testCbLogArgs on_sinit", | ||||
|         "on_setup": "testCbLogArgs on_setup", | ||||
|         "on_destroy": "-", | ||||
|         "post_ctor": "testCbLogArgs post_ctor", | ||||
|         "pre_sinit": "testCbLogArgs pre_sinit", | ||||
|         "pre_setup": "testCbLogArgs pre_setup", | ||||
|         "post_destroy": "-", | ||||
|         "description": "For testing purposes only." | ||||
|     }, | ||||
| "testing-succ-file-luks": | ||||
| @ -68,14 +68,14 @@ | ||||
|         "bdriver_args": { | ||||
|             "dir_path": "/mnt/test_luks" | ||||
|         }, | ||||
|         "on_ctor": "logger 'testing-succ-file-luks: ctor'", | ||||
|         "on_setup": "set -e -o pipefail ; [ ! -e /mnt/test.key ] ; [ ! -e /mnt/test.luks ] ; dd if=/dev/random bs=100 of=/mnt/test.key iflag=fullblock count=1 ; dd if=/dev/urandom bs=1M of=/mnt/test.luks iflag=fullblock count=2048 ; cryptsetup luksFormat -q --key-file /mnt/test.key /mnt/test.luks ; cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mkfs -t ext4 /dev/mapper/test-luks ; mkdir -p /mnt/test_luks ; mount /dev/mapper/test-luks /mnt/test_luks", | ||||
|         "on_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" != \"/mnt/test_luks\" ]] ; then cryptsetup status test-luks > /dev/null || cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mount /dev/mapper/test-luks /mnt/test_luks ; else exit 0 ; fi", | ||||
|         "on_destroy": "umount /mnt/test_luks && cryptsetup close test-luks ; set -e -o pipefail ; dd if=/dev/urandom bs=100 of=/mnt/test.key iflag=fullblock count=1 ; rm -f /mnt/test.key ; rm -f /mnt/test.luks ; rmdir /mnt/test_luks", | ||||
|         "on_volume_create":          "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "on_volume_import":          "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "on_volume_import_data":     "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "on_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "post_ctor": "logger 'testing-succ-file-luks: ctor'", | ||||
|         "pre_setup": "set -e -o pipefail ; [ ! -e /mnt/test.key ] ; [ ! -e /mnt/test.luks ] ; dd if=/dev/random bs=100 of=/mnt/test.key iflag=fullblock count=1 ; dd if=/dev/urandom bs=1M of=/mnt/test.luks iflag=fullblock count=2048 ; cryptsetup luksFormat -q --key-file /mnt/test.key /mnt/test.luks ; cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mkfs -t ext4 /dev/mapper/test-luks ; mkdir -p /mnt/test_luks ; mount /dev/mapper/test-luks /mnt/test_luks", | ||||
|         "pre_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" != \"/mnt/test_luks\" ]] ; then cryptsetup status test-luks > /dev/null || cryptsetup open -q --key-file /mnt/test.key /mnt/test.luks test-luks ; mount /dev/mapper/test-luks /mnt/test_luks ; else exit 0 ; fi", | ||||
|         "post_destroy": "umount /mnt/test_luks && cryptsetup close test-luks ; set -e -o pipefail ; dd if=/dev/urandom bs=100 of=/mnt/test.key iflag=fullblock count=1 ; rm -f /mnt/test.key ; rm -f /mnt/test.luks ; rmdir /mnt/test_luks", | ||||
|         "pre_volume_create":           "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "pre_volume_import":           "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "pre_volume_import_data":      "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "post_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-luks -n -o TARGET)\" == \"/mnt/test_luks\" ]]", | ||||
|         "description": "For testing purposes only: Showcasing seemless use of encrypted VM pools. For personal use, a dedicated script is recommended." | ||||
|     }, | ||||
| "testing-succ-file-luks-eph": | ||||
| @ -85,13 +85,13 @@ | ||||
|             "dir_path": "/mnt/test_eph" | ||||
|         }, | ||||
|         "signal_back": true, | ||||
|         "on_setup": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0", | ||||
|         "on_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0", | ||||
|         "on_destroy": "umount /mnt/test_eph && cryptsetup close test-eph ; set -e -o pipefail ; if [ -f /mnt/ram/teph.key ] ; then dd if=/dev/urandom bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; rm -f /mnt/ram/teph.key ; fi ; rm -f /mnt/teph.luks ; rmdir /mnt/test_eph", | ||||
|         "on_volume_create":          "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "on_volume_import":          "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "on_volume_import_data":     "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "on_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "pre_setup": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0", | ||||
|         "pre_sinit": "set -e -o pipefail ; if [[ \"$(findmnt -T /mnt/ram -o SOURCE -n)\" != \"ramfs\" ]] ; then mkdir -p /mnt/ram ; mount -t ramfs ramfs /mnt/ram ; fi ; if [[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" != \"/mnt/test_eph\" ]] ; then if [ -f /mnt/ram/teph.key ] ; then cryptsetup status test-eph > /dev/null || cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; else dd if=/dev/random bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; if [ ! -f /mnt/teph.luks ] ; then dd if=/dev/urandom bs=1M of=/mnt/teph.luks iflag=fullblock count=2048 ; fi ; cryptsetup luksFormat -q --key-file /mnt/ram/teph.key /mnt/teph.luks ;cryptsetup open -q --key-file /mnt/ram/teph.key /mnt/teph.luks test-eph ; mkfs -t ext4 /dev/mapper/test-eph ; echo SIGNAL_setup ; fi ; mkdir -p /mnt/test_eph ; mount /dev/mapper/test-eph /mnt/test_eph ; fi ; exit 0", | ||||
|         "post_destroy": "umount /mnt/test_eph && cryptsetup close test-eph ; set -e -o pipefail ; if [ -f /mnt/ram/teph.key ] ; then dd if=/dev/urandom bs=100 of=/mnt/ram/teph.key iflag=fullblock count=1 ; rm -f /mnt/ram/teph.key ; fi ; rm -f /mnt/teph.luks ; rmdir /mnt/test_eph", | ||||
|         "pre_volume_create":           "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "pre_volume_import":           "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "pre_volume_import_data":      "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "post_volume_import_data_end": "[[ \"$(findmnt -S /dev/mapper/test-eph -n -o TARGET)\" == \"/mnt/test_eph\" ]]", | ||||
|         "description": "For testing purposes only: Showcasing seemless use of encrypted disposable (upon boot) VM pools with keys held in RAM only. For personal use, a dedicated script is recommended." | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -78,23 +78,23 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     qvm-pool -o conf_id=testing-succ-file-02 -a test callback | ||||
|     qvm-pool | ||||
|     ls /mnt/test02 | ||||
|     less /tmp/callback.log (on_ctor & on_setup should be there and in that order) | ||||
|     less /tmp/callback.log (post_ctor & pre_setup should be there and in that order) | ||||
|     qvm-create -l red -P test test-vm | ||||
|     cat /tmp/callback.log (2x on_volume_create should be added) | ||||
|     cat /tmp/callback.log (2x pre_volume_create should be added) | ||||
|     qvm-start test-vm | ||||
|     qvm-volume | grep test-vm | ||||
|     grep test-vm /var/lib/qubes/qubes.xml | ||||
|     ls /mnt/test02/appvms/ | ||||
|     cat /tmp/callback.log (2x on_volume_start should be added) | ||||
|     cat /tmp/callback.log (2x pre_volume_start should be added) | ||||
|     qvm-shutdown test-vm | ||||
|     cat /tmp/callback.log (2x on_volume_stop should be added) | ||||
|     cat /tmp/callback.log (2x post_volume_stop should be added) | ||||
|     #reboot | ||||
|     cat /tmp/callback.log (only (!) on_ctor should be there) | ||||
|     cat /tmp/callback.log (only (!) post_ctor should be there) | ||||
|     qvm-start test-vm | ||||
|     cat /tmp/callback.log (on_sinit & 2x on_volume_start should be added) | ||||
|     cat /tmp/callback.log (pre_sinit & 2x pre_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 on_volume_stop, 2x on_volume_remove, on_destroy should be added) | ||||
|     less /tmp/callback.log (2x post_volume_stop, 2x post_volume_remove, post_destroy should be added) | ||||
| 
 | ||||
|     qvm-pool -o conf_id=testing-succ-file-02 -a test callback | ||||
|     qvm-create -l red -P test test-dvm | ||||
| @ -111,7 +111,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     qvm-pool -o conf_id=testing-succ-file-03 -a test callback | ||||
|     qvm-pool | ||||
|     ls /mnt/test03 | ||||
|     less /tmp/callback.log (on_ctor & on_setup should be there, no more arguments) | ||||
|     less /tmp/callback.log (post_ctor & pre_setup should be there, no more arguments) | ||||
|     qvm-pool -r test && sudo rm -rf /mnt/test03 | ||||
|     less /tmp/callback.log (nothing should have been added) | ||||
| 
 | ||||
| @ -123,13 +123,13 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     sudo cryptsetup status test-luks | ||||
|     sudo mount | grep test_luks | ||||
|     ls /mnt/test_luks/ | ||||
|     qvm-create -l red -P tluks test-luks (journalctl -b0 should show two on_volume_create callbacks) | ||||
|     qvm-create -l red -P tluks test-luks (journalctl -b0 should show two pre_volume_create callbacks) | ||||
|     ls /mnt/test_luks/appvms/test-luks/ | ||||
|     qvm-volume | grep test-luks | ||||
|     qvm-start test-luks | ||||
|     #reboot | ||||
|     grep luks /var/lib/qubes/qubes.xml | ||||
|     sudo cryptsetup status test-luks (should be inactive due to late on_sinit!) | ||||
|     sudo cryptsetup status test-luks (should be inactive due to late pre_sinit!) | ||||
|     qvm-start test-luks | ||||
|     sudo mount | grep test_luks | ||||
|     qvm-shutdown --wait test-luks | ||||
| @ -145,7 +145,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     md5sum /mnt/ram/teph.key (1) | ||||
|     sudo mount|grep -E 'ram|test' | ||||
|     sudo cryptsetup status test-eph | ||||
|     qvm-create -l red -P teph test-eph (should execute two on_volume_create callbacks) | ||||
|     qvm-create -l red -P teph test-eph (should execute two pre_volume_create callbacks) | ||||
|     qvm-volume | grep test-eph | ||||
|     ls /mnt/test_eph/appvms (should have private.img and volatile.img) | ||||
|     ls /var/lib/qubes/appvms/test-eph (should only have the icon) | ||||
| @ -242,11 +242,11 @@ class CallbackPool(qubes.storage.Pool): | ||||
| 
 | ||||
|         super().__init__(name=name, revisions_to_keep=int(bdriver_args.get('revisions_to_keep', 1))) | ||||
|         self._cb_ctor_done = True | ||||
|         self._callback_nocoro('on_ctor') | ||||
|         self._callback_nocoro('post_ctor') | ||||
| 
 | ||||
|     def _check_init(self): | ||||
|         ''' Whether or not this object requires late storage initialization via callback. ''' | ||||
|         cmd = self._cb_conf.get('on_sinit') | ||||
|         cmd = self._cb_conf.get('pre_sinit') | ||||
|         if not cmd: | ||||
|             cmd = self._cb_conf.get('cmd') | ||||
|         return bool(cmd and cmd != '-') | ||||
| @ -254,12 +254,12 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     @asyncio.coroutine | ||||
|     def _init(self, callback=True): | ||||
|         ''' Late storage initialization on first use for e.g. decryption on first usage request. | ||||
|         :param callback: Whether to trigger the `on_sinit` callback or not. | ||||
|         :param callback: Whether to trigger the `pre_sinit` callback or not. | ||||
|         ''' | ||||
|         with self._cb_init_lock: | ||||
|             if self._cb_requires_init: | ||||
|                 if callback: | ||||
|                     yield from self._callback('on_sinit') | ||||
|                     yield from self._callback('pre_sinit') | ||||
|                 self._cb_requires_init = False | ||||
| 
 | ||||
|     def _init_nocoro(self, callback=True): | ||||
| @ -267,7 +267,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
|         with self._cb_init_lock: | ||||
|             if self._cb_requires_init: | ||||
|                 if callback: | ||||
|                     self._callback_nocoro('on_sinit') | ||||
|                     self._callback_nocoro('pre_sinit') | ||||
|                 self._cb_requires_init = False | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
| @ -352,7 +352,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     def destroy(self): | ||||
|         yield from self._assert_initialized() | ||||
|         ret = yield from coro_maybe(self._cb_impl.destroy()) | ||||
|         yield from self._callback('on_destroy') | ||||
|         yield from self._callback('post_destroy') | ||||
|         return ret | ||||
| 
 | ||||
|     def init_volume(self, vm, volume_config): | ||||
| @ -363,7 +363,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
|     @asyncio.coroutine | ||||
|     def setup(self): | ||||
|         yield from self._assert_initialized(callback=False) #setup is assumed to include storage initialization | ||||
|         yield from self._callback('on_setup') | ||||
|         yield from self._callback('pre_setup') | ||||
|         return (yield from coro_maybe(self._cb_impl.setup())) | ||||
| 
 | ||||
|     @property | ||||
| @ -419,7 +419,7 @@ class CallbackPool(qubes.storage.Pool): | ||||
| class CallbackVolume(qubes.storage.Volume): | ||||
|     ''' Proxy volume adding callback functionality to other volumes. | ||||
| 
 | ||||
|         Required to support the `on_sinit` and other callbacks. | ||||
|         Required to support the `pre_sinit` and other callbacks. | ||||
|     ''' | ||||
| 
 | ||||
|     def __init__(self, pool, impl): | ||||
| @ -432,7 +432,7 @@ class CallbackVolume(qubes.storage.Volume): | ||||
|         impl.pool = pool #enforce the CallbackPool instance as the parent pool of the volume | ||||
|         self._cb_pool = pool #: CallbackPool instance the Volume belongs to. | ||||
|         self._cb_impl = impl #: Backend volume implementation instance. | ||||
|         #NOTE: we must *not* call super().__init()__ as it would prevent attribute delegation | ||||
|         #NOTE: we must *not* call super().__init__() as it would prevent attribute delegation | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def _assert_initialized(self, **kwargs): | ||||
| @ -448,52 +448,52 @@ class CallbackVolume(qubes.storage.Volume): | ||||
|     @asyncio.coroutine | ||||
|     def create(self): | ||||
|         yield from self._assert_initialized() | ||||
|         yield from self._callback('on_volume_create') | ||||
|         yield from self._callback('pre_volume_create') | ||||
|         return (yield from coro_maybe(self._cb_impl.create())) | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def remove(self): | ||||
|         yield from self._assert_initialized() | ||||
|         ret = yield from coro_maybe(self._cb_impl.remove()) | ||||
|         yield from self._callback('on_volume_remove') | ||||
|         yield from self._callback('post_volume_remove') | ||||
|         return ret | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def resize(self, size): | ||||
|         yield from self._assert_initialized() | ||||
|         yield from self._callback('on_volume_resize', cb_args=[size]) | ||||
|         yield from self._callback('pre_volume_resize', cb_args=[size]) | ||||
|         return (yield from coro_maybe(self._cb_impl.resize(size))) | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def start(self): | ||||
|         yield from self._assert_initialized() | ||||
|         yield from self._callback('on_volume_start') | ||||
|         yield from self._callback('pre_volume_start') | ||||
|         return (yield from coro_maybe(self._cb_impl.start())) | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def stop(self): | ||||
|         yield from self._assert_initialized() | ||||
|         ret = yield from coro_maybe(self._cb_impl.stop()) | ||||
|         yield from self._callback('on_volume_stop') | ||||
|         yield from self._callback('post_volume_stop') | ||||
|         return ret | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def import_data(self): | ||||
|         yield from self._assert_initialized() | ||||
|         yield from self._callback('on_volume_import_data') | ||||
|         yield from self._callback('pre_volume_import_data') | ||||
|         return (yield from coro_maybe(self._cb_impl.import_data())) | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def import_data_end(self, success): | ||||
|         yield from self._assert_initialized() | ||||
|         ret = yield from coro_maybe(self._cb_impl.import_data_end(success)) | ||||
|         yield from self._callback('on_volume_import_data_end', cb_args=[success]) | ||||
|         yield from self._callback('post_volume_import_data_end', cb_args=[success]) | ||||
|         return ret | ||||
| 
 | ||||
|     @asyncio.coroutine | ||||
|     def import_volume(self, src_volume): | ||||
|         yield from self._assert_initialized() | ||||
|         yield from self._callback('on_volume_import', cb_args=[src_volume.vid]) | ||||
|         yield from self._callback('pre_volume_import', cb_args=[src_volume.vid]) | ||||
|         return (yield from coro_maybe(self._cb_impl.import_volume(src_volume))) | ||||
| 
 | ||||
|     def is_dirty(self): | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 3hhh
						3hhh