Unverified Commit 242b16a7 authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

runInLinuxVM: apply Qemu's vCPU limit (#386224)

parents ee2c1b83 64503c86
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -247,11 +247,17 @@ rec {
    eval "$preVM"

    if [ "$enableParallelBuilding" = 1 ]; then
      QEMU_NR_VCPUS=0
      if [ ''${NIX_BUILD_CORES:-0} = 0 ]; then
        QEMU_OPTS+=" -smp cpus=$(nproc)"
        QEMU_NR_VCPUS="$(nproc)"
      else
        QEMU_OPTS+=" -smp cpus=$NIX_BUILD_CORES"
        QEMU_NR_VCPUS="$NIX_BUILD_CORES"
      fi
      # qemu only supports 255 vCPUs (see error from `qemu-system-x86_64 -smp 256`)
      if [ "$QEMU_NR_VCPUS" -gt 255 ]; then
        QEMU_NR_VCPUS=255
      fi
      QEMU_OPTS+=" -smp cpus=$QEMU_NR_VCPUS"
    fi

    # Write the command to start the VM to a file so that the user can