metznet-channel/scripts/qemu.sh

45 lines
936 B
Bash

#!/usr/bin/env bash
start(){
if [[ $# -lt 3 ]]; then
echo "usage: start [system].scm [netdev] [macaddr]"
exit 1
fi
echo "building $1"
export DOMAIN_CAPS=METZNET.CA
export DOMAIN_NAME=metznet.ca
ro_image=$(guix system image --image-type=qcow2 -L `pwd` $1)
if [[ -z ${ro_image} ]]; then
echo "failed to build $1..."
exit 1
else
echo "built ${ro_image}"
fi
image="${1%.*}.qcow2"
echo "copying ${ro_image} to ${image} and adding 5G to VM"
cp $ro_image $image
chmod +w $image
qemu-img resize $image +5G
echo "starting vm..."
qemu-system-x86_64 -enable-kvm -nographic -serial mon:stdio -hda $image -m 1000 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -nic tap,ifname=$2,script=no,downscript=no,mac=$3
}
stop(){
echo unimplemented
}
case $1 in
start)
shift
start $@
;;
stop)
shift
stop $@
;;
*)
echo $0 "[start|stop] [system].scm"
;;
esac