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

feat: Enable hypervisor flag (#543)

parent f0307e9a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -45,15 +45,16 @@ else
  progress="--progress=dot:giga"
fi

msg="Downloading $base..."
info "$msg" && html "$msg"
msg="Downloading $base"
info "$msg..." && html "$msg..."

/run/progress.sh "$TMP" "" "Downloading $base ([P])..." &
/run/progress.sh "$TMP" "" "$msg ([P])..." &
{ wget "$BOOT" -O "$TMP" -q --timeout=30 --show-progress "$progress"; rc=$?; } || :

fKill "progress.sh"

(( rc == 4 )) && error "Failed to download $BOOT , network failure!" && exit 60
(( rc == 8 )) && error "Failed to download $BOOT , server issued an error response!" && exit 60
(( rc != 0 )) && error "Failed to download $BOOT , reason: $rc" && exit 60
[ ! -s "$TMP" ] && error "Failed to download $BOOT" && exit 61

+23 −17
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ fi

if [[ "$KVM" != [Nn]* ]]; then

  CPU_FEATURES="kvm=on,l3-cache=on"
  CPU_FEATURES="kvm=on,l3-cache=on,+hypervisor"
  KVM_OPTS=",accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard"

  if [ -z "$CPU_MODEL" ]; then
@@ -64,18 +64,34 @@ if [[ "$KVM" != [Nn]* ]]; then
    fi
  fi

  if [[ "$HV" != [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then

    HV_FEATURES="+hypervisor,hv_passthrough"

  if grep -qw "svm" <<< "$flags"; then

    # AMD processor

    if grep -qw "tsc_scale" <<< "$flags"; then
        HV_FEATURES="$HV_FEATURES,+invtsc"
      CPU_FEATURES="$CPU_FEATURES,+invtsc"
    fi

  else

    # Intel processor

    vmx=$(sed -ne '/^vmx flags/s/^.*: //p' /proc/cpuinfo)

    if grep -qw "tsc_scaling" <<< "$vmx"; then
      CPU_FEATURES="$CPU_FEATURES,+invtsc"
    fi

  fi
  
  if [[ "$HV" != [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then

    HV_FEATURES="hv_passthrough"

    if grep -qw "svm" <<< "$flags"; then

      # AMD processor

      if ! grep -qw "avic" <<< "$flags"; then
        HV_FEATURES="$HV_FEATURES,-hv-avic"
      fi
@@ -86,12 +102,6 @@ if [[ "$KVM" != [Nn]* ]]; then

      # Intel processor

      vmx=$(sed -ne '/^vmx flags/s/^.*: //p' /proc/cpuinfo)

      if grep -qw "tsc_scaling" <<< "$vmx"; then
        HV_FEATURES="$HV_FEATURES,+invtsc"
      fi

      if ! grep -qw "apicv" <<< "$vmx"; then
        HV_FEATURES="$HV_FEATURES,-hv-apicv,-hv-evmcs"
      else
@@ -111,7 +121,7 @@ if [[ "$KVM" != [Nn]* ]]; then
else

  KVM_OPTS=""
  CPU_FEATURES="l3-cache=on"
  CPU_FEATURES="l3-cache=on,+hypervisor"

  if [[ "$ARCH" == "amd64" ]]; then
    KVM_OPTS=" -accel tcg,thread=multi"
@@ -128,10 +138,6 @@ else

  CPU_FEATURES="$CPU_FEATURES,+ssse3,+sse4.1,+sse4.2"

  if [[ "$HV" != [Nn]* ]] && [[ "${BOOT_MODE,,}" == "windows"* ]]; then
    CPU_FEATURES="$CPU_FEATURES,+hypervisor"
  fi

fi

if [ -z "$CPU_FLAGS" ]; then