Passing KVM virtualization in Balena container

Hello,
I am looking to run a virtual machine image inside of a container for a specific use case. I have been able to do this using QEMU inside of a Balena container. However, I am looking to virtualize using KVM hypervisor instead of QEMU.

That said, does BalenaOS support KVM and if so how would I go about enabling that feature. Can this be enabled through ENV variable in the compose file being used for Balena containers?

I have been able to achieve this through basic docker on a linux box. Just wondering how to best achieve this with BalenaCloud.

Kind Regards,
Jock

Hi @jockdarock . I don’t think we or any other customers have ever tried to run KVM emulation in a container, so it’s not an officially supported feature. That being said, I can’t see why it shouldn’t work, as long as the device type you are using has all the correct kernel modules enabled (no idea what it requires of the host system). You should then just be able to craft a docker-compose file with the same “docker run” commands you used on your basic docker + linux box setup.

Hey @shaunmulligan, thank you for the fast reply.

I was pretty sure on the host side kvm would also have to be installed. And I think I have had trouble with it before in balena, but it has been 2-3 weeks since I have tried it so I am probably forgetting something. I will try it again though and see what happens.

@JockDaRock I think it might work if you have KVM installed in the container userspace provided the kernel supports all the modules that kvm needs.