feat: Support USB storage (#416)

This commit is contained in:
Kroese 2024-02-01 10:40:35 +01:00 committed by GitHub
parent 9182422b82
commit ba9c79bd4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 14 deletions

View file

@ -22,7 +22,7 @@ case "${BOOT_MODE,,}" in
VARS="OVMF_VARS_4M.ms.fd"
;;
windows_legacy)
USB="usb-ehci"
USB="usb-ehci,id=ehci"
BOOT_OPTS=""
;;
legacy)

View file

@ -1,9 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: "${MACHINE:="q35"}"
: "${USB:="qemu-xhci"}"
: "${SERIAL:="mon:stdio"}"
: "${USB:="qemu-xhci,id=xhci"}"
: "${MONITOR:="telnet:localhost:7100,server,nowait,nodelay"}"
DEF_OPTS="-nodefaults"

View file

@ -15,20 +15,19 @@ DISK_OPTS="$DISK_OPTS -device virtio-scsi-pci,id=scsi0,iothread=io2,addr=0x5"
DISK_OPTS="$DISK_OPTS -device scsi-cd,bus=scsi0.0,drive=cdrom0,bootindex=$BOOT_INDEX"
BOOT="$STORAGE/$BASE"
if [ -f "$BOOT" ]; then
DISK_OPTS="$DISK_OPTS -drive id=cdrom0,if=none,format=raw,readonly=on,file=$BOOT"
else
DISK_OPTS="$DISK_OPTS -drive id=cdrom0,if=none,format=raw,readonly=on,file=/dev/null"
fi
[ ! -f "$BOOT" ] && BOOT="/dev/null"
DISK_OPTS="$DISK_OPTS -drive id=cdrom0,if=none,format=raw,readonly=on,file=$BOOT"
DRIVERS="$STORAGE/drivers.iso"
[ ! -f "$DRIVERS" ] && DRIVERS="/run/drivers.iso"
if [ -f "$DRIVERS" ]; then
DISK_OPTS="$DISK_OPTS \
-drive id=cdrom1,if=none,format=raw,readonly=on,file=$DRIVERS \
-device ide-cd,drive=cdrom1"
DISK_OPTS="$DISK_OPTS -drive id=cdrom1,if=none,format=raw,readonly=on,file=$DRIVERS"
if [[ "${MACHINE,,}" != "pc-q35-2"* ]]; then
DISK_OPTS="$DISK_OPTS -device ide-cd,drive=cdrom1"
else
DISK_OPTS="$DISK_OPTS -device usb-storage,bus=ehci.0,drive=cdrom1"
fi
fi
fmt2ext() {
@ -356,7 +355,7 @@ createDevice () {
local result="-drive file=$DISK_FILE,if=none,id=drive-$DISK_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
if [[ "${MACHINE,,}" == "pc-q35-2"* ]]; then
result="$result -device virtio-blk-pci,scsi=off,bus=pcie.0,addr=$DISK_ADDRESS,drive=drive-$DISK_ID,id=$DISK_ID,iothread=io2,bootindex=$DISK_INDEX"

View file

@ -18,6 +18,7 @@ echo
: "${BOOT:=""}" # URL of the ISO file
: "${DEBUG:="N"}" # Disable debugging
: "${MACHINE:="q35"}" # Machine selection
: "${ALLOCATE:=""}" # Preallocate diskspace
: "${ARGUMENTS:=""}" # Extra QEMU parameters
: "${CPU_CORES:="1"}" # Amount of CPU cores