Pool interface questions

30 views
Skip to first unread message

David Hobach

unread,
Jun 14, 2020, 7:00:29 AM6/14/20
to qubes...@googlegroups.com
Dear devs,

I'm trying to understand the qubes.storage.Pool interface and its
requirements for implementations.

In particular I wonder:
Are implementations required to be fully initialized right after the
constructor is called?

I'm asking because I prefer "lazy initialization"; I don't want to
execute a lot of code for initialization and then later the user doesn't
even start any VM running on my pool.

For example, you usually wouldn't want to decrypt a pool until the user
requests some data from it.

Or do I have to implement "lazy initialization" myself?

I.e. I guess I'd then have to one-time run the initialization code on
any interface method that would require me to be initialized?

Best Regards
David

Rusty Bird

unread,
Jun 14, 2020, 10:27:08 AM6/14/20
to David Hobach, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

David Hobach:
> I'm trying to understand the qubes.storage.Pool interface and its
> requirements for implementations.
>
> In particular I wonder:
> Are implementations required to be fully initialized right after the
> constructor is called?

You don't necessarily have to do anything in __init__(), except
forward the call to the base class so it can set some standard
attributes like 'name'.

> For example, you usually wouldn't want to decrypt a pool until the user
> requests some data from it.
>
> Or do I have to implement "lazy initialization" myself?
>
> I.e. I guess I'd then have to one-time run the initialization code on any
> interface method that would require me to be initialized?

That sounds right. It's really up to the driver which of the public
methods - e.g. vol.remove() - can operate independently on a volume,
and which need to arrange some some heavy per-pool or global state.

Rusty
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEhLWbz8YrEp/hsG0ERp149HqvKt8FAl7mLAdfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDg0
QjU5QkNGQzYyQjEyOUZFMUIwNkQwNDQ2OUQ3OEY0N0FBRjJBREYACgkQRp149Hqv
Kt/9sg//aQ6ETqLucK+mvp+GfAhxZRxNzIgB4v+MsGwlNKkGZpKuwGtrjpEhNWnv
lBMhD0KyttKKwP7TGfospq6e8/s+3qJ4LMxJPJFbftWn1Y/Rd+nbsIbZzVONZ5bf
PCuImeD155RC+WKd0RZj+ZGgvToMe4ypESn3AUHIC2vB1MHVvTNMfbWnCzceZ7Bw
TUVY/iqkGnjNNZMunYUVcEe3tuUpt8y8k5NweoN7vR3cowfKBEH98FTotGTqucX8
MoCVgg/Q027KyhhU6EfvN7C+7dA+w9mT1N74Qw5UA6NzV287AjWBWIVR/8jTrgE3
6ZVD/QNy3o2+zbgmp70YWPoTKzEZxDFu2+uIIRVFb5nXnOal+ZIUysr6A0A5btZC
gk2jO0W+HXQJLO0HDfaB9k8aRxA3tH4/zPZsThay3RQCrXU9wg2d509aBE9txgSN
xbmMMyP4W9fwzXybvZBj9lvR0mT3Z496vqjUiK7PjgNsM5IlauZjm85xso5Rla5z
UnAEMPZ8+IZENRpB7NMNKx+JNX3SkbjiSys1UwVvLDLxiYSJ/oXLGpmBBQD/z6n8
6UD15ej55ov8qBK8Ahs/QdMj+3j6MRODy0Tauie+2EMkFmvIa5tOtM2dmmFLh4jJ
C2i8l1gC3Z9oHoKb6H9U4EnQi2VI4i5AjJkh3dUqYYGA2RKZoR0=
=GEWu
-----END PGP SIGNATURE-----

David Hobach

unread,
Jun 20, 2020, 1:00:14 PM6/20/20
to qubes...@googlegroups.com, rust...@net-c.com
On 6/14/20 3:54 PM, Rusty Bird wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> David Hobach:
>> For example, you usually wouldn't want to decrypt a pool until the user
>> requests some data from it.
>>
>> Or do I have to implement "lazy initialization" myself?
>>
>> I.e. I guess I'd then have to one-time run the initialization code on any
>> interface method that would require me to be initialized?
>
> That sounds right. It's really up to the driver which of the public
> methods - e.g. vol.remove() - can operate independently on a volume,
> and which need to arrange some some heavy per-pool or global state.

I just noticed that Pool.init_volume() is the last Pool method to be
called before a VM starts. Unfortunately it's called during boot for all
VMs, so not exactly what I'd call "late".

So I guess I'd also have to proxy the Volume class for that feature? -_-

Just please let me know if you have a better idea.

Otherwise enjoy the weekend & Best Regards
David

Marek Marczykowski-Górecki

unread,
Jun 20, 2020, 1:51:13 PM6/20/20
to David Hobach, qubes...@googlegroups.com, rust...@net-c.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sat, Jun 20, 2020 at 07:00:10PM +0200, David Hobach wrote:
> On 6/14/20 3:54 PM, Rusty Bird wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA512
> >
> > David Hobach:
> > > For example, you usually wouldn't want to decrypt a pool until the user
> > > requests some data from it.
> > >
> > > Or do I have to implement "lazy initialization" myself?
> > >
> > > I.e. I guess I'd then have to one-time run the initialization code on any
> > > interface method that would require me to be initialized?
> >
> > That sounds right. It's really up to the driver which of the public
> > methods - e.g. vol.remove() - can operate independently on a volume,
> > and which need to arrange some some heavy per-pool or global state.
>
> I just noticed that Pool.init_volume() is the last Pool method to be called
> before a VM starts. Unfortunately it's called during boot for all VMs, so
> not exactly what I'd call "late".

This method is used just to create instance of appropriate volume
object. The actual data doesn't need to be available at this point.
See here for documentation about various methods:
https://dev.qubes-os.org/projects/core-admin/en/latest/qubes-storage.html#storage-pool-driver-api

> So I guess I'd also have to proxy the Volume class for that feature? -_-

I think so. The right place for "initialize storage before VM start" is
Volume.start().

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAl7uTIkACgkQ24/THMrX
1yzoowf/QUkeq95ANz4j9SXdpOuequ3X13T1LxTa/cw6TszARJYYKWvPPg1XGWk7
1T6mbue3NH4AHKz9Qru9zKyn08L5B9sR08Wdwkm191t19qK2BymtilQ8e9/poGAH
kE8LJZaMFsRXEMxItVNaxEEufeSW0HZ96OZBMxaODWulBAweRud6s6CsLQMA/n66
lxIqzohZgMnYEjn82x3v3UIsR/t9upUa8KwVOD8eiWdg+OGH/XXXCPRDfU4b5tnW
DfwGNdouVldcMylHw3kDiS9PqBr5Eia+rKzj5J5uGJy2533br5FpX1HYUwlgQskm
d5Jx+gJFkN3VaGLzeCTs8zIDYFfrOw==
=sx2W
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages