Conversation
Name of this implementation is not clear but it wants to abstract some entry-points to underlying target (eg. unix, xen, solo5). _entry-points_ implements: - `at_enter` - `at_exit` It lets end-user to register functions at the beginning and at the end of the MirageOS process. It is currently used to initialize an entropy engine (eg. nocrypto).
an abstraction of entry-points of the underlying target. This specific patch wants to provide a more conventional way (a _functor_ way) to generate random generator according an entropy engine which should register something at the beginning of the procress. This is why random implementations expect an entry-points abstraction. This patch removes a nocrypto implementation which is a dummy implementation to check if, at the link time, `Entropy` module is correctly available - and avoid a linking error.
For each implementation which wants a random implementation, we add a new optional argument `entry_points` to specify which entry-points implementation you want to use to generate a random generator. Then, this optional argument is used to produce, by default, the default random generator described here: Mirage_impl_random.default_random but can still be specified by the end-user. In this last case, optional argument entry_points does not have any others impacts.
This last patch removes nocrypto implementation (again, a dummy implementation to check if an entropy module is available) from conduit and conduit-connector. Implication of this patch is not clear but highlights the weird dependency path of the entropy engine at the end because mirage-entropy was on top of the linking-trick instead the _functor_ way.
|
/cc @Drup |
|
Hi there, thanks for starting that discussion. There are various things going on there: first However, let's step back a little: as far as I can see,
As usual, let me know what you think :-) |
This is the current solution used by As @hannesm said, if we look into the MirageOS eco-system, this solution does not really fit smoothly when a hack with
So we can document it but the hack with On the other hand, as I said, playing with the linking-trick currently - with the current state of the MirageOS eco-system - is not so good when we have nothing (or, at least, But, as I said too, But at this stage, I would like to point another incompatibility: if we use
I'm more convinced by this solution when we can generate a It still is a special case but as you said - and I agree with this - "we do not try to functorise over the scheduler implementation", The patch should be applied only into |
|
I'm very much in favor of removing the horrible hack around nocrypto/random/entroy in the mirage tool. It's very non-uniform with the rest and the fact that it works to begin with is an implementation accident. I do not have much of an opinion on how to remove it, so I'll let you guys decide on that. Regarding the name: when @dinosaure first showed me what he was doing, the name I do like |
first of all: thanks @dinosaure, this is IMHO the way to go forward. some nitpicks:
|
Hi @mirage/core!
This PR is one patch to paving the way for the dunification of MirageOS. But, at least, it rollbacks the MirageOS eco-system to something more homogeneous. Indeed, the choice of MirageOS is to take the advantage of functors to be able to choose an implementations of an abstraction - like choose
irminorcrunchas a read-only KV-store.functoriaserves this purpose and orchestrates application of functors according definitions.The black duck
However, a part of the MirageOS decided to choose an other way to specialize an implementation from another by a non-conventional way:
mirage-entropywithmirage-os-shim. These packages use the linking-trick:mirage-entropyexpects at the link time a CMX which follows CMI provided bymirage-os-shimnocrypto.mirageandmirage-stdlib-randomare done on top of thatAccording discussion on mirage/mirage-os-shim#8, the goal of this PR is to delete this non-explicit dependency path of the MirageOS eco-system and provide a new way to have a random generator implementation.
The solution
This new way is, of course, the functor way. Random generator must initializes an entropy engine at the beginning of the process - so, just before
start.mirage-entropytrusts on a CMI to have an access toat_enter_iterand fill a state used by the entropy engine.However, as I said, implementation of this CMI provided by
mirage-os-shimdoes not exist - not yet. Then,mirage-os-shimprovided a specialization of implementations of targets (eg.mirage-solo5,mirage-xen&mirage-unix) under the same CMI.At the end,
mirage-entropywill be linked with the right specialization/implementation ofmirage-os-shim(with an help ofMETAfile/ocamlfind- hint dunification) and will be have an access toat_enter_iter. However,functoriais not able to follow this kind of dependency - or precisely not conventionally.The choice was made to provide a new interface
Mirage_main.S(see mirage/mirage-os-shim#9) into themirage-os-shimpackage and only an interface - so specialization of targets under this interface should not exist anymore.Then, by this way, we are able to reverse the dependency graph between targets and
mirage-os-shim. targets must depend onmirage-os-shimand implement this interface - the choice was made to provide a new sub-packagemain:mirage-entropywill be functorized over this interface (mirage/mirage-entropy#44) and, by cascading,mirage-random-stdlibwill be functorized too (mirage/mirage-random-stdlib#2).nocrypto.mirageis not needed anymore when a new packagemirage-entropy-nocryptofollows the same implementation but, again, in a functorized way.Random generators expect now an implementation which provides entry-points of the target - see
Mirage_impl_entry_points. Of course, any random occurrence must be updated to, at least, choose the default random implementation (eg.mirage-random-stdlib) with the right default target.Finally, to ensure the existence of the CMX at the link time when we currently compile an unikernel, a dummy implementation was made to track this dependency globally and ensure that CMX of the target to provide
at_enter_iterexists at the link time.Because we follow in this PR an usual pattern (with
functoriaand dependencies withpackage), this dummy implementation is not needed anymore - I think. But I don't know real implication of this deletion.Status of this PR
At first, this PR wants to show what is going on currently and what we will do to start proper discussion of all of that when, even if it concerns few packages, update seems deep enough to avoid to click with blinded eyes.
Secondly, it breaks compatibility specially about
random, so we need to take care across several others packages and still have a consistent eco-system.pinswas not done,versionsshould be cleaned and we should start a release plan.Third,
entry_points/mirage-os-shim/*.mainuse bad names or non-explicit purposes names and we should find a consensus to be clear about all of that to avoid any mis-conception/mis-comprehension.functor design, linking-trick and virtual-library
As I said into mirage/mirage-os-shim#8,
virtual_librariesprovided byduneis interesting for us whenmirageshould be only an interface provider. However, the goal, at this time, is to dunify MirageOS - so I prefer to post-pone this goal.Design of
mirage-entropy/mirage-os-shimis not bad and is an example of how to usevirtual_librariesoutside the scope ofdune- and mirage/mirage-os-shim#8 provides a compatible way across packages of this idea independently of the build-system. However, this patch highlight how linking-trick (at the end, or more generally we can talk about the linking-trick) is fragile specially withfunctoria(which was not developed with pattern in our mind).It shows that, even if we can find good aspects of it, it's hard to follow what is really going on when I spend finally 2 weeks to really understand the dependency graph of all with one of my smallest unikernel
entropieur.I think, we should stay far from all of that at the beginning and start a full documentation of all and may be a migration to this kind of design then, but I consider it as orthogonal to the dunification of MirageOS first.