Skip to content
/ msmv Public

MicroVM specialized container build system in Python

License

Notifications You must be signed in to change notification settings

snacsnoc/msmv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuStack MicroVM

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!

Usage

Configuration

Start by creating a TOML configuration file for your VM. Please see the recipes/ directory for examples.

Building the Virtual Machine Image

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 the make command, defaults to make
  • CC - specify the compiler to be used, defaults to cc
  • LD - specify the linker to be used, defaults to ld

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

Running the Virtual Machine

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 

VM Management with VMTool

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

TODO

  • 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

Contributing

Please fork the repository, make your changes, and submit a pull request.

License

This project is licensed under the GPL v3 license.

Releases

No releases published

Packages

No packages published

Languages