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

fix: Disable Hyper-V in Windows Legacy mode (#601)

parent 074058ad
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ case "${BOOT_MODE,,}" in
    VARS="OVMF_VARS_4M.ms.fd"
    ;;
  "windows_legacy" )
    HV="N"
    SECURE="on"
    BOOT_DESC=" (legacy)"
    USB="usb-ehci,id=ehci"
@@ -114,8 +115,8 @@ if [[ "$TPM" == [Yy1]* ]]; then
      BOOT_OPTS+=" -chardev socket,id=chrtpm,path=/run/swtpm-sock"
      BOOT_OPTS+=" -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0"
    fi
  fi

  fi
fi

return 0
+39 −17
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@ set -Eeuo pipefail

# Docker environment variables

: "${DISK_IO:="native"}"          # I/O Mode, can be set to 'native', 'threads' or 'io_turing'
: "${DISK_IO:="native"}"          # I/O Mode, can be set to 'native', 'threads' or 'io_uring'
: "${DISK_FMT:=""}"               # Disk file format, can be set to "raw" (default) or "qcow2"
: "${DISK_TYPE:=""}"              # Device type to be used, choose "ide", "usb", "blk" or "scsi"
: "${DISK_TYPE:=""}"              # Device type to be used, "sata", "nvme", "blk" or "scsi"
: "${DISK_FLAGS:=""}"             # Specifies the options for use with the qcow2 disk format
: "${DISK_CACHE:="none"}"         # Caching mode, can be set to 'writeback' for better performance
: "${DISK_DISCARD:="on"}"         # Controls whether unmap (TRIM) commands are passed to the host.
@@ -363,6 +363,7 @@ createDevice () {
  local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"

  case "${DISK_TYPE,,}" in
    "none" ) ;;  
    "auto" )
      echo "$result"
      ;;
@@ -371,7 +372,12 @@ createDevice () {
      -device usb-storage,drive=${DISK_ID}${index}"
      echo "$result"
      ;;
    "ide" )
    "nvme" )
      result+=",if=none \
      -device nvme,drive=${DISK_ID}${index},serial=deadbeaf${DISK_INDEX}"
      echo "$result"
      ;;      
    "ide" | "sata" )
      result+=",if=none \
      -device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
      -device ide-hd,drive=${DISK_ID},bus=ahci$DISK_INDEX.0,rotation_rate=$DISK_ROTATION${index}"
@@ -406,6 +412,7 @@ addMedia () {
  local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=raw,cache=unsafe,readonly=on,media=cdrom"

  case "${DISK_TYPE,,}" in
    "none" ) ;;
    "auto" )
      echo "$result"
      ;;
@@ -414,7 +421,12 @@ addMedia () {
      -device usb-storage,drive=${DISK_ID}${index},removable=on"
      echo "$result"
      ;;
    "ide" )
    "nvme" )
      result+=",if=none \
      -device nvme,drive=${DISK_ID}${index},serial=deadbeaf${DISK_INDEX}"
      echo "$result"
      ;;
    "ide" | "sata" )
      result+=",if=none \
      -device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
      -device ide-cd,drive=${DISK_ID},bus=ahci${DISK_INDEX}.0${index}"
@@ -532,23 +544,33 @@ html "Initializing disks..."
[ -z "${DISK_NAME:-}" ] && DISK_NAME="data"

case "${DISK_TYPE,,}" in
  "ide" | "usb" | "scsi" | "blk" | "auto" ) ;;
  "ide" | "sata" | "nvme" | "usb" | "scsi" | "blk" | "auto" | "none" ) ;;
  * ) error "Invalid DISK_TYPE specified, value \"$DISK_TYPE\" is not recognized!" && exit 80 ;;
esac

if [ -z "${MEDIA_TYPE:-}" ]; then
case "${MACHINE,,}" in
  "virt" )
      MEDIA_TYPE="usb" ;;
    FALLBACK="usb" ;;
  "pc-q35-2"* | "pc-i440fx-2"* )
      MEDIA_TYPE="auto" ;;
    FALLBACK="auto" ;;
  * )
      MEDIA_TYPE="ide" ;;
    FALLBACK="ide" ;;
esac

if [ -z "${MEDIA_TYPE:-}" ]; then
  if [[ "${BOOT_MODE:-}" != "windows"* ]]; then
    if [[ "${DISK_TYPE,,}" == "blk" ]]; then
      MEDIA_TYPE="$FALLBACK"
    else
      MEDIA_TYPE="$DISK_TYPE"
    fi
  else
    MEDIA_TYPE="$FALLBACK"
  fi
fi

case "${MEDIA_TYPE,,}" in
  "ide" | "usb" | "scsi" | "blk" | "auto" ) ;;
  "ide" | "sata" | "nvme" | "usb" | "scsi" | "blk" | "auto" | "none" ) ;;
  * ) error "Invalid MEDIA_TYPE specified, value \"$MEDIA_TYPE\" is not recognized!" && exit 80 ;;
esac

@@ -569,14 +591,14 @@ DRIVERS="/drivers.iso"
[ ! -f "$DRIVERS" ] || [ ! -s "$DRIVERS" ] && DRIVERS="$STORAGE/drivers.iso"

if [ -f "$DRIVERS" ] && [ -s "$DRIVERS" ]; then
  DISK_OPTS+=$(addMedia "$DRIVERS" "$MEDIA_TYPE" "" "0x6")
  DISK_OPTS+=$(addMedia "$DRIVERS" "$FALLBACK" "" "0x6")
fi

RESCUE="/start.iso"
[ ! -f "$RESCUE" ] || [ ! -s "$RESCUE" ] && RESCUE="$STORAGE/start.iso"

if [ -f "$RESCUE" ] && [ -s "$RESCUE" ]; then
  DISK_OPTS+=$(addMedia "$RESCUE" "$MEDIA_TYPE" "1" "0x6")
  DISK_OPTS+=$(addMedia "$RESCUE" "$FALLBACK" "1" "0x6")
fi

DISK1_FILE="$STORAGE/${DISK_NAME}"