macVMs is a lightweight CLI tool for managing QEMU virtual machines on Apple Silicon Macs.
It focuses on simplicity and reproducibility, making it easy to create and manage fully emulated x86 and x86_64 virtual machines without manually writing QEMU commands.
Some time ago I was doing some CTF (capture the flag) Cybersecurity competitions, but I couldn't tackle the software related challenges because of my MacBook and the ARM architecture.
I decided to build my very own wrapper over QEMU to create lightweight, emulated virtual machines similar to what WSL 2.0 offers, and so, macVMs was born.
macVMs is designed to be portable and easy to use:
- Interactive VM creation
- Configurable RAM, CPU and disk size
- Headless serial-console installation
- Shared folders via 9p
- Built-in networking presets
- Per-VM QEMU configuration overrides
- Optional SSH-based workflow
- macOS
- Python 3.9+
- QEMU
- Basic VM / operating system installation knowledge
- Launch macVMs.
- Create a new VM.
- Select an operating system.
- Complete the installation.
- Start the VM.
- Configure SSH (optional).
- Connect to the VM.
The entire workflow can be completed from the interactive menu without manually invoking QEMU.
During creation you will be prompted for:
- VM name
- Operating system
- RAM size
- CPU count
- Disk size
- Optional shared folder
Both Debian and Ubuntu are configured to boot directly into a serial-console installer suitable for headless environments.
For lightweight virtual machines:
- Install only standard system utilities.
- Avoid desktop environments unless required.
This produces a small VM that boots directly into a shell.
By default, macVMs forwards:
localhost:2222 -> guest:22
Install OpenSSH inside the guest:
sudo apt update
sudo apt install -y openssh-server
sudo systemctl enable --now sshSet a root password:
sudo passwd rootEnable root login:
sudo tee -a /etc/ssh/sshd_config >/dev/null <<EOF
PermitRootLogin yes
PasswordAuthentication yes
EOF
sudo systemctl restart sshConnect from the host:
ssh -p 2222 root@localhostSetup the macvms command in the host:
./scripts/install-macvms.shWhen enabled, a host directory is exposed to the guest using QEMU 9p. This allows for your file to be also accessed through the VM.
Create a mount point:
sudo mkdir /mnt/sharedMount the share:
sudo mount -t 9p -o trans=virtio shared /mnt/sharedTo make a persistent mount:
echo 'shared /mnt/shared 9p trans=virtio,version=9p2000.L,rw 0 0' | sudo tee -a /etc/fstab
sudo mount -amacVMs supports three networking modes:
Default mode.
network=userProvides NAT networking and automatic SSH forwarding.
network=vmnet-sharedProvides a macOS-managed shared network.
network=vmnet-bridged
ifname=en0Places the guest directly on the physical network.
Each VM contains a dedicated configuration file:
~/macVMs/vms/<vm-name>/qemu.conf
This config file is very technical and not user-friendly.
Supported options:
network=user|vmnet-shared|vmnet-bridged
ifname=en0
nic_model=virtio-net-pci
hostfwd=tcp::2222-:22
extra_args=<qemu args>
qemu_args=<qemu args>Example:
network=user
hostfwd=tcp::2222-:22Example:
network=vmnet-bridged
ifname=en0
nic_model=virtio-net-pciCreate a virtual environment:
python3 -m venv .venv
source .venv/bin/activateBuild the application:
./build.shThe resulting disk image will be available at:
dist/macVMs.dmg
You can then move the application into the macOS Applications directory.
- Uses QEMU full emulation
- Hardware virtualization is not enabled
- Performance is MUCH lower than native virtualization
macVMs is intended for small, testing environments and lightweight Linux instances. It's not intended to be a full-featured virutalization platform.
Made by xEcho1337
Licensed under Apache License 2.0.