Hello everyone,

I had some down time and I wanted to learn more about Guile and Guix, I have used NixOS in the past and still do for some projects and for work related stuff. In that context, I've used something called microvm.nix[1] as a way to create lightweight vm environment and I did miss that workflow for Guix. I know that (gnu system vm) exists and I did use
it but it's tied to qemu

With the changes in rust import, it really made packaging rust application a lot easier. Thank you! So with that in mind I've packaged `cloud-hypervisor`[2] and `virtiofsd`[3] and started playing a little
in creating a uniform api, maybe I've played too much?

So I've made a working poc that I've made available as a channel at https://codeberg.org/pierhugues/microvm. Keep in mind it's experimental, code is not the best guile code ever, but we all have to start somewhere. `microvm` will compile as a derivation but its not really runnable alone if you share directories from the host. When you run it with the `microvm-service-type` it will take care of starting `virtiofsd-service-type` per share.

(service microvm-service-type
       (microvm-configuration
           (microvm-config
               (microvm
                   (name "complex-vm")
                   (boot %microvm-base-os)
                   (vmm cloud-hypervisor)
                   (memory 256)
                   (vcpu 1)
                   (net (list (net
                               (name "tap3")
                               (type 'tap)
                               (mac "02:00:00:00:00:05"))))
                   (shares
                       (list (share
                               (tag "src")
                               (shared-dir "/home/ph/src/")
                               (mount-point "/home/microvm/src/")
                               (readonly? #f)
                               (type "virtiofs"))
                           (share
                               (tag "documents")
                               (shared-dir "/home/ph/Documents/")
(mount-point "/home/microvm/Documents")
                               (type "virtiofs"))))))))


Keep in mind its optimized for happy path (I already said it's poc), so it doesn't handle validation or edge cases.
But it does the following:

- Start the services required for the shares.
- Ensure that the `operating-system` is configured for the shares
- Make the store available (using volatile)
- A small service to handle the tap creation, need to be done manually see the readme.org
- Should be able to add a different vmm like firecracker.
- It could also start the vmm with a different image like ubuntu, I have a hacky config for that.

What is next for me?

Actually I am not sure, I had fun, I've learned a lot.
I will certainly upstream the packages I've made and probably the services for virtiofsd. I will continue to hack on the channel and I will see what I'll do with it.

If there any interest let me know.

--
Thanks
ph

[1]: https://github.com/microvm-nix/microvm.nix
[2]: https://github.com/cloud-hypervisor/cloud-hypervisor/
[3]: https://gitlab.com/virtio-fs/virtiofsd

Reply via email to