From 012a6d20d43aabd8a4f023e63cec8282f9ab66ac Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sat, 31 Jul 2021 15:43:38 -0700 Subject: [PATCH] boot-qemu.sh: Add '--smp' flag The help text is fairly self explanatory. Signed-off-by: Nathan Chancellor --- README.txt | 8 ++++++++ boot-qemu.sh | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 020efd6..1e21442 100644 --- a/README.txt +++ b/README.txt @@ -69,6 +69,14 @@ Optional parameters: This can be useful for reproducing certain bugs but booting kernels will be much slower. + -s | --smp: + By default, the script does not specify a number of cores for the + QEMU machine, which usually means it spawns with only one core. + Certain features such as the KCSAN KUnit tests require multiple cores + to work so this value will be used for the number of cores for the + virtual machine. It can be more than the number of processors on your + host machine. + -t | --timeout: By default, the timeout command waits 3 minutes before killing the QEMU machine. Depending on the power of the host machine, this might diff --git a/boot-qemu.sh b/boot-qemu.sh index 0685041..2ab7de6 100755 --- a/boot-qemu.sh +++ b/boot-qemu.sh @@ -77,6 +77,10 @@ function parse_parameters() { KVM=false ;; + -s | --smp) + shift && SMP=${1} + ;; + -t | --timeout) shift && TIMEOUT=${1} ;; @@ -187,7 +191,7 @@ function setup_qemu_args() { if ${DEBIAN}; then # Booting is so slow without these QEMU_RAM=2G - QEMU_ARCH_ARGS+=(-smp 4) + QEMU_ARCH_ARGS+=(-smp "${SMP:-4}") fi QEMU=(qemu-system-aarch64) ;; @@ -277,7 +281,7 @@ function setup_qemu_args() { -cpu host -d "unimp,guest_errors" -enable-kvm - -smp "$(nproc)" + -smp "${SMP:-$(nproc)}" ) else QEMU_ARCH_ARGS=(-cpu Nehalem) @@ -342,6 +346,9 @@ function invoke_qemu() { fi # Removing trailing space for aesthetic purposes [[ -n ${APPEND_STRING} ]] && QEMU+=(-append "${APPEND_STRING%* }") + if [[ -n ${SMP} ]] && ! echo "${QEMU_ARCH_ARGS[*]}" | grep -q "smp"; then + QEMU+=(-smp "${SMP}") + fi if ${GDB:=false}; then while true; do if lsof -i:1234 &>/dev/null; then