Change $driver_iso to $fixed_iso

Compatibility for configurations using $driver_iso is preserved.
This commit is contained in:
Martin Wimpress 2021-09-28 15:32:12 +01:00
parent ac13c5875a
commit f60e92d80e
No known key found for this signature in database
GPG Key ID: 61DF940515E06DA3
2 changed files with 25 additions and 8 deletions

View File

@ -275,8 +275,8 @@ function vm_boot() {
echo " - Boot: ${iso}"
fi
if [ -n "${driver_iso}" ] && [ -e "${driver_iso}" ]; then
echo " - Drivers: ${driver_iso}"
if [ -n "${fixed_iso}" ] && [ -e "${fixed_iso}" ]; then
echo " - CD-ROM: ${fixed_iso}"
fi
local CORES_VM="1"
@ -502,14 +502,24 @@ function vm_boot() {
args+=(-drive id=SystemDisk,if=none,format=qcow2,file="${disk_img}"
-device virtio-blk-pci,drive=SystemDisk,scsi=off ${STATUS_QUO})
if [ -n "${fixed_iso}" ]; then
# shellcheck disable=SC2054
args+=(-drive media=cdrom,index=0,file="${fixed_iso}")
fi
else
if [ -n "${iso}" ]; then
# shellcheck disable=SC2054
args+=(-drive media=cdrom,index=0,file="${iso}")
fi
else
if [ -n "${fixed_iso}" ]; then
# shellcheck disable=SC2054
args+=(-drive media=cdrom,index=1,file="${fixed_iso}")
fi
# shellcheck disable=SC2054,SC2206
args+=(-drive media=cdrom,index=0,file="${iso}"
-drive media=cdrom,index=1,file="${driver_iso}"
args+=(
-device virtio-blk-pci,drive=drive0,scsi=off
-drive id=drive0,if=none,cache=directsync,aio=native,format=qcow2,file="${disk_img}"
-device virtio-blk-pci,drive=drive0,scsi=off ${STATUS_QUO}
-device qemu-xhci,id=spicepass
@ -584,7 +594,7 @@ boot="efi"
cpu_cores=""
disk_img=""
disk="64G"
driver_iso=""
fixed_iso=""
guest_os="linux"
img=""
iso=""
@ -690,6 +700,11 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then
echo "ERROR! No disk_img defined."
exit 1
fi
# Backwards compatibility for ${driver_iso}
if [ -n "${driver_iso}" ] && [ -z "${fixed_iso}" ]; then
fixed_iso="${driver_iso}"
fi
else
echo "ERROR! Virtual machine configuration not found."
usage

View File

@ -121,9 +121,11 @@ function make_vm_dir() {
function make_vm_config() {
local IMAGE_FILE=""
local ISO_FILE=""
local IMAGE_TYPE=""
local GUEST=""
IMAGE_FILE="${1}"
ISO_FILE="${2}"
if [[ "${OS}" == *"ubuntu"* ]]; then
GUEST="linux"
IMAGE_TYPE="iso"
@ -142,8 +144,8 @@ guest_os="${GUEST}"
disk_img="${VM_PATH}/disk.qcow2"
${IMAGE_TYPE}="${VM_PATH}/${IMAGE_FILE}"
EOF
if [ -n "${2}" ]; then
echo "driver_iso=${VM_PATH}/${2}" >> "${OS}-${RELEASE}.conf"
if [ -n "${ISO_FILE}" ]; then
echo "fixed_iso=\"${VM_PATH}/${ISO_FILE}\"" >> "${OS}-${RELEASE}.conf"
fi
fi
}