add yamls and mods to accept various images

This commit is contained in:
Barak Michener 2017-07-02 22:24:08 -07:00
parent e9825ad01a
commit b44639dfe0
6 changed files with 133 additions and 18 deletions

View file

@ -1,11 +1,12 @@
#!/usr/bin/env bash
set -eox pipefail
VM_NAME="${VM_NAME:-coreos-kvm}"
VM_NAME="${VM_NAME:-k8s-kvm}"
VM_MEMORY="${VM_MEMORY:-4G}"
VM_DISK_SIZE="${VM_DISK_SIZE:-12G}"
# hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
HOSTFWD="${HOSTFWD:-hostfwd=tcp::2222-:22}"
DISK_IMG="${DISK_IMG:-./coreos_production_qemu_image.img}"
CD_ARG=""
if [ -n "${CLOUD_CONFIG_FILE}" ]; then
echo "Setting cloud config file: ${CLOUD_CONFIG_FILE}"
@ -32,7 +33,9 @@ if [ -n "$CONFIG_FILE" ]; then
set -- -fw_cfg name=opt/com.coreos/config,file="${PWD}/ignition.json" "$@"
fi
qemu-img resize ./coreos_production_qemu_image.img "${VM_DISK_SIZE}"
if [ -n "$CD_IMG" ]; then
CD_ARG="-drive file=${CD_IMG},media=cdrom"
fi
# https://alpha.release.core-os.net/amd64-usr/current/coreos_production_qemu.sh
qemu-system-x86_64 \
@ -40,10 +43,12 @@ qemu-system-x86_64 \
-enable-kvm \
-cpu host \
-m "${VM_MEMORY}" \
-net nic,model=virtio \
-net user,"${HOSTFWD}",hostname="${VM_NAME}" \
-drive if=virtio,file=./coreos_production_qemu_image.img \
-device virtio-net,netdev=vmnic \
-netdev user,id=vmnic,"${HOSTFWD}",hostname="${VM_NAME}" \
-drive if=virtio,file="${DISK_IMG}" \
${CD_ARG} \
-nographic \
-machine accel=kvm \
-vga std \
-smp 2 \
"$@"
$@