From patchwork Fri Jul 2 16:31:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 1500183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GGgYS1DBXz9shx for ; Sat, 3 Jul 2021 02:30:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230020AbhGBQdH (ORCPT ); Fri, 2 Jul 2021 12:33:07 -0400 Received: from foss.arm.com ([217.140.110.172]:50562 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhGBQdH (ORCPT ); Fri, 2 Jul 2021 12:33:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75F261063; Fri, 2 Jul 2021 09:30:34 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C464B3F5A1; Fri, 2 Jul 2021 09:30:31 -0700 (PDT) From: Alexandru Elisei To: drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, kvm-ppc@vger.kernel.org, david@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andre.przywara@arm.com, maz@kernel.org, vivek.gautam@arm.com Subject: [kvm-unit-tests RFC PATCH 1/5] lib: arm: Print test exit status on exit if chr-testdev is not available Date: Fri, 2 Jul 2021 17:31:18 +0100 Message-Id: <20210702163122.96110-2-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702163122.96110-1-alexandru.elisei@arm.com> References: <20210702163122.96110-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org The arm64 tests can be run under kvmtool, which doesn't emulate a chr-testdev device. In preparation for adding run script support for kvmtool, print the test exit status so the scripts can pick it up and correctly mark the test as pass or fail. Signed-off-by: Alexandru Elisei --- lib/chr-testdev.h | 1 + lib/arm/io.c | 10 +++++++++- lib/chr-testdev.c | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/chr-testdev.h b/lib/chr-testdev.h index ffd9a851aa9b..09b4b424670e 100644 --- a/lib/chr-testdev.h +++ b/lib/chr-testdev.h @@ -11,4 +11,5 @@ */ extern void chr_testdev_init(void); extern void chr_testdev_exit(int code); +extern bool chr_testdev_available(void); #endif diff --git a/lib/arm/io.c b/lib/arm/io.c index 343e10822263..9e62b571a91b 100644 --- a/lib/arm/io.c +++ b/lib/arm/io.c @@ -125,7 +125,15 @@ extern void halt(int code); void exit(int code) { - chr_testdev_exit(code); + if (chr_testdev_available()) { + chr_testdev_exit(code); + } else { + /* + * Print the test return code in the format used by chr-testdev + * so the runner script can parse it. + */ + printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1); + } psci_system_off(); halt(code); __builtin_unreachable(); diff --git a/lib/chr-testdev.c b/lib/chr-testdev.c index b3c641a833fe..301e73a6c064 100644 --- a/lib/chr-testdev.c +++ b/lib/chr-testdev.c @@ -68,3 +68,8 @@ void chr_testdev_init(void) in_vq = vqs[0]; out_vq = vqs[1]; } + +bool chr_testdev_available(void) +{ + return vcon != NULL; +} From patchwork Fri Jul 2 16:31:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 1500184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GGgYV183kz9sXN for ; Sat, 3 Jul 2021 02:30:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbhGBQdJ (ORCPT ); Fri, 2 Jul 2021 12:33:09 -0400 Received: from foss.arm.com ([217.140.110.172]:50576 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhGBQdJ (ORCPT ); Fri, 2 Jul 2021 12:33:09 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0F76011B3; Fri, 2 Jul 2021 09:30:37 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B29973F5A1; Fri, 2 Jul 2021 09:30:34 -0700 (PDT) From: Alexandru Elisei To: drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, kvm-ppc@vger.kernel.org, david@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andre.przywara@arm.com, maz@kernel.org, vivek.gautam@arm.com Subject: [kvm-unit-tests RFC PATCH 2/5] scripts: Rename run_qemu_status -> run_test_status Date: Fri, 2 Jul 2021 17:31:19 +0100 Message-Id: <20210702163122.96110-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702163122.96110-1-alexandru.elisei@arm.com> References: <20210702163122.96110-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org kvm-unit-tests will get support for running tests automatically under kvmtool, rename the function to make it more generic. Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones Reviewed-by: Thomas Huth --- scripts/arch-run.bash | 2 +- powerpc/run | 2 +- s390x/run | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 5997e384019b..8ceed53ed7f8 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -69,7 +69,7 @@ run_qemu () return $ret } -run_qemu_status () +run_test_status () { local stdout ret diff --git a/powerpc/run b/powerpc/run index 597ab96ed8a8..312576006504 100755 --- a/powerpc/run +++ b/powerpc/run @@ -31,4 +31,4 @@ command="$(migration_cmd) $(timeout_cmd) $command" # to fixup the fixup below by parsing the true exit code from the output. # The second fixup is also a FIXME, because once we add chr-testdev # support for powerpc, we won't need the second fixup. -run_qemu_status $command "$@" +run_test_status $command "$@" diff --git a/s390x/run b/s390x/run index c615caa1b772..5a4bb3bda805 100755 --- a/s390x/run +++ b/s390x/run @@ -28,4 +28,4 @@ command+=" -kernel" command="$(timeout_cmd) $command" # We return the exit code via stdout, not via the QEMU return code -run_qemu_status $command "$@" +run_test_status $command "$@" From patchwork Fri Jul 2 16:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 1500185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GGgYY0knsz9ssP for ; Sat, 3 Jul 2021 02:30:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbhGBQdM (ORCPT ); Fri, 2 Jul 2021 12:33:12 -0400 Received: from foss.arm.com ([217.140.110.172]:50600 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbhGBQdM (ORCPT ); Fri, 2 Jul 2021 12:33:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E304139F; Fri, 2 Jul 2021 09:30:39 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C5793F5A1; Fri, 2 Jul 2021 09:30:37 -0700 (PDT) From: Alexandru Elisei To: drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, kvm-ppc@vger.kernel.org, david@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andre.przywara@arm.com, maz@kernel.org, vivek.gautam@arm.com Subject: [kvm-unit-tests RFC PATCH 3/5] run_tests.sh: Add kvmtool support Date: Fri, 2 Jul 2021 17:31:20 +0100 Message-Id: <20210702163122.96110-4-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702163122.96110-1-alexandru.elisei@arm.com> References: <20210702163122.96110-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Modify run_tests.sh to use kvmtool instead of qemu to run tests when kvm-unit-tests has been configured with --target=kvmtool. Example invocation: $ ./configure --target=kvmtool $ make clean && make $ ./run_scripts.sh A custom location for the kvmtool binary can be set using the environment variable KVMTOOL: $ KVMTOOL=/path/to/kvmtool/binary ./run_scripts.sh Standalone test support is absent, but will be added in subsequent patches. Signed-off-by: Alexandru Elisei --- scripts/arch-run.bash | 48 ++++++++++++++++-- scripts/runtime.bash | 94 ++++++++++++++++++++++++++++------ scripts/mkstandalone.sh | 5 ++ arm/run | 110 ++++++++++++++++++++++++---------------- run_tests.sh | 11 +++- 5 files changed, 204 insertions(+), 64 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 8ceed53ed7f8..b916b0e79aca 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -69,16 +69,39 @@ run_qemu () return $ret } +run_kvmtool() +{ + local stdout errors ret sig + + # kvmtool doesn't allow an initrd argument with --firmware, but configure + # sets CONFIG_ERRATA_FORCE in lib/config.h for the kvmtool target. + + # stdout to {stdout}, stderr to $errors and stderr + exec {stdout}>&1 + errors=$("${@}" >(tee /dev/stderr) > /dev/fd/$stdout) + ret=$? + exec {stdout}>&- + + # ret=0 success, everything else is failure. + return $ret +} + run_test_status () { - local stdout ret + local stdout ret exit_status exec {stdout}>&1 - lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout)) + if [ "$TARGET" = "kvmtool" ]; then + lines=$(run_kvmtool "$@" > >(tee /dev/fd/$stdout)) + exit_status=0 + else + lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout)) + exit_status=1 + fi ret=$? exec {stdout}>&- - if [ $ret -eq 1 ]; then + if [ $ret -eq $exit_status ]; then testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') if [ "$testret" ]; then if [ $testret -eq 1 ]; then @@ -193,6 +216,25 @@ search_qemu_binary () export PATH=$save_path } +search_kvmtool_binary () +{ + local lkvm kvmtool + + for lkvm in ${KVMTOOL:-lkvm vm lkvm-static}; do + if $lkvm --help 2>/dev/null | grep -q 'The most commonly used'; then + kvmtool="$lkvm" + break + fi + done + + if [ -z "$kvmtool" ]; then + echo "A kvmtool binary was not found." >&2 + echo "You can set a custom location by using the KVMTOOL= environment variable." >&2 + return 2 + fi + command -v $kvmtool +} + initrd_create () { if [ "$ENVIRON_DEFAULT" = "yes" ]; then diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 132389c7dd59..23b238a6ab6f 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -12,14 +12,19 @@ extract_summary() tail -3 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/'"$cr"'\{0,1\}$/)/' } -# We assume that QEMU is going to work if it tried to load the kernel +# We assume that QEMU/kvmtool is going to work if it tried to load the kernel premature_failure() { local log="$(eval $(get_cmdline _NO_FILE_4Uhere_) 2>&1)" - echo "$log" | grep "_NO_FILE_4Uhere_" | - grep -q -e "could not \(load\|open\) kernel" -e "error loading" && - return 1 + if [ "$TARGET" = "kvmtool" ]; then + echo "$log" | grep "Fatal: unable to load firmware image _NO_FILE_4Uhere_" && + return 1 + else + echo "$log" | grep "_NO_FILE_4Uhere_" | + grep -q -e "could not \(load\|open\) kernel" -e "error loading" && + return 1 + fi RUNTIME_log_stderr <<< "$log" @@ -30,7 +35,14 @@ premature_failure() get_cmdline() { local kernel=$1 - echo "TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" + local smp_param + + if [ "$TARGET" = "kvmtool" ]; then + smp_param="--cpus $smp" + else + smp_param="-smp $smp" + fi + echo "TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel $smp_param $opts" } skip_nodefault() @@ -70,6 +82,35 @@ function find_word() grep -Fq " $1 " <<< " $2 " } +fixup_kvmtool_opts() +{ + local opts=$1 + local groups=$2 + local gic + local gic_version + + if find_word "pmu" $groups; then + opts+=" --pmu" + fi + + if find_word "its" $groups; then + gic_version=3 + gic="gicv3-its" + elif [[ "$opts" =~ -machine\ *gic-version=(2|3) ]]; then + gic_version="${BASH_REMATCH[1]}" + gic="gicv$gic_version" + fi + + if [ -n "$gic" ]; then + opts=${opts/-machine gic-version=$gic_version/} + opts+=" --irqchip=$gic" + fi + + opts=${opts/-append/--params} + + echo "$opts" +} + function run() { local testname="$1" @@ -105,7 +146,12 @@ function run() return 2 fi - if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then + if [ "$TARGET" = "kvmtool" ]; then + if [ -n "$accel" ] && [ "$accel" != "kvm" ]; then + print_result "SKIP" $testname "" "$accel not supported by kvmtool" + return 2 + fi + elif [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then print_result "SKIP" $testname "" "$accel only, but ACCEL=$ACCEL" return 2 elif [ -n "$ACCEL" ]; then @@ -126,6 +172,10 @@ function run() done fi + if [ "$TARGET" = "kvmtool" ]; then + opts=$(fixup_kvmtool_opts "$opts" "$groups") + fi + last_line=$(premature_failure > >(tail -1)) && { print_result "SKIP" $testname "" "$last_line" return 77 @@ -165,13 +215,25 @@ function run() # # Probe for MAX_SMP, in case it's less than the number of host cpus. # -# This probing currently only works for ARM, as x86 bails on another -# error first. Also, this probing isn't necessary for any ARM hosts -# running kernels later than v4.3, i.e. those including ef748917b52 -# "arm/arm64: KVM: Remove 'config KVM_ARM_MAX_VCPUS'". So, at some -# point when maintaining the while loop gets too tiresome, we can -# just remove it... -while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ - |& grep -qi 'exceeds max CPUs'; do - MAX_SMP=$((MAX_SMP >> 1)) -done +# This probing currently only works for ARM, as x86 bails on another error +# first. Also, this probing isn't necessary for any ARM hosts running kernels +# later than v4.3, i.e. those including ef748917b52 "arm/arm64: KVM: Remove +# 'config KVM_ARM_MAX_VCPUS'". So, at some point when maintaining the while loop +# gets too tiresome, we can just remove it... +# +# We don't need this check for kvmtool, as kvmtool will automatically limit the +# number of VCPUs to what the host supports instead of exiting with an error. +# kvmtool prints a message when that happens, but it's harmless and the chance +# of running a kernel so old that the number of VCPUs is smaller than the number +# of physical CPUs is vanishingly small. +# +# For qemu this check is still needed. For qemu-system-aarch64 version 6.0.0, +# using TCG, the maximum number of VCPUs that mach-virt supports is 8. If a test +# is running on a recent x86 machine, there's a fairly good chance that more +# than 8 logical CPUs are available. +if [ "$TARGET" = "qemu" ]; then + while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ + |& grep -qi 'exceeds max CPUs'; do + MAX_SMP=$((MAX_SMP >> 1)) + done +fi diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index cefdec30cb33..16f461c06842 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -95,6 +95,11 @@ function mkstandalone() echo Written $standalone. } +if [ "$TARGET" = "kvmtool" ]; then + echo "Standalone tests not supported with kvmtool" + exit 2 +fi + if [ "$ENVIRON_DEFAULT" = "yes" ] && [ "$ERRATATXT" ] && [ ! -f "$ERRATATXT" ]; then echo "$ERRATATXT not found. (ERRATATXT=$ERRATATXT)" >&2 exit 2 diff --git a/arm/run b/arm/run index a390ca5ae0ba..cc5890e7fec4 100755 --- a/arm/run +++ b/arm/run @@ -8,59 +8,81 @@ if [ -z "$STANDALONE" ]; then source config.mak source scripts/arch-run.bash fi -processor="$PROCESSOR" -ACCEL=$(get_qemu_accelerator) || - exit $? +run_test_qemu() +{ + processor="$PROCESSOR" -qemu=$(search_qemu_binary) || - exit $? + ACCEL=$(get_qemu_accelerator) || + exit $? -if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then - echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." - exit 2 -fi + qemu=$(search_qemu_binary) || + exit $? -M='-machine virt' + if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then + echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." + exit 2 + fi -if [ "$ACCEL" = "kvm" ]; then - if $qemu $M,\? 2>&1 | grep gic-version > /dev/null; then - M+=',gic-version=host' - fi - if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then - processor="host" - if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then - processor+=",aarch64=off" - fi - fi -fi + M='-machine virt' -if [ "$ARCH" = "arm" ]; then - M+=",highmem=off" -fi + if [ "$ACCEL" = "kvm" ]; then + if $qemu $M,\? 2>&1 | grep gic-version > /dev/null; then + M+=',gic-version=host' + fi + if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then + processor="host" + if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then + processor+=",aarch64=off" + fi + fi + fi -if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then - echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." - exit 2 -fi + if [ "$ARCH" = "arm" ]; then + M+=",highmem=off" + fi -if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ - | grep backend > /dev/null; then - echo "$qemu doesn't support chr-testdev. Exiting." - exit 2 -fi + if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then + echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." + exit 2 + fi -chr_testdev='-device virtio-serial-device' -chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' + if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \ + | grep backend > /dev/null; then + echo "$qemu doesn't support chr-testdev. Exiting." + exit 2 + fi -pci_testdev= -if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then - pci_testdev="-device pci-testdev" -fi + chr_testdev='-device virtio-serial-device' + chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' + + pci_testdev= + if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then + pci_testdev="-device pci-testdev" + fi + + M+=",accel=$ACCEL" + command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" + command+=" -display none -serial stdio -kernel" + command="$(migration_cmd) $(timeout_cmd) $command" + + run_qemu $command "$@" +} + +run_test_kvmtool() +{ + kvmtool=$(search_kvmtool_binary) || + exit $? -M+=",accel=$ACCEL" -command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -command+=" -display none -serial stdio -kernel" -command="$(migration_cmd) $(timeout_cmd) $command" + local command="$(timeout_cmd) $kvmtool run --firmware " + run_test_status $command "$@" +} -run_qemu $command "$@" +case "$TARGET" in + "qemu") + run_test_qemu "$@" + ;; + "kvmtool") + run_test_kvmtool "$@" + ;; +esac diff --git a/run_tests.sh b/run_tests.sh index 65108e73a2c0..b010ee3ab348 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -26,7 +26,9 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] -t, --tap13 Output test results in TAP format Set the environment variable QEMU=/path/to/qemu-system-ARCH to -specify the appropriate qemu binary for ARCH-run. +specify the appropriate qemu binary for ARCH-run. For arm/arm64, kvmtool +is also supported and the environment variable KVMTOOL=/path/to/kvmtool +can be used to specify a custom location for the kvmtool binary. EOF } @@ -41,6 +43,13 @@ if [ $? -ne 4 ]; then exit 1 fi +if [ "$TARGET" = "kvmtool" ]; then + if [ -n "$ACCEL" ] && [ "$ACCEL" != "kvm" ]; then + echo "kvmtool supports only the kvm accelerator" + exit 1 + fi +fi + only_tests="" args=`getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*` [ $? -ne 0 ] && exit 2; From patchwork Fri Jul 2 16:31:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 1500186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GGgYb1qRvz9t23 for ; Sat, 3 Jul 2021 02:30:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbhGBQdO (ORCPT ); Fri, 2 Jul 2021 12:33:14 -0400 Received: from foss.arm.com ([217.140.110.172]:50624 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbhGBQdO (ORCPT ); Fri, 2 Jul 2021 12:33:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 37C101424; Fri, 2 Jul 2021 09:30:42 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA9953F5A1; Fri, 2 Jul 2021 09:30:39 -0700 (PDT) From: Alexandru Elisei To: drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, kvm-ppc@vger.kernel.org, david@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andre.przywara@arm.com, maz@kernel.org, vivek.gautam@arm.com Subject: [kvm-unit-tests RFC PATCH 4/5] scripts: Generate kvmtool standalone tests Date: Fri, 2 Jul 2021 17:31:21 +0100 Message-Id: <20210702163122.96110-5-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702163122.96110-1-alexandru.elisei@arm.com> References: <20210702163122.96110-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Add support for the standalone target when running kvm-unit-tests under kvmtool. Example command line invocation: $ ./configure --target=kvmtool $ make clean && make standalone Signed-off-by: Alexandru Elisei --- scripts/mkstandalone.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index 16f461c06842..d84bdb7e278c 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -44,6 +44,10 @@ generate_test () config_export ARCH_NAME config_export PROCESSOR + if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "arm" ]; then + config_export TARGET + fi + echo "echo BUILD_HEAD=$(cat build-head)" if [ ! -f $kernel ]; then @@ -59,7 +63,7 @@ generate_test () echo 'export FIRMWARE' fi - if [ "$ENVIRON_DEFAULT" = "yes" ] && [ "$ERRATATXT" ]; then + if [ "$TARGET" != "kvmtool" ] && [ "$ENVIRON_DEFAULT" = "yes" ] && [ "$ERRATATXT" ]; then temp_file ERRATATXT "$ERRATATXT" echo 'export ERRATATXT' fi @@ -95,12 +99,8 @@ function mkstandalone() echo Written $standalone. } -if [ "$TARGET" = "kvmtool" ]; then - echo "Standalone tests not supported with kvmtool" - exit 2 -fi - -if [ "$ENVIRON_DEFAULT" = "yes" ] && [ "$ERRATATXT" ] && [ ! -f "$ERRATATXT" ]; then +if [ "$TARGET" != "kvmtool" ] && [ "$ENVIRON_DEFAULT" = "yes" ] && \ + [ "$ERRATATXT" ] && [ ! -f "$ERRATATXT" ]; then echo "$ERRATATXT not found. (ERRATATXT=$ERRATATXT)" >&2 exit 2 fi From patchwork Fri Jul 2 16:31:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 1500187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GGgYf2CSxz9sXN for ; Sat, 3 Jul 2021 02:30:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbhGBQdR (ORCPT ); Fri, 2 Jul 2021 12:33:17 -0400 Received: from foss.arm.com ([217.140.110.172]:50634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbhGBQdR (ORCPT ); Fri, 2 Jul 2021 12:33:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CDA23143B; Fri, 2 Jul 2021 09:30:44 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 75C643F5A1; Fri, 2 Jul 2021 09:30:42 -0700 (PDT) From: Alexandru Elisei To: drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, kvm-ppc@vger.kernel.org, david@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: andre.przywara@arm.com, maz@kernel.org, vivek.gautam@arm.com Subject: [kvm-unit-tests RFC PATCH 5/5] configure: Ignore --erratatxt when --target=kvmtool Date: Fri, 2 Jul 2021 17:31:22 +0100 Message-Id: <20210702163122.96110-6-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702163122.96110-1-alexandru.elisei@arm.com> References: <20210702163122.96110-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org kvmtool runs a test using the -f/--firmware argument, which doesn't load an initrd, making specifying an errata file useless. Instead, configure forces all erratas to be enabled via the CONFIG_ERRATA_FORCE define in lib/config.h. Forbid the --erratatxt option when kvm-unit-tests is configured for kvmtool and let the user know that all erratas are enabled by default. Signed-off-by: Alexandru Elisei --- I'm not sure if printing an error is too strong here and a simple warning would suffice. Suggestions welcome! configure | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 395c809c9c02..acd288239f80 100755 --- a/configure +++ b/configure @@ -24,7 +24,8 @@ u32_long= wa_divide= target= errata_force=0 -erratatxt="$srcdir/errata.txt" +erratatxt_default="$srcdir/errata.txt" +erratatxt="_NO_FILE_4Uhere_" host_key_document= page_size= earlycon= @@ -50,7 +51,8 @@ usage() { enable or disable the generation of a default environ when no environ is provided by the user (enabled by default) --erratatxt=FILE specify a file to use instead of errata.txt. Use - '--erratatxt=' to ensure no file is used. + '--erratatxt=' to ensure no file is used. This option is + invalid for arm/arm64 when target=kvmtool. --host-key-document=HOST_KEY_DOCUMENT Specify the machine-specific host-key document for creating a PVM image with 'genprotimg' (s390x only) @@ -147,11 +149,6 @@ if [ -n "$host_key_document" ] && [ ! -f "$host_key_document" ]; then exit 1 fi -if [ "$erratatxt" ] && [ ! -f "$erratatxt" ]; then - echo "erratatxt: $erratatxt does not exist or is not a regular file" - exit 1 -fi - arch_name=$arch [ "$arch" = "aarch64" ] && arch="arm64" [ "$arch_name" = "arm64" ] && arch_name="aarch64" @@ -184,6 +181,21 @@ else fi fi +if [ "$target" = "kvmtool" ]; then + if [ "$erratatxt" ] && [ "$erratatxt" != "_NO_FILE_4Uhere_" ]; then + echo "--erratatxt is not supported for target=kvmtool (all erratas enabled by default)" + usage + fi +else + if [ "$erratatxt" = "_NO_FILE_4Uhere_" ]; then + erratatxt=$erratatxt_default + fi + if [ "$erratatxt" ] && [ ! -f "$erratatxt" ]; then + echo "erratatxt: $erratatxt does not exist or is not a regular file" + exit 1 + fi +fi + [ -z "$processor" ] && processor="$arch" if [ "$processor" = "arm64" ]; then