feat: Support USB storage (#416)
This commit is contained in:
parent
9182422b82
commit
ba9c79bd4c
4 changed files with 13 additions and 14 deletions
|
@ -22,7 +22,7 @@ case "${BOOT_MODE,,}" in
|
||||||
VARS="OVMF_VARS_4M.ms.fd"
|
VARS="OVMF_VARS_4M.ms.fd"
|
||||||
;;
|
;;
|
||||||
windows_legacy)
|
windows_legacy)
|
||||||
USB="usb-ehci"
|
USB="usb-ehci,id=ehci"
|
||||||
BOOT_OPTS=""
|
BOOT_OPTS=""
|
||||||
;;
|
;;
|
||||||
legacy)
|
legacy)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
: "${MACHINE:="q35"}"
|
|
||||||
: "${USB:="qemu-xhci"}"
|
|
||||||
: "${SERIAL:="mon:stdio"}"
|
: "${SERIAL:="mon:stdio"}"
|
||||||
|
: "${USB:="qemu-xhci,id=xhci"}"
|
||||||
: "${MONITOR:="telnet:localhost:7100,server,nowait,nodelay"}"
|
: "${MONITOR:="telnet:localhost:7100,server,nowait,nodelay"}"
|
||||||
|
|
||||||
DEF_OPTS="-nodefaults"
|
DEF_OPTS="-nodefaults"
|
||||||
|
|
21
src/disk.sh
21
src/disk.sh
|
@ -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"
|
DISK_OPTS="$DISK_OPTS -device scsi-cd,bus=scsi0.0,drive=cdrom0,bootindex=$BOOT_INDEX"
|
||||||
|
|
||||||
BOOT="$STORAGE/$BASE"
|
BOOT="$STORAGE/$BASE"
|
||||||
|
[ ! -f "$BOOT" ] && BOOT="/dev/null"
|
||||||
if [ -f "$BOOT" ]; then
|
DISK_OPTS="$DISK_OPTS -drive id=cdrom0,if=none,format=raw,readonly=on,file=$BOOT"
|
||||||
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
|
|
||||||
|
|
||||||
DRIVERS="$STORAGE/drivers.iso"
|
DRIVERS="$STORAGE/drivers.iso"
|
||||||
[ ! -f "$DRIVERS" ] && DRIVERS="/run/drivers.iso"
|
[ ! -f "$DRIVERS" ] && DRIVERS="/run/drivers.iso"
|
||||||
|
|
||||||
if [ -f "$DRIVERS" ]; then
|
if [ -f "$DRIVERS" ]; then
|
||||||
DISK_OPTS="$DISK_OPTS \
|
DISK_OPTS="$DISK_OPTS -drive id=cdrom1,if=none,format=raw,readonly=on,file=$DRIVERS"
|
||||||
-drive id=cdrom1,if=none,format=raw,readonly=on,file=$DRIVERS \
|
if [[ "${MACHINE,,}" != "pc-q35-2"* ]]; then
|
||||||
-device ide-cd,drive=cdrom1"
|
DISK_OPTS="$DISK_OPTS -device ide-cd,drive=cdrom1"
|
||||||
|
else
|
||||||
|
DISK_OPTS="$DISK_OPTS -device usb-storage,bus=ehci.0,drive=cdrom1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fmt2ext() {
|
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"
|
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"
|
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"
|
||||||
|
|
||||||
|
@ -446,7 +445,7 @@ addDevice () {
|
||||||
local OPTS
|
local OPTS
|
||||||
OPTS=$(createDevice "$DISK_ID" "$DISK_DEV" "$DISK_INDEX" "$DISK_ADDRESS")
|
OPTS=$(createDevice "$DISK_ID" "$DISK_DEV" "$DISK_INDEX" "$DISK_ADDRESS")
|
||||||
DISK_OPTS="$DISK_OPTS $OPTS"
|
DISK_OPTS="$DISK_OPTS $OPTS"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ echo
|
||||||
|
|
||||||
: "${BOOT:=""}" # URL of the ISO file
|
: "${BOOT:=""}" # URL of the ISO file
|
||||||
: "${DEBUG:="N"}" # Disable debugging
|
: "${DEBUG:="N"}" # Disable debugging
|
||||||
|
: "${MACHINE:="q35"}" # Machine selection
|
||||||
: "${ALLOCATE:=""}" # Preallocate diskspace
|
: "${ALLOCATE:=""}" # Preallocate diskspace
|
||||||
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
||||||
: "${CPU_CORES:="1"}" # Amount of CPU cores
|
: "${CPU_CORES:="1"}" # Amount of CPU cores
|
||||||
|
|
Loading…
Reference in a new issue