chore: update qemu hack script to use ISO

This can serve as an example of providing the config via an ISO, and
simplify local setups a bit.

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
This commit is contained in:
Andrew Rynhard 2020-09-29 19:58:12 -07:00 committed by talos-bot
parent eb9ee06dbc
commit 7017327059

View File

@ -4,11 +4,6 @@ set -e
: ${TALOS_QEMU_ROOT:="/tmp"}
if [[ $# -ne 1 ]]; then
echo 1>&2 "Usage: $0 <machine config URL>"
exit 3
fi
case $(uname -s) in
Linux*)
ACCEL=kvm
@ -22,23 +17,27 @@ case $(uname -s) in
;;
esac
KERNEL="build/vmlinuz"
INITRD="build/initramfs.xz"
KERNEL="_out/vmlinuz-amd64"
INITRD="_out/initramfs-amd64.xz"
IMAGE="$TALOS_QEMU_ROOT/rootfs.qcow2"
MACHINE_CONFIG="${1}"
ISO="$TALOS_QEMU_ROOT/iso/config.iso"
talosctl gen config -o ${TALOS_QEMU_ROOT}/iso qemu https://10.254.0.10
cp ${TALOS_QEMU_ROOT}/iso/init.yaml ${TALOS_QEMU_ROOT}/iso/config.yaml
mkisofs -joliet -rock -volid 'metal-iso' -output ${ISO} ${TALOS_QEMU_ROOT}/iso
qemu-img create -f qcow2 ${IMAGE} 8G
qemu-system-x86_64 \
-m 2048 \
-accel ${ACCEL},thread=multi \
-accel ${ACCEL} \
-cpu max \
-smp 2 \
-hda ${IMAGE} \
-netdev user,id=talos,ipv4=on,net=10.254.0.0/24,dhcpstart=10.254.0.10,hostfwd=tcp::50000-:50000,hostname=master-1 \
-netdev user,id=talos,ipv4=on,net=10.254.0.0/24,dhcpstart=10.254.0.10,hostfwd=tcp::50000-:50000,hostfwd=tcp::6443-:6443,hostname=master-1 \
-device virtio-net,netdev=talos \
-nographic \
-serial mon:stdio \
-append "talos.platform=metal page_poison=1 slub_debug=P slab_nomerge pti=on printk.devkmsg=on earlyprintk=serial,tty0,keep console=tty0 talos.config=${MACHINE_CONFIG}" \
-cdrom ${ISO} \
-append "talos.platform=metal page_poison=1 slub_debug=P slab_nomerge pti=on printk.devkmsg=on earlyprintk=serial,tty0,keep console=tty0 talos.config=metal-iso" \
-kernel ${KERNEL} \
-initrd ${INITRD}