Added support for changing virtual sound hardware

Added new configuration file option "sound_card" and new command-line
switch "--sound-card" to change the virtual sound hardware. Allowed
options are "intel-hda" (default), "ac97", "es1370", "sb16", and "none".
Also changed default sound card for Solaris to "ac97" and for FreeDOS to
"sb16".
This commit is contained in:
Chase Covello 2023-04-28 15:15:49 -07:00
parent 8ee0d3a207
commit 532837efb5

View File

@ -235,6 +235,7 @@ function vm_boot() {
local MAC_DISK_DEV="${MAC_DISK_DEV:-ide-hd,bus=ahci.2}"
local NET_DEVICE="${NET_DEVICE:-virtio-net}"
local OSK=""
local SOUND=""
local SMM="${SMM:-off}"
local USB_HOST_PASSTHROUGH_CONTROLLER="qemu-xhci"
local VGA=""
@ -484,11 +485,13 @@ function vm_boot() {
if [ "${guest_os}" == "freedos" ] ; then
# fix for #382
SMM="on"
SOUND_CARD="sb16"
fi
if [[ "${guest_os}" == *"solaris" ]]; then
MACHINE_TYPE="pc"
USB_CONTROLLER="xhci"
SOUND_CARD="ac97"
fi
if [ -z "${disk_size}" ]; then
@ -788,6 +791,16 @@ function vm_boot() {
# Add fullscreen options
VIDEO="${VGA} ${VIDEO} ${FULLSCREEN}"
# Build the sound hardware configuration
if [ "${SOUND_CARD}" == "intel-hda" ]; then
SOUND="-device intel-hda -device hda-duplex,audiodev=audio0"
elif [ "${SOUND_CARD}" == "ac97" ] || [ "${SOUND_CARD}" == "es1370" ] || [ "${SOUND_CARD}" == "sb16" ]; then
SOUND="-device ${SOUND_CARD},audiodev=audio0"
elif [ "${SOUND_CARD}" == "none" ]; then
SOUND=""
fi
echo " - Sound: ${SOUND_CARD}"
# Set the hostname of the VM
local NET="user,hostname=${VMNAME}"
@ -916,7 +929,7 @@ function vm_boot() {
-m ${RAM_VM} ${BALLOON}
${VIDEO} -display ${DISPLAY_RENDER}
-audiodev ${AUDIO_DEV}
-device intel-hda -device hda-duplex,audiodev=audio0
${SOUND}
-rtc base=localtime,clock=host,driftfix=slew)
# Only enable SPICE is using SPICE display
@ -1336,6 +1349,7 @@ function usage() {
echo " --keyboard_layout <layout> : Set keyboard layout."
echo " --mouse <type> : Set mouse. @Options: 'tablet' (default), 'ps2', 'usb', 'virtio'"
echo " --usb-controller <type> : Set usb-controller. @Options: 'ehci' (default), 'xhci', 'none'"
echo " --sound-card <type> : Set sound card. @Options: 'intel-hda' (default), 'ac97', 'es1370', 'sb16', 'none'"
echo " --extra_args <arguments> : Pass additional arguments to qemu"
echo " --version : Print version"
exit 1
@ -1348,6 +1362,13 @@ function display_param_check() {
fi
}
function sound_card_param_check() {
if [ "${SOUND_CARD}" != "intel-hda" ] && [ "${SOUND_CARD}" != "ac97" ] && [ "${SOUND_CARD}" != "es1370" ] && [ "${SOUND_CARD}" != "sb16" ] && [ "${SOUND_CARD}" != "none" ]; then
echo "ERROR! Requested sound card '${SOUND_CARD}' is not recognised."
exit 1
fi
}
function viewer_param_check() {
if [ "${VIEWER}" != "none" ] && [ "${VIEWER}" != "spicy" ] && [ "${VIEWER}" != "remote-viewer" ]; then
echo "ERROR! Requested viewer '${VIEWER}' is not recognised."
@ -1468,6 +1489,8 @@ keyboard="usb"
keyboard_layout="en-us"
# options: ps2, usb, tablet, virtio
mouse="tablet"
# options: intel-hda, ac97, es1370, sb16, none
sound_card="intel-hda"
BRAILLE=""
DELETE_DISK=0
@ -1505,6 +1528,7 @@ KEYBOARD_LAYOUT=""
MOUSE=""
USB_CONTROLLER=""
EXTRA_ARGS=""
SOUND_CARD=""
# shellcheck disable=SC2155
readonly LAUNCHER=$(basename "${0}")
@ -1642,6 +1666,10 @@ else
EXTRA_ARGS="${2}"
shift;
shift;;
-sound-card|--sound-card)
SOUND_CARD="${2}"
shift;
shift;;
-version|--version)
echo "${VERSION}"
exit;;
@ -1744,6 +1772,11 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then
exit 1
fi
if [ -z "${SOUND_CARD}" ]; then
SOUND_CARD="${sound_card}"
fi
sound_card_param_check
# Check if vm is already run
VM_PID=0
VM_UP=0