MuStack MicroVM (msmv) is a specialized container build system designed to create and manage minimal, secure, and isolated Linux virtual machine images for microVM environments.
Using QEMU's microvm machine type, msmv provides rapid boot times, enhanced security through isolation, and efficient resource management, for developers and hobbyists who require lightweight virtual testing environments.
Imagine Docker, except requiring a lot more effort. It’s like building a ship in a bottle — complex, rewarding, frustrating, and yes, a bit intense!
Start by creating a TOML configuration file for your VM. Please see the recipes/
directory for examples.
Note: it is recommended to use a virtual environment (venv)
python3 -m venv venv
pip install -r requirements.txt
Run the build script with your configuration file:
python -m msmv.bin.msmv --config-file my_application.toml
Options:
-c
or--config-file
- sets the build (recipe) configuration file-b
or--build-dir
- sets the build workspace and output directory
Environment variables:
MAKE_COMMAND
- specify themake
command, defaults tomake
- For Mac OS, I would recommend
lkmake
for building the kernel https://github.com/markbhasawut/mac-linux-kdk
- For Mac OS, I would recommend
CC
- specify the compiler to be used, defaults tocc
LD
- specify the linker to be used, defaults told
This script will:
- Set up the workspace
- Download and extract the Linux kernel
- Configure and build the kernel
- Download and build the specified applications
- Set up the root filesystem
- Put a smile on your face
- Create the final VM image
After building, you can run the VM with QEMU:
Examples:
qemu-system-x86_64 -M microvm -drive file=output_vms/output_image.qcow2,if=virtio -m 128 -nographic -append "console=ttyS0" -qmp unix:/tmp/qmp-socket,server,nowait
The microvm
machine type is not supported for aarch64, so we must use virt
:
qemu-system-aarch64 -M virt -cpu max -kernel Image -initrd rootfs.cpio -append "init=/init rdinit=/init console=ttyAMA0" -serial mon:stdio -nographic
msmv includes VMTool
, a script for managing the VM lifecycle through the QEMU Machine Protocol (QMP):
python -m msmv.bin.msmv start # Starts the VM
python -m msmv.bin.msmv stop # Sends a shutdown signal to the VM
python -m msmv.bin.msmv status # Queries the current status of the VM
- Use build commands defined in recipe versus assuming
make
- Simplify Linux kernel downloading and optionally specify the download URL
- Create
init
script framework to boot into desired application upon VM start - Use script argument to use ccache
- Pass cross-compiler env vars (
CC
, etc) to build processes - Use architecture defined in recipe TOML versus host OS's arch
- Apply predefined kernel config sets (serial only, framebuffer, debugging etc) before user's config
- To reduce requirement for the user to supply all necessary kconfig options in the recipe file
Please fork the repository, make your changes, and submit a pull request.
This project is licensed under the GPL v3 license.