diff options
author | Simon Spöhel <simon@spoehel.ch> | 2021-04-19 08:50:05 +0000 |
---|---|---|
committer | Sakirnth Nagarasa <sakirnth@gmail.com> | 2021-09-01 08:24:59 +0000 |
commit | dee050f39c72d07edbc34bc4c13e8dbb6c3c89b8 (patch) | |
tree | a92eb49c67d0b6e2c4ac4564ee34e46bd7d9258c | |
parent | Creating option for images booting efi or legacy bios. (diff) | |
download | compute-tools-dee050f39c72d07edbc34bc4c13e8dbb6c3c89b8.tar.xz compute-tools-dee050f39c72d07edbc34bc4c13e8dbb6c3c89b8.zip |
Reading VM related variables from config file.
-rwxr-xr-x | libexec/container/start-qemu | 52 | ||||
-rw-r--r-- | share/doc/examples/eos-vm.conf | 59 |
2 files changed, 100 insertions, 11 deletions
diff --git a/libexec/container/start-qemu b/libexec/container/start-qemu index 491278c..e27df60 100755 --- a/libexec/container/start-qemu +++ b/libexec/container/start-qemu @@ -125,12 +125,6 @@ case "${NAME}" in ;; esac -if [ ! -e "${MACHINES}/${NAME}.img" ] -then - echo "'${NAME}': no such vm" >&2 - exit 1 -fi - case "${START}" in false) STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')" @@ -228,8 +222,41 @@ then esac DIRECTORY="$(awk -Fdirectory= '/^directory=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo ${MACHINES}/${NAMES})" - DIRECTORY="-drive file=${DIRECTORY}.img,format=raw,if=virtio" + DRIVE="" + DRIVES="$(awk -Fdrive= '/^drive=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + case "${DRIVES}" in + "") + ;; + + *) + for DRIVE_ITEM in ${DRIVES} + do + DRIVE="${DRIVE} -drive ${DRIVE_ITEM}" + done + ;; + esac + + MEMORY="-m $(awk -Fmemory= '/^memory=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + SERIAL="-serial $(awk -Fserial= '/^serial=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + # FIXME empty + + RAW_OPTIONS="$(awk -Fraw-options= '/^raw-options=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + # FIXME empty + + BIOS_FILE="$(awk -Fbios= '/^bios=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + case "${BIOS_FILE}" in + "") + BIOS="" + ;; + + *) + BIOS="-bios ${BIOS_FILE}" + ;; + esac DROP_CAPABILITY="$(awk -Fdrop-capability= '/^drop-capability=/ { print $2 }' ${CONFIG}/${NAME}.conf)" case "${DROP_CAPABILITY}" in @@ -268,8 +295,9 @@ then for VETH in ${VETHS} do INTERFACE="$(echo ${VETH} | awk -F: '{ print $1 }')" + INTERFACE_ID="$(echo ${VETH} | awk -F: '{ print $2 }')" - NETWORK_VETH_EXTRA="${NETWORK_VETH_EXTRA} -netdev tap,id=${INTERFACE},ifname=${INTERFACE},script=no,downscript=no -device virtio-net-pci,netdev=${INTERFACE}" + NETWORK_VETH_EXTRA="${NETWORK_VETH_EXTRA} -netdev tap,id=${INTERFACE_ID},ifname=${INTERFACE},script=no,downscript=no -device virtio-net-pci,netdev=${INTERFACE_ID}" if [ "$(echo ${INTERFACE} | wc -c)" -gt 15 ] then @@ -400,11 +428,13 @@ case "${START}" in qemu-system-x86_64 \ -machine accel=kvm:tcg \ - ${DIRECTORY} \ - -m 4G \ + ${DRIVE} \ + ${MEMORY} \ -name ${NAME} \ ${NETWORK_VETH_EXTRA} \ - -bios /usr/share/qemu/OVMF.fd + ${BIOS} \ + ${SERIAL} \ + ${RAW_OPTIONS} case "${VERBOSE}" in true) diff --git a/share/doc/examples/eos-vm.conf b/share/doc/examples/eos-vm.conf new file mode 100644 index 0000000..71d2913 --- /dev/null +++ b/share/doc/examples/eos-vm.conf @@ -0,0 +1,59 @@ +# compute-tools: eos1 + +[start] +cnt.auto=false +cnt.container-server=fuchur +cnt.overlay= +cnt.overlay-options= +bind= +bind-ro= +boot=yes +capability= +directory=/var/lib/machines/eos1 +drop-capability= +link-journal=no +machine=test +private-users=no +register=yes +memory=2G +bios= +serial=telnet::3355,server,nowait +raw-options=-usb -boot d +drive=file=/home/simon/downloads/Aboot-veos-serial-8.0.0.iso,index=2,media=cdrom +drive=file=/home/simon/downloads/vEOS-lab-4.25.3M.vmdk,index=0,media=disk,if=ide +network-veth-extra=tap-ma1:ma1 +cnt.network-bridge=tap-ma1:bridge-oob +network-veth-extra=tap-et1:et1 +network-veth-extra=tap-et2:et2 +network-veth-extra=tap-et3:et3 +network-veth-extra=tap-et4:et4 +network-veth-extra=tap-et5:et5 +network-veth-extra=tap-et6:et6 +network-veth-extra=tap-et7:et7 +network-veth-extra=tap-et8:et8 +network-veth-extra=tap-et9:et9 +network-veth-extra=tap-et10:et10 +network-veth-extra=tap-et11:et11 +network-veth-extra=tap-et12:et12 +network-veth-extra=tap-et13:et13 +network-veth-extra=tap-et14:et14 +network-veth-extra=tap-et15:et15 +network-veth-extra=tap-et16:et16 +network-veth-extra=tap-et17:et17 +network-veth-extra=tap-et18:et18 +network-veth-extra=tap-et19:et19 +network-veth-extra=tap-et20:et20 +network-veth-extra=tap-et21:et21 +network-veth-extra=tap-et22:et22 +network-veth-extra=tap-et23:et23 +network-veth-extra=tap-et24:et24 + +[limit] +BlockIODeviceWeight= +BlockIOReadBandwidth= +BlockIOWeight= +BlockIOWriteBandwidth= +CPUQuota= +CPUShares= +MemoryLimit= +TasksMax= |