Enroll Machines with QEMU
QEMU is an open source virtualization tool that allows you to launch VMs on many different architectures.
Using QEMU is handy to quickly get a local VM node joined to your meltcloud Clusters.
Prerequisites
- Create an Enrollment Image or reuse an existing one
- Download the
.isofile for your architecture (amd64 or arm64) used to launch the QEMU virtual machine.
Launch a Virtual Machine with QEMU
Directly launch a virtual machine using QEMU and the previously generated .iso enrollment image.
shell
# install QEMU
brew install qemu
# setup a path to store your QEMU disk files
disks_path=./melt-disks
mkdir -p ${disks_path}
# create a disk for the ephemeral root device that holds docker images
disk_path=${disks_path}/melt-node.qcow2
qemu-img create -f qcow2 $disk_path 20g
# add efi-vars to persist boot order settings
efi_vars=${disks_path}/efi-vars.fd
cp $(brew --prefix qemu)/share/qemu/edk2-arm-vars.fd $efi_vars
# Enrollment Image ISO path - adjust it to your filename
enrollment_iso="$HOME/Downloads/enrollment-image-arm64.iso"
# assign a UUID - be aware that creating a new UUID will create a new machine in meltcloud
machine_uuid=$(uuidgen)
mem=4G # requires at least 4GB - give more for more workload
cpus=6 # no minimum requirement for CPU, but let's give it some power!
# start the machine (Ctrl-a, release, hit x to exit)
qemu-system-aarch64 \
--uuid $machine_uuid \
-m $mem \
-smp $cpus \
-netdev user,id=net1 \
-device nec-usb-xhci,id=usb-bus \
-device usb-storage,drive=meltcloud-iso,removable=true,bus=usb-bus.0 \
-drive if=none,id=meltcloud-iso,media=cdrom,file=${enrollment_iso},readonly=on \
-device virtio-net-pci,netdev=net1,bus=pcie.0,addr=0x19 \
-drive file=$(brew --prefix qemu)/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
-drive file=${efi_vars},if=pflash,format=raw \
-hda ${disk_path} \
-machine virt \
-accel hvf \
-cpu host \
-nographicshell
# install QEMU
sudo apt install qemu-system ovmf
sudo adduser `id -un` kvm
# setup a path to store your QEMU disk files
disks_path=./melt-disks
mkdir -p ${disks_path}
mem=4G # requires at least 4GB
cpus=2
# create a disk for the ephemeral root device that holds docker images
disk_path=${disks_path}/melt-node.qcow2
qemu-img create -f qcow2 $disk_path 20g
# add efi-vars to persist boot order settings
efi_vars=${disks_path}/efi-vars.fd
cp /usr/share/OVMF/OVMF_VARS_4M.fd $efi_vars
# Enrollment Image ISO path - adjust it to your filename
enrollment_iso="$HOME/Downloads/enrollment-image-amd64.iso"
# assign a UUID - be aware that creating a new UUID will create a new machine in meltcloud
machine_uuid=$(uuidgen)
# start the machine (To exit press Alt + 2, then type "quit")
qemu-system-x86_64 \
-uuid $machine_uuid \
-m $mem \
-accel kvm \
-smp $cpus \
-cdrom $enrollment_iso \
-cpu host \
-netdev user,id=hostnet0 \
-device e1000,netdev=hostnet0,bus=pci.0,addr=0x3 \
-drive file=$disk_path,if=virtio \
-drive file=/usr/share/OVMF/OVMF_CODE_4M.fd,if=pflash,format=raw,readonly=on \
-drive file=${efi_vars},if=pflash,format=raw \
-boot order=dTroubleshoot
If your VM has trouble booting, check out the Enrollment Images – Troubleshooting section.
