Hi Waldek,

On Tue, Nov 26, 2019 at 12:44 AM Waldek Kozaczuk <[email protected]>
wrote:

> Sometimes it might be more useful to think of unikernels as highly
> isolated processes instead of microVMs with a specialised guest OS. See
> Nabla processes -
> https://acmsocc.github.io/2018/slides/socc18-slides-williams.pdf.
>
> So given that I wonder if it would make sense/be feasible/applicable to
> implement limited fork/execve in OSv. It could work like this:
>
>    1. fork() starts new thread T2 - acts as "stub/proxy" to a new remote
>    microVM that would be lazily started when execve() is actually called
>    2. tid of the new thread T2 would be returned to the caller in the
>    thread T1; it would act as PID of the new process
>    3. New thread T2 would start with same code as calling thread T1 but
>    somehow (???) get 0 as the return value and continue from there (just like
>    on normal Posix OS)
>    4. T2 typically would call execve() right away
>    5.
>       - execve() would somehow communicate with host (how?) to start new
>       child VM with passed in command line, argv
>       - execve() would never return and instead wait unit the child VM
>       terminates
>       - T2 would also somehow listen for some other calls like kill() and
>       pass it to the host that would shutdown child VM
>
> There is obviously a plethora of various IPC mechanisms to communicate
> between processes (shared filesystem, shared memory, named semaphores,
> named semaphores, etc) so how much OSv would need to implement them to make
> such fork/execve useful, I do not know. I am also not sure if that would be
> applicable in any real-world scenarios. Maybe master-worker types of
> workloads (kind of what nginx model is).'
>

You can certainly implement fork()/exec() for an unikernel, and it has been
done before. See, for example, the following paper on Graphene:

  Tsai et al. Cooperation and Security Isolation of Library OSes for
Multi-Process Applications. EuroSys 2014.
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.589.1837&rep=rep1&type=pdf

However, please keep in mind that fork() is used for different kinds of
things, which are not going to be easy to support efficiently using this
kind of model. The way Redis uses fork() for snapshotting comes to mind,
for example.

There is a way to support multi-process environment, though, and that's by
implementing the posix_spawn() system call. I recommend reading the
following paper for a case against fork() and why posix_spawn() makes more
sense in the general case:

  Baumann et al. A fork() in the road. HotOS 2019.
https://www.microsoft.com/en-us/research/uploads/prod/2019/04/fork-hotos19.pdf

- Pekka

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CAGUyND_q5cm093bHuKkPTWPS56ENNh1EcAckH%3DDzGLzUfXamgw%40mail.gmail.com.

Reply via email to