style(quickemu): correctly indent case statements

This commit is contained in:
Martin Wimpress 2024-05-09 02:09:23 +01:00 committed by Martin Wimpress
parent d7cc6e8115
commit da6aa9fb2c
1 changed files with 384 additions and 409 deletions

View File

@ -299,14 +299,10 @@ function vm_boot() {
if [ -e /sys/devices/system/cpu/smt/control ] && [ "${GUEST_CPU_CORES}" -ge 2 ]; then
HOST_CPU_SMT=$(cat /sys/devices/system/cpu/smt/control)
case ${HOST_CPU_SMT} in
on)
GUEST_CPU_THREADS=2
GUEST_CPU_LOGICAL_CORES=$(( GUEST_CPU_CORES / GUEST_CPU_THREADS ))
;;
*)
GUEST_CPU_THREADS=1
GUEST_CPU_LOGICAL_CORES=${GUEST_CPU_CORES}
;;
on) GUEST_CPU_THREADS=2
GUEST_CPU_LOGICAL_CORES=$(( GUEST_CPU_CORES / GUEST_CPU_THREADS ));;
*) GUEST_CPU_THREADS=1
GUEST_CPU_LOGICAL_CORES=${GUEST_CPU_CORES};;
esac
else
GUEST_CPU_THREADS=1
@ -400,8 +396,7 @@ function vm_boot() {
# https://bugzilla.redhat.com/show_bug.cgi?id=1929357#c5
if [ -n "${EFI_CODE}" ] || [ ! -e "${EFI_CODE}" ]; then
case ${secureboot} in
on)
# shellcheck disable=SC2054,SC2140
on) # shellcheck disable=SC2054,SC2140
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.secboot.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
"/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
"/usr/share/OVMF/x64/OVMF_CODE.secboot.fd","/usr/share/OVMF/x64/OVMF_VARS.fd" \
@ -409,10 +404,8 @@ function vm_boot() {
"/usr/share/qemu/ovmf-x86_64-smm-ms-code.bin","/usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin" \
"/usr/share/qemu/edk2-x86_64-secure-code.fd","/usr/share/qemu/edk2-x86_64-code.fd" \
"/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd","/usr/share/edk2-ovmf/x64/OVMF_VARS.fd"
)
;;
*)
# shellcheck disable=SC2054,SC2140
);;
*) # shellcheck disable=SC2054,SC2140
ovmfs=("/usr/share/OVMF/OVMF_CODE_4M.fd","/usr/share/OVMF/OVMF_VARS_4M.fd" \
"/usr/share/edk2/ovmf/OVMF_CODE.fd","/usr/share/edk2/ovmf/OVMF_VARS.fd" \
"/usr/share/OVMF/OVMF_CODE.fd","/usr/share/OVMF/OVMF_VARS.fd" \
@ -421,8 +414,7 @@ function vm_boot() {
"/usr/share/qemu/ovmf-x86_64-4m-code.bin","/usr/share/qemu/ovmf-x86_64-4m-vars.bin" \
"/usr/share/qemu/edk2-x86_64-code.fd","/usr/share/qemu/edk2-x86_64-code.fd" \
"/usr/share/edk2-ovmf/x64/OVMF_CODE.fd","/usr/share/edk2-ovmf/x64/OVMF_VARS.fd"
)
;;
);;
esac
# Attempt each EFI_CODE file one by one, selecting the corresponding code and vars
# when an existing file is found.
@ -517,10 +509,8 @@ function vm_boot() {
MACHINE_TYPE="pc"
case ${guest_os} in
kolibrios) NET_DEVICE="rtl8139";;
reactos)
NET_DEVICE="e1000"
KEYBOARD="ps2"
;;
reactos) NET_DEVICE="e1000"
KEYBOARD="ps2";;
esac
;;
macos)
@ -540,24 +530,21 @@ function vm_boot() {
else
echo "ERROR! macOS ${macos_release} requires a CPU with SSE 4.2 and AVX2 support."
exit 1
fi
;;
fi;;
catalina|big-sur|monterey)
if check_cpu_flag sse4_2; then
CPU="-cpu Haswell-v4,kvm=on,vendor=GenuineIntel,+avx,+sse,+sse2,+sse3,+sse4.2,vmware-cpuid-freq=on"
else
echo "ERROR! macOS ${macos_release} requires a CPU with SSE 4.2 support."
exit 1
fi
;;
fi;;
*)
if check_cpu_flag sse4_1; then
CPU="-cpu Penryn,kvm=on,vendor=GenuineIntel,+avx,+sse,+sse2,+sse3,+sse4.1,vmware-cpuid-freq=on"
else
echo "ERROR! macOS ${macos_release} requires a CPU with SSE 4.1 support."
exit 1
fi
;;
fi;;
esac
# https://www.techpowerup.com/cpu-specs/xeon-w-2140b.c2953 8 cores 16 threads # skylake server
@ -595,24 +582,21 @@ function vm_boot() {
BALLOON=""
MAC_DISK_DEV="virtio-blk-pci"
NET_DEVICE="vmxnet3"
USB_HOST_PASSTHROUGH_CONTROLLER="usb-ehci"
;;
USB_HOST_PASSTHROUGH_CONTROLLER="usb-ehci";;
big-sur|monterey|ventura|sonoma)
BALLOON="-device virtio-balloon"
MAC_DISK_DEV="virtio-blk-pci"
NET_DEVICE="virtio-net"
USB_HOST_PASSTHROUGH_CONTROLLER="nec-usb-xhci"
GUEST_TWEAKS="${GUEST_TWEAKS} -global nec-usb-xhci.msi=off"
USB_CONTROLLER="xhci"
;;
USB_CONTROLLER="xhci";;
*)
# Backwards compatibility if no macos_release is specified.
# Also safe catch all for High Sierra and Mojave
BALLOON=""
MAC_DISK_DEV="ide-hd,bus=ahci.2"
NET_DEVICE="vmxnet3"
USB_HOST_PASSTHROUGH_CONTROLLER="usb-ehci"
;;
USB_HOST_PASSTHROUGH_CONTROLLER="usb-ehci";;
esac
if [ -z "${disk_size}" ]; then
@ -644,14 +628,12 @@ function vm_boot() {
fi
SMM="on"
;;
*)
CPU="-cpu host,kvm=on"
*) CPU="-cpu host,kvm=on"
NET_DEVICE="rtl8139"
if [ -z "${disk_size}" ]; then
disk_size="32G"
fi
echo "WARNING! Unrecognised guest OS: ${guest_os}"
;;
echo "WARNING! Unrecognised guest OS: ${guest_os}";;
esac
echo " - Disk: ${disk_img} (${disk_size})"
@ -660,8 +642,7 @@ function vm_boot() {
mkdir -p "${VMDIR}" 2>/dev/null
case ${preallocation} in
off|metadata|falloc|full) true;;
*)
echo "ERROR! ${preallocation} is an unsupported disk preallocation option."
*) echo "ERROR! ${preallocation} is an unsupported disk preallocation option."
exit 1;;
esac
@ -772,10 +753,8 @@ function vm_boot() {
DISPLAY_DEVICE="vmware-svga"
elif [ "${guest_os}" == "linux" ]; then
case ${OUTPUT} in
none|spice|spice-app)
DISPLAY_DEVICE="virtio-gpu";;
*)
DISPLAY_DEVICE="virtio-vga";;
none|spice|spice-app) DISPLAY_DEVICE="virtio-gpu";;
*) DISPLAY_DEVICE="virtio-vga";;
esac
elif [ "${guest_os}" == "macos" ]; then
# qxl-vga supports seamless mouse and sane resolutions if only one scanout
@ -943,8 +922,7 @@ function vm_boot() {
# Reference: https://gitlab.gnome.org/GNOME/phodav/-/issues/5
echo " - WebDAV: On guest: build spice-webdavd (https://gitlab.gnome.org/GNOME/phodav/-/merge_requests/24)"
echo " - WebDAV: On guest: Finder -> Connect to Server -> http://localhost:9843/"
fi
;;
fi;;
*)
echo " - WebDAV: On guest: dav://localhost:9843/";;
esac
@ -1546,16 +1524,13 @@ function monitor_send_cmd {
case "${monitor_channel}" in
socket)
echo -e " - Sending: ${MSG}"
echo -e "${MSG}" | socat -,shut-down unix-connect:"${VM_MONITOR_SOCKETPATH}" 2>&1 > /dev/null
;;
echo -e "${MSG}" | socat -,shut-down unix-connect:"${VM_MONITOR_SOCKETPATH}" 2>&1 > /dev/null;;
telnet)
echo -e " - Sending: ${MSG}"
echo -e "${MSG}" | socat - tcp:"${MONITOR_TELNET_HOST}":"${MONITOR_TELNET_PORT}" 2>&1 > /dev/null
;;
echo -e "${MSG}" | socat - tcp:"${MONITOR_TELNET_HOST}":"${MONITOR_TELNET_PORT}" 2>&1 > /dev/null;;
*)
echo "ERROR! This should never happen!"
exit 1
;;
exit 1;;
esac
return 0