Provision Machines with QEMU
QEMU is an open source virtualization tool, which allows you to launch VMs on many different architectures. Using QEMU together with meltcloud is handy to quickly get a node joined to your meltcloud clusters.
Prerequisites
- Create an Enrollment Image or reuse an existing one
- Download the
.iso
file 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 10g
# add efi-vars to persist bootorder 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=3G # requires at least 3GB - 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 \
-nographic
shell
# 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=3G # requires at least 3GB - give more for more workload
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 10g
# add efi-vars to persist bootorder 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=d