To bring up the appartus:
- Setup the environment.
This defines the
QVM_DIRdirectory where virtual machine disks are stored, and adds thescriptsdirectory to thePATHvariable.
source env.sh- Create the
qvm0bridge on the host, with address10.42.01/42All virtual machines will plug into that bridge.
qvm-bridge up
# Inspect
ip addr show qvm0- Setup host firewall rules that make the internet reachable from the bridge.
Enable host DNS resolution, assigning the
qvm0.landomain to the bridge.
qvm-setup-host
qvm-dns up
# Inspect
resolvectl status qvm0
journalctl -b SYSLOG_IDENTIFIER=dnsmasq- Start virtual machines.
Assuming existing disks
${QVM_DIR}/machines/{cp,wk1,wk2}.qcow2:
for vm in cp wk1 wk2; do
qvm-run -d "${vm}"
done- The VM serial port and QEMU monitor will be multiplexed on a pty mentioned in the output of
qvm-run. To get a console from the host:
foot --pty dev/pts/3
- Alternatively, SSH to the VMs from the host. Aassuming the SSH public key was authorized on the guest by cloud-init:
ssh -i "${QVM_DIR}/ssh/id_ed25519" root@cp.qvm0.lan- To stop a VM
kill "$(cat "${QVM_DIR}/run/${vm}.pid")"- Add
qcow2images that should serve as VM templates in theQVM_DIR/templatesdirectory.
cp ~/Downloads/rhel-10.0-x86_64-kvm.qcow2 "${QVM_DIR}/templates"- Create a VM disk image named
node, using a template as base image
qvm-create -b rhel-10.0-x86_64-kvm.qcow2 -s 20G node- Optionally, create a
cloud-initseed for the VM, using a provideduser-data(default:scripts/user-data/cloud.yaml)
qvm-localds -u /path/to/user-data.yaml node- Run the VM with cloud-init seed mounted using the
-iflag
qvm-run -i node