Skip to content
/ qvm Public

Equipment for working with QEMU virtual machines

License

Notifications You must be signed in to change notification settings

kwentine/qvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Equipment to work with QEMU VMs

To bring up the appartus:

  • Setup the environment. This defines the QVM_DIR directory where virtual machine disks are stored, and adds the scripts directory to the PATH variable.
source env.sh
  • Create the qvm0 bridge on the host, with address 10.42.01/42 All 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.lan domain 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")"

Creating virtual machines

  • Add qcow2 images that should serve as VM templates in the QVM_DIR/templates directory.
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-init seed for the VM, using a provided user-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 -i flag
qvm-run -i node

About

Equipment for working with QEMU virtual machines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published