Crates.io | vmexec |
lib.rs | vmexec |
version | 0.2.0 |
created_at | 2025-03-13 11:06:50.799464+00 |
updated_at | 2025-06-04 17:51:49.974189+00 |
description | Run a single command in a speedy virtual machine with zero-setup |
homepage | |
repository | https://gitlab.archlinux.org/archlinux/vmexec |
max_upload_size | |
id | 1590747 |
size | 223,679 |
Run a single command in a speedy virtual machine with zero-setup
vmexec is a zero-setup CLI tool that runs single commands in a throwaway virtual machines. The idea is for you to run a command in VM without having think about the performance implications, how to mount files, how to forward ports, etc.
Nowadays, many are used to the convenience of container runners such as podman
or docker
but so far it hasn't been as covenient to run a VM, often requiring a manual set up step.
docker run
-inspired interface that many should already be familiar with-e/--env
)-v/--volume
)-p/--publish
)--pull
)--pmem
to bypass the guest page cache entirely)vmexec run archlinux -- echo hello from inside VM
This will take a long time the first time because it will download the Arch Linux image and then warm it up by booting it, waiting until the first-boot processes have settled, then take a snapshot and shutoff the VM. Any subsequent runs will use this snapshot which will result in quick follow-up commands.
vmexec run archlinux -- bash
vmexec run archlinux -e HELLO=yeshello -- bash -c '$HELLO'
vmexec run archlinux -v $PWD/hostdir:/mnt -- ls -lha /mnt
A virtio-pmem device will allow the OS inside the VM to bypass its page cache and use the host's page cache directly. This allows for more efficient RAM usage as and page cache used by the guest will be unavailable to the host and can't be reclaimed.
vmexec run archlinux --pmem /mnt:50 -- ls -lha /mnt
This command will create a temporary sparse file on the host. During VM boot, it's automatically formatted and mounted.
vmexec run archlinux -p 8080:80 -- nc -l -p 80
It is strongly encouraged to enable KSM in your kernel in order to allow for multiple similar VMs to share their pages, thereby strongly cutting their memory costs.
To temporarily enable KSM, you can do this as root:
echo 1 > /sys/kernel/mm/ksm/run
However, you are advised to enable this permanently by running
vmexec ksm --enable
as root.
When running a VM or two, you can check the shared memory stats via
vmexec ksm
which will print a few pretty stats for you.
If you like this kind of stuff or if this doesn't exactly fit your needs, there are also these projects:
This is mostly a note for me on how to release this thing:
CHANGELOG.md
is up to date.cargo release <version>
cargo release --execute <version>