Unverified Commit ba9c79bd authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Support USB storage (#416)

parent 9182422b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −2
Original line number Diff line number Diff line
#!/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"
+10 −11
Original line number Diff line number Diff line
@@ -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
[ ! -f "$BOOT" ] && BOOT="/dev/null"
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"
[ ! -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"

+1 −0
Original line number Diff line number Diff line
@@ -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