Overview

What is the vm-builder?

vm-builder builds a virtual machine from a text file.

It's goals are:

  • To be extremely portable
    • By relying on minimal dependencies in terms of the software stack, operating system and virtual machine monitor interfaces used
  • To ease the migration of legacy applications from monolithic kernels to microkernels
    • By allowing to build the same virtual machine on different operating system / VMM combinations with the same input files
  • To help iteratively build smaller and more secure virtual machines
    • By providing portable build environents for smaller guest kernels (micro- and unikernels)

Why vm-builder?

As each piece of software is built using other software, it is difficult to ensure that a program is not accidentally infected through malicious code interfering anywhere in this process. An important defence is reducing the amount of code one relies upon and strictly isolating the build from any other processes that could influence it, typically by using a virtual machine.

However, the are currently no minimal, portable and final virtual machine build systems which enable effective bootstrapping of operating systems. Delegating this task to container build systems is insufficient, since they are primarily available to the Linux kernel and provide weak isolation properties. Delivering those with a high portability and even (or especially) on low TCB microkernels is key to secure bootstrapping of operating systems and applications on (to be) trusted infrastructure.

The current prototype has proven successfully applicable to nowadays general purpose OSs, templating/inheritance and reproducible builds are to be implemented. An implementation in a more robust programming language like Rust is still lacking and will be completed in the course of this project. The long term goal is to easily build and provide legacy platforms and software especially on microkernels — allowing for a migration path towards operating systems with effectively manageable complexity.

Getting started

git clone https://codeberg.org/uvm/vm-builder.git
cd vm-builder
cargo install --path .
  • vm-builder list - List all build configurations and images.
  • vm-builder import --path <PATH> - Import a build configuration repository by path.
  • vm-builder build --repo <REPO> --name <NAME> Build an image from a configuration.

How it works

vm-builder is a small rust tool using only the least common denominator of interfaces provided by virtual machine monitors (VMMs), making it extremely portable among kernels and VMMs. To make it explicit: only a serial console and virtual hard disks are necessary for a VMM to be integrated.

It uses a simple build configuration file specifying jobs, those heavylifting is outsourced to a build-vm running inside the VMM e.g. qemu. The build-vm currently is a small (<10MB) buildroot image, which labels, formats, partitions disks, copies files and archives in and out.

This is enough to bootstrap a new operating system installation (target-vm) to boot. In order for the target-vm to run user specified commands, it needs to replicate the command interface of the build-vm.

The requirements for this interface are as simple as it gets:

  1. Read a text file from the VMs second attached hard disk (e.g. /dev/sdb or /dev/vdb).
  2. Execute the command specified.
  3. Return the exit code by the serial console.

Architecture

vm-builder calls a VMM to run a virtual machine working on a job. The VM is passed a text file as a virtual hard disk, which it then acts upon. The VM outputs directly to the virtual serial console attached to it and vm-builder monitors that output for a successful job result or a failure.

Upon a successful job result, the next job in the list is acted upon.

vm-builder approach

The following job groups are available:

  • Disk creation provides a disk to work on with the create-disk job.
  • Disk operations work on a disk by providing different on disk structures for copying files in and out. Needs a created disk.
  • File obtaining jobs fetch files from remote location to the local disk, to copy from onto the target-vm disk.
  • File operations Copy individual files and directories to and from the target-vm disk. Allows for compressing and extracting files and directory to and from the target-vm disk. Needs a partition.
  • Command operations Allows for the target-vm to run user specified commands. Needs the firstrun script copied to the target-vm and running it as a startup script inside the target-vm.

vm-builder jobs

Features

  • Supported VMMs:
    • qemu
  • Supported host kernels:
    • GNU Linux
  • Jobs on VMs
    • create-disk - Create a new disk with a specified size.
    • resize-disk - Resizes a disk to a specified size.
    • label - Label a disk (msdos, gpt).
    • partition - Create partitions (primary, extended, logical).
    • format - Format partitions (ext2, ext3, ext4, fat32, ntfs, ufs, ufs2, xfs, udf, btrfs, minix, exfat)
    • fetch - Download files for later copying / extraction to the VM disk.
    • tar-in - Extract an archive to a partitions path.
    • tar-out - Compress a path in the VM disk to an archive.
    • copy-in - Copy a file or directory to the VM disk.
    • copy-out - Copy a file or directory from the VM disk.
    • dd - Copy a files content to a specific offset on the disk, to e.g. write the MBR.
    • run - Run an arbitrary command as the target-vm, to e.g. creates users, install packages.
    • hash - Create a hash over the raw VM disk.
    • diff - Export the disk in raw format, hash, then diff versions of the files on the VM disk from two consequent runs.
    • remove - Remove a file or directory from the VM disk.
    • export - Recreates the raw disk in order to create a reproducable image checked by hash. See the reference for supported formats.
  • Further support for VMMs and host kernels is in developement.

Development Status

The project is currently in alpha status and the code can be found here.