summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorSimon Spöhel <simon@spoehel.ch>2021-04-19 08:50:05 +0000
committerSakirnth Nagarasa <sakirnth@gmail.com>2021-09-01 08:24:59 +0000
commitdee050f39c72d07edbc34bc4c13e8dbb6c3c89b8 (patch)
treea92eb49c67d0b6e2c4ac4564ee34e46bd7d9258c /libexec
parentCreating option for images booting efi or legacy bios. (diff)
downloadcompute-tools-dee050f39c72d07edbc34bc4c13e8dbb6c3c89b8.tar.xz
compute-tools-dee050f39c72d07edbc34bc4c13e8dbb6c3c89b8.zip
Reading VM related variables from config file.
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/container/start-qemu52
1 files changed, 41 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)