From patchwork Mon Jan 20 16:42:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945243 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F4B8372; Mon, 20 Jan 2025 16:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391417; cv=none; b=pFYh97xg+kKhGxbfvDX0Z0jSc9gK6yZ+o9yb5+o5ENLNsDjyc/YODRbQUtqmBb6GuUWBd9I9JPr1iHzRbbOY1sY5bYOSx1vK5wr2ZnF6QiIv0cDgi5t077W+wT0kbrW6vsUGnw8ubsbbC4B0zEhQ2Ojit9no1bwxdpGS8Goz61U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391417; c=relaxed/simple; bh=+4IglO/GI3XVPZc5VCSog3ieaKkrOLPa+81+1UtZvkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dHda4+SLKBhxH2+idU4X65NZ7M3/ExNmJaJRevX73jJi8H/VQpjDghI7t27MotLSP9bfccjkOmwobiT+qgGqFPQfAel7WJO2IiKEn2j5aEqFnRBoVhZZD7SOki8BPavofcIWZKLc1b8DoatuvPqVW98dLWFlLlvAVdq3CwFgd6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 22C0E1063; Mon, 20 Jan 2025 08:44:04 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D2A93F5A1; Mon, 20 Jan 2025 08:43:32 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 01/18] run_tests: Document --probe-maxsmp argument Date: Mon, 20 Jan 2025 16:42:59 +0000 Message-ID: <20250120164316.31473-2-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 5dd20ec76ea63 ("runtime: Update MAX_SMP probe") added the --probe-maxmp argument, but the help message for run_tests.sh wasn't updated. Document --probe-maxsmp. Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones --- run_tests.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 152323ffc8a2..f30b6dbd131c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -17,14 +17,15 @@ cat < X-Patchwork-Id: 13945244 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD37C372; Mon, 20 Jan 2025 16:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391421; cv=none; b=DDvwxqg5o/vUyVaUsTnveakAqI8vGsEqpafSt7ySKV3lDR+j11j7aeoHkbhyIE3w5HbFIsfGiTVTRvVgXA8Fpa67Fcq3OiuMgoCTVqOyJsiC+K2xYZiO+bwuv/fqZtmtF0OFhCQJ2/uqbdOGvLz1r7iahw+iwVt5sszDj06FnIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391421; c=relaxed/simple; bh=GfhxiJqzI2tLPyXNWcy2aEygOIOs18xCVccC1B0xNr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+FDmf54X1b+DOs117veaO6KHV1Qailfr84on63WMr+lixiFYQu4N4tqQEyGrkqO36JMhMhzECvydTS5edLXDhj0eGIY+T3fes8CSaXjjrcv0vH9VmfFIJOVbA+bwBnCbAHzfN+KBgL7obZPJznQ06n9eNo6k77jg7CYF2SVrH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 BDF701688; Mon, 20 Jan 2025 08:44:07 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EEF843F5A1; Mon, 20 Jan 2025 08:43:35 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com, Andrew Jones Subject: [kvm-unit-tests PATCH v2 02/18] Document environment variables Date: Mon, 20 Jan 2025 16:43:00 +0000 Message-ID: <20250120164316.31473-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document the environment variables that influence how a test is executed by the run_tests.sh test runner. Suggested-by: Andrew Jones Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones --- docs/unittests.txt | 5 ++++- run_tests.sh | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/unittests.txt b/docs/unittests.txt index c4269f6230c8..dbc2c11e3b59 100644 --- a/docs/unittests.txt +++ b/docs/unittests.txt @@ -88,7 +88,8 @@ timeout ------- timeout = -Optional timeout in seconds, after which the test will be killed and fail. +Optional timeout in seconds, after which the test will be killed and fail. Can +be overwritten with the TIMEOUT= environment variable. check ----- @@ -99,3 +100,5 @@ can contain multiple files to check separated by a space, but each check parameter needs to be of the form = The path and value cannot contain space, =, or shell wildcard characters. + +Can be overwritten with the CHECK environment variable with the same syntax. diff --git a/run_tests.sh b/run_tests.sh index f30b6dbd131c..23d81b2caaa1 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -27,9 +27,15 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] [-l] -l, --list Only output all tests list --probe-maxsmp Update the maximum number of VCPUs supported by host -Set the environment variable QEMU=/path/to/qemu-system-ARCH to -specify the appropriate qemu binary for ARCH-run. - +The following environment variables are used: + + QEMU Path to QEMU binary for ARCH-run + ACCEL QEMU accelerator to use, e.g. 'kvm', 'hvf' or 'tcg' + ACCEL_PROPS Extra argument to ACCEL + MACHINE QEMU machine type + TIMEOUT Timeout duration for the timeout(1) command + CHECK Overwrites the 'check' unit test parameter (see + docs/unittests.txt) EOF } From patchwork Mon Jan 20 16:43:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945245 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 864FB1E9B3F; Mon, 20 Jan 2025 16:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391425; cv=none; b=XHK6n+LvbKcexpLrxPj27xj3X1CuweiYq8vfbVO8M+vLacmPi32tcTLLU5ClHTAs2VtAC7sea8JihAN7CjO6kWrCe4UbATmuVTz9V1QPHsj8xsoM3VKxWxJdVMxc6aivSNudU5uK3iih/1g4JDJZ+z1A/GePgxKgzQvw5LIWo58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391425; c=relaxed/simple; bh=njIcaoieuawVSW7Wnwt14YqgJAcPuRLFfdXOhQmctqE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UaIiUuCDHTIgs8HipunNc322maBH75iqH8YaVTrbZMFJ7dTQAMB+lm11qG5lDLN9PICbV9c0yVc2R3kFgP321dsQc67tp4vdW2fB/6s7n6CTkiJPS0J9QmhrB/No6aSlNh/fuWL7Ew0KsbP1ma9hv62M+RwmlaSTe4mZM1Ts0YE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 402B1106F; Mon, 20 Jan 2025 08:44:11 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 990FB3F5A1; Mon, 20 Jan 2025 08:43:39 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 03/18] scripts: Refuse to run the tests if not configured for qemu Date: Mon, 20 Jan 2025 16:43:01 +0000 Message-ID: <20250120164316.31473-4-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Arm and arm64 support running the tests under kvmtool. Unsurprisingly, kvmtool and qemu have a different command line syntax for configuring and running a virtual machine. On top of that, when kvm-unit-tests has been configured to run under kvmtool (via ./configure --target=kvmtool), the early UART address changes, and if then the tests are run with qemu, this warning is displayed: WARNING: early print support may not work. Found uart at 0x9000000, but early base is 0x1000000. At the moment, the only way to run a test under kvmtool is manually, as no script has any knowledge of how to invoke kvmtool. Also, unless one looks at the logs, it's not obvious that the test runner is using qemu to run the tests, and not kvmtool. To avoid any confusion for unsuspecting users, refuse to run a test via the testing scripts when kvm-unit-tests has been configured for kvmtool. There are four different ways to run a test using the test infrastructure: with run_tests.sh, by invoking arm/run or arm/efi/run with the correct parameters (only the arm directory is mentioned here because the tests can be configured for kvmtool only on arm and arm64), and by creating standalone tests. Add a check in each of these locations for the supported virtual machine manager. Signed-off-by: Alexandru Elisei --- arm/efi/run | 8 ++++++++ arm/run | 9 +++++++++ run_tests.sh | 8 ++++++++ scripts/mkstandalone.sh | 8 ++++++++ 4 files changed, 33 insertions(+) diff --git a/arm/efi/run b/arm/efi/run index 8f41fc02df31..916f4c4deef6 100755 --- a/arm/efi/run +++ b/arm/efi/run @@ -12,6 +12,14 @@ fi source config.mak source scripts/arch-run.bash +case "$TARGET" in +qemu) + ;; +*) + echo "$0 does not support '$TARGET'" + exit 2 +esac + if [ -f /usr/share/qemu-efi-aarch64/QEMU_EFI.fd ]; then DEFAULT_UEFI=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd elif [ -f /usr/share/edk2/aarch64/QEMU_EFI.silent.fd ]; then diff --git a/arm/run b/arm/run index efdd44ce86a7..6db32cf09c88 100755 --- a/arm/run +++ b/arm/run @@ -8,6 +8,15 @@ if [ -z "$KUT_STANDALONE" ]; then source config.mak source scripts/arch-run.bash fi + +case "$TARGET" in +qemu) + ;; +*) + echo "'$TARGET' not supported" + exit 3 +esac + processor="$PROCESSOR" if [ "$QEMU" ] && [ -z "$ACCEL" ] && diff --git a/run_tests.sh b/run_tests.sh index 23d81b2caaa1..61480d0c05ed 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -100,6 +100,14 @@ while [ $# -gt 0 ]; do shift done +case "$TARGET" in +qemu) + ;; +*) + echo "$0 does not support '$TARGET'" + exit 2 +esac + # RUNTIME_log_file will be configured later if [[ $tap_output == "no" ]]; then process_test_output() { cat >> $RUNTIME_log_file; } diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index 2318a85f0706..4de97056e641 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -7,6 +7,14 @@ fi source config.mak source scripts/common.bash +case "$TARGET" in +qemu) + ;; +*) + echo "'$TARGET' not supported for standlone tests" + exit 2 +esac + temp_file () { local var="$1" From patchwork Mon Jan 20 16:43:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945246 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5B171E9B3F; Mon, 20 Jan 2025 16:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391428; cv=none; b=mCJvAYl9RXcJhiQHWbUPNJy/V8MmgDC7W8mxnEPLEzZPs+NOAsnowcYLnwkcMmaQmsQWhW1HzJfCiDCV11ynvY4F6OuArXxhFl343evHO1ocnC0fVFy1ywbNhWl6y/16c88bBVqvUgtsGGbbHa/22qS3wsnT+Dd0gtrckR46zrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391428; c=relaxed/simple; bh=KvMHBn7pkSGF8D0elsiBrOYyhjrWX3YWu5SMwaWBV3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rp28pmv8dIOMMrGHz7PUXlyBTdoReLMTa9PmsnCR6O21G0jGrspDEWDVjaYPdnn/Fw/GYoUBWrs/oxUPCzL3EasUSl9XOOPoxc2DBqgHda1fBFrxuTAfCFJJ31AzmtI0eg0ZYnRbMQ+eTBlcJs0ZMFYaixYtassCDDQzJfa5K+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 B3E66169C; Mon, 20 Jan 2025 08:44:14 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 191683F5A1; Mon, 20 Jan 2025 08:43:42 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 04/18] run_tests: Introduce unittest parameter 'qemu_params' Date: Mon, 20 Jan 2025 16:43:02 +0000 Message-ID: <20250120164316.31473-5-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Tests for the arm and arm64 architectures can also be run with kvmtool, and work is under way to have it supported by the run_tests.sh test runner. Not suprisingly, kvmtool has a different syntax than qemu when configuring and running a virtual machine. Add a new unittest parameter, 'qemu_params', with the goal to add a similar parameter for each virtual machine manager that run_tests.sh supports. 'qemu_params' and 'extra_params' are interchangeable, but it is expected that going forward new tests will use 'qemu_params'. A test should have only one of the two parameters. While we're at it, rename the variable opts to qemu_opts to match the new unit configuration name, and to make it easier to distinguish from the kvmtool parameters when they'll be added. Signed-off-by: Alexandru Elisei --- docs/unittests.txt | 17 +++++++++----- scripts/common.bash | 53 ++++++++++++++++++++++++++------------------ scripts/runtime.bash | 10 ++++----- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/docs/unittests.txt b/docs/unittests.txt index dbc2c11e3b59..3e1a9e563016 100644 --- a/docs/unittests.txt +++ b/docs/unittests.txt @@ -24,9 +24,9 @@ param = value format. Available parameters ==================== -Note! Some parameters like smp and extra_params modify how a test is run, -while others like arch and accel restrict the configurations in which the -test is run. +Note! Some parameters like smp and qemu_params/extra_params modify how a +test is run, while others like arch and accel restrict the configurations +in which the test is run. file ---- @@ -56,13 +56,18 @@ smp = Optional, the number of processors created in the machine to run the test. Defaults to 1. $MAX_SMP can be used to specify the maximum supported. -extra_params ------------- +qemu_params +----------- These are extra parameters supplied to the QEMU process. -append '...' can be used to pass arguments into the test case argv. Multiple parameters can be added, for example: -extra_params = -m 256 -append 'smp=2' +qemu_params = -m 256 -append 'smp=2' + +extra_params +------------ +Alias for 'qemu_params', supported for compatibility purposes. Use +'qemu_params' for new tests. groups ------ diff --git a/scripts/common.bash b/scripts/common.bash index 3aa557c8c03d..a40c28121b6a 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -1,5 +1,28 @@ source config.mak +function parse_opts() +{ + local opts="$1" + local fd="$2" + + while read -r -u $fd; do + #escape backslash newline, but not double backslash + if [[ $opts =~ [^\\]*(\\*)$'\n'$ ]]; then + if (( ${#BASH_REMATCH[1]} % 2 == 1 )); then + opts=${opts%\\$'\n'} + fi + fi + if [[ "$REPLY" =~ ^(.*)'"""'[:blank:]*$ ]]; then + opts+=${BASH_REMATCH[1]} + break + else + opts+=$REPLY$'\n' + fi + done + + echo "$opts" +} + function for_each_unittest() { local unittests="$1" @@ -7,7 +30,7 @@ function for_each_unittest() local testname local smp local kernel - local opts + local qemu_opts local groups local arch local machine @@ -22,12 +45,12 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" fi testname=$rematch smp=1 kernel="" - opts="" + qemu_opts="" groups="" arch="" machine="" @@ -38,24 +61,10 @@ function for_each_unittest() kernel=$TEST_DIR/${BASH_REMATCH[1]} elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then smp=${BASH_REMATCH[1]} - elif [[ $line =~ ^extra_params\ *=\ *'"""'(.*)$ ]]; then - opts=${BASH_REMATCH[1]}$'\n' - while read -r -u $fd; do - #escape backslash newline, but not double backslash - if [[ $opts =~ [^\\]*(\\*)$'\n'$ ]]; then - if (( ${#BASH_REMATCH[1]} % 2 == 1 )); then - opts=${opts%\\$'\n'} - fi - fi - if [[ "$REPLY" =~ ^(.*)'"""'[:blank:]*$ ]]; then - opts+=${BASH_REMATCH[1]} - break - else - opts+=$REPLY$'\n' - fi - done - elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then - opts=${BASH_REMATCH[1]} + elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *'"""'(.*)$ ]]; then + qemu_opts=$(parse_opts ${BASH_REMATCH[2]}$'\n' $fd) + elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *(.*)$ ]]; then + qemu_opts=${BASH_REMATCH[2]} elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then groups=${BASH_REMATCH[1]} elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then @@ -71,7 +80,7 @@ function for_each_unittest() fi done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 4b9c7d6b7c39..e5d661684ceb 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -34,7 +34,7 @@ premature_failure() get_cmdline() { local kernel=$1 - echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" + echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $qemu_opts" } skip_nodefault() @@ -80,7 +80,7 @@ function run() local groups="$2" local smp="$3" local kernel="$4" - local opts="$5" + local qemu_opts="$5" local arch="$6" local machine="$7" local check="${CHECK:-$8}" @@ -179,9 +179,9 @@ function run() echo $cmdline fi - # extra_params in the config file may contain backticks that need to be - # expanded, so use eval to start qemu. Use "> >(foo)" instead of a pipe to - # preserve the exit status. + # qemu_params/extra_params in the config file may contain backticks that + # need to be expanded, so use eval to start qemu. Use "> >(foo)" instead of + # a pipe to preserve the exit status. summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \ > >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary)) ret=$? From patchwork Mon Jan 20 16:43:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945247 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ED8F1E9B3F; Mon, 20 Jan 2025 16:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391431; cv=none; b=Vn4p8peCmBhcNrnbyp2f5wy9BU6ec+sZ6YXxdzp/Iyhefvjg1ztpadDsOE/1HDqKHhUo0NgFnok5z/kyAaw+M+25UU4rkPJYLwslU5UkQHd6eRK4Oq2tkeFFa3fsHkJYnxULjJtMJZhoEVe7GEY9B6VOyeFufzulRhC660hsgz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391431; c=relaxed/simple; bh=btUNxg9BkB+Z+r3FmdDIjdI3aDp8cLqkNvOD7MAjCEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hZNLPwgivWIQZE5gZnWCNoxhOg5+8Ymli7TrXB6JLrds3AFU6CpxH0kq9TmSM9zqXhnagabcIUsInqPkhTJc+W+wLxBr2mI6I/sYuwqebTBsv89Cyfv7vqc9wZQB6cokEeGXEYW5H5fnNvwjBo42UVvgTSLj2lplaGF0iPlGpBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 500531C0A; Mon, 20 Jan 2025 08:44:18 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C4353F5A1; Mon, 20 Jan 2025 08:43:46 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com, Alexandru Elisei Subject: [kvm-unit-tests PATCH v2 05/18] scripts: Rename run_qemu_status -> run_test_status Date: Mon, 20 Jan 2025 16:43:03 +0000 Message-ID: <20250120164316.31473-6-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alexandru Elisei For the arm/arm64 architectures, kvm-unit-tests can also be run using the kvmtool virtual machine manager. Rename run_qemu_status to run_test_status to make it more generic, in preparation to add support for kvmtool. Signed-off-by: Alexandru Elisei --- arm/run | 4 ++-- powerpc/run | 2 +- riscv/run | 4 ++-- s390x/run | 2 +- scripts/arch-run.bash | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arm/run b/arm/run index 6db32cf09c88..9b11feafffdd 100755 --- a/arm/run +++ b/arm/run @@ -85,9 +85,9 @@ command+=" -display none -serial stdio" command="$(migration_cmd) $(timeout_cmd) $command" if [ "$UEFI_SHELL_RUN" = "y" ]; then - ENVIRON_DEFAULT=n run_qemu_status $command "$@" + ENVIRON_DEFAULT=n run_test_status $command "$@" elif [ "$EFI_USE_ACPI" = "y" ]; then - run_qemu_status $command -kernel "$@" + run_test_status $command -kernel "$@" else run_qemu $command -kernel "$@" fi diff --git a/powerpc/run b/powerpc/run index 27abf1ef6a4d..9b5fbc1197ed 100755 --- a/powerpc/run +++ b/powerpc/run @@ -63,4 +63,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/riscv/run b/riscv/run index 73f2bf54dc32..2a846d361a4d 100755 --- a/riscv/run +++ b/riscv/run @@ -34,8 +34,8 @@ command+=" $mach $acc $firmware -cpu $processor " command="$(migration_cmd) $(timeout_cmd) $command" if [ "$UEFI_SHELL_RUN" = "y" ]; then - ENVIRON_DEFAULT=n run_qemu_status $command "$@" + ENVIRON_DEFAULT=n run_test_status $command "$@" else # We return the exit code via stdout, not via the QEMU return code - run_qemu_status $command -kernel "$@" + run_test_status $command -kernel "$@" fi diff --git a/s390x/run b/s390x/run index 34552c2747d4..9ecfaf983a3d 100755 --- a/s390x/run +++ b/s390x/run @@ -47,4 +47,4 @@ command+=" -kernel" command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command" # We return the exit code via stdout, not via the QEMU return code -run_qemu_status $command "$@" +run_test_status $command "$@" diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 8643bab3b252..d6eaf0ee5f09 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -75,7 +75,7 @@ run_qemu () return $ret } -run_qemu_status () +run_test_status () { local stdout ret From patchwork Mon Jan 20 16:43:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945248 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00DB71E9B3F; Mon, 20 Jan 2025 16:43:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391435; cv=none; b=rcfJfJZ1xxCaOcQkaKwev/+s5nFJDAVDUMjG5hentlXQ4wmHtM6WGZDVZxjE1j+RdxpjCTOaiypEpOOhK7bxwNyb0NII8DwZoRFn2JEdCXhTTSOnkFcGKEHvJREMZs6KYAj5rQnV8b2HH7jQl/0q0CA8OoKvkERablMtnJiLzgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391435; c=relaxed/simple; bh=jacWk6aUJYc+SCjwy2Kul2rVWQrs8XYtBgBQWT2mpVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oyAWW38t+kpIgaZprkIsewbzOfZRm+nCL1/x08O18AOAoXK/wWD+OO9M5ZiJyvtBVGn0F4AisxkJoMiO4elItYfFMgJxBFjYW9k0eFMIkefXckDtxbLVJzgrnm629bcmvmnBsImqT8Ds6NjZrKczu0hddC4M8XCYvEIu8vGy9Ik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 C18EE1CC4; Mon, 20 Jan 2025 08:44:21 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A9F03F5A1; Mon, 20 Jan 2025 08:43:50 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 06/18] scripts: Merge the qemu parameter -smp into $qemu_opts Date: Mon, 20 Jan 2025 16:43:04 +0000 Message-ID: <20250120164316.31473-7-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 kvmtool has a different command line parameter to specify the number of VCPUs (-c/--cpus). To make it easier to accommodate it, merge the qemu specific parameter -smp into $qemu_opts when passing it to the $RUNTIME_arch_run script. This is safe to do because the $RUNTIME_arch_run script, on all architectures, passes the parameters right back to run_qemu() et co, and do not treat individual parameters separately. Signed-off-by: Alexandru Elisei --- scripts/runtime.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/runtime.bash b/scripts/runtime.bash index e5d661684ceb..a89f2d10ab78 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -34,7 +34,8 @@ premature_failure() get_cmdline() { local kernel=$1 - echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $qemu_opts" + + echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel $qemu_opts" } skip_nodefault() @@ -87,6 +88,8 @@ function run() local accel="$9" local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default + qemu_opts="-smp $smp $qemu_opts" + if [ "${CONFIG_EFI}" == "y" ]; then kernel=${kernel/%.flat/.efi} fi From patchwork Mon Jan 20 16:43:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945249 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 295721EB9E1; Mon, 20 Jan 2025 16:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391438; cv=none; b=pi8r+Upwbksqkrh3SUo/eJuGsirqGxGmEbdY2vyuLtHvHjJJyJ8vL4EjuynJ+hodaW0VOT3SO5boy3HpMWFTnGbhT9iLrFGFHm49IMKQ9ndgE33BNV3HHmaHAJmMSTvveUvTiWDJczXCtXEysawMxczIVmzvVoVB46Ogmta4uhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391438; c=relaxed/simple; bh=+0z9ZcxM8BSGnL7S6xhZIDiNijF7rdoQ0wWPrMo55Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hYHwLq+X4HcmwVy9gKrc8Zf4gdopjKvyXOI1E8TqVedEWbG4POYxRlP/62tXGM9GM2NoUX0E9JhFDiMBblqmdShMOA/CoMZFFbaaNzRvn/q6rR+PL6F5QyWCvzS7QtY5W5DmEiuELZwGLpflrS2AS0dDijL8wcsqiLWUBES/yuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 3B32F1CE2; Mon, 20 Jan 2025 08:44:25 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 99F273F5A1; Mon, 20 Jan 2025 08:43:53 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 07/18] scripts: Introduce kvmtool_opts Date: Mon, 20 Jan 2025 16:43:05 +0000 Message-ID: <20250120164316.31473-8-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for supporting kvmtool, create and pass the variable 'kvmtool_opts' to the arch run script $RUNTIME_arch_run. Signed-off-by: Alexandru Elisei --- scripts/common.bash | 6 ++++-- scripts/runtime.bash | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/common.bash b/scripts/common.bash index a40c28121b6a..1b5e0d667841 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -37,6 +37,7 @@ function for_each_unittest() local check local accel local timeout + local kvmtool_opts local rematch exec {fd}<"$unittests" @@ -45,7 +46,7 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" fi testname=$rematch smp=1 @@ -57,6 +58,7 @@ function for_each_unittest() check="" accel="" timeout="" + kvmtool_opts="" elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then kernel=$TEST_DIR/${BASH_REMATCH[1]} elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then @@ -80,7 +82,7 @@ function for_each_unittest() fi done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index a89f2d10ab78..451b5585f010 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -35,7 +35,7 @@ get_cmdline() { local kernel=$1 - echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel $qemu_opts" + echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel $opts" } skip_nodefault() @@ -87,8 +87,16 @@ function run() local check="${CHECK:-$8}" local accel="$9" local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default - - qemu_opts="-smp $smp $qemu_opts" + local kvmtool_opts="${11}" + + case "$TARGET" in + qemu) + opts="-smp $smp $qemu_opts" + ;; + kvmtool) + opts="--cpus $smp $kvmtool_opts" + ;; + esac if [ "${CONFIG_EFI}" == "y" ]; then kernel=${kernel/%.flat/.efi} From patchwork Mon Jan 20 16:43:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945250 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D9621EB9E1; Mon, 20 Jan 2025 16:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391442; cv=none; b=Uz6x+GAB98GLN1EkGqb/0fqta/zl/0zwQ2s95RU+TioDYk3+JLSgGqj7xIGSI9Pw49+bkiz0S2nAn8kt0nBzWSwvTAoq5pZxlH1o2o3zaKG5RUriiQUlkj1WU0uZ2AeFYRBg3W92w4CmyXMFtRDUEcgGRBNgjtbj99CgumFePsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391442; c=relaxed/simple; bh=VRlmWOtKd0rzjKQg1nbsvS0WHqWKPiS/g0FGcXukalo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pR6YoUWhXWeRVMJKYsD2ZiOR/YjU79rxPpEe8nnNaEFbUJ8JsnO5BFSdbLK7QT3ifvWmve+KQQq3elFYheAN/TbGLvgbAytxl1vulueluDJgxt5ETODH1+ooZDBIh8zyAI5VQUtoFHzPUkFsts7qnrxlohh3UVi9eTiO8OhclO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 AA7381CE0; Mon, 20 Jan 2025 08:44:28 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 14D993F5A1; Mon, 20 Jan 2025 08:43:56 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 08/18] scripts/runtime: Detect kvmtool failure in premature_failure() Date: Mon, 20 Jan 2025 16:43:06 +0000 Message-ID: <20250120164316.31473-9-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 kvm-unit-tests assumes that if the VMM is able to get to where it tries to load the kernel, then the VMM and the configuration parameters will also work for running the test. All of this is done in premature_failure(). Teach premature_failure() about the kvmtool's error message when it fails to load the dummy kernel. Signed-off-by: Alexandru Elisei --- scripts/runtime.bash | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 451b5585f010..ee8a188b22ce 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -12,18 +12,27 @@ extract_summary() tail -5 | 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 the VMM is going to work if it tried to load the kernel premature_failure() { local log log="$(eval "$(get_cmdline _NO_FILE_4Uhere_)" 2>&1)" - echo "$log" | grep "_NO_FILE_4Uhere_" | - grep -q -e "[Cc]ould not \(load\|open\) kernel" \ - -e "error loading" \ - -e "failed to load" && - return 1 + case "$TARGET" in + qemu) + + echo "$log" | grep "_NO_FILE_4Uhere_" | + grep -q -e "[Cc]ould not \(load\|open\) kernel" \ + -e "error loading" \ + -e "failed to load" && + return 1 + ;; + kvmtool) + echo "$log" | grep "Fatal: Unable to open kernel _NO_FILE_4Uhere_" && + return 1 + ;; + esac RUNTIME_log_stderr <<< "$log" From patchwork Mon Jan 20 16:43:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945251 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 140C11EB9F7; Mon, 20 Jan 2025 16:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391445; cv=none; b=uJAyqumckMIll5TWWnQ61B4FwrW/oyMzQM/Aqt6A5GiEXTw0+iGX42Y5R8u3fnHOv59iDbex+l/PLvMVX2YyC6WvUjwO8H2a+jUW2+67VGyFHJJ76Sf/4QkUW60uYp6lVKRdKoHqbCbtDGtyzJWUslDXtvp6i5QktiRfXiuqOfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391445; c=relaxed/simple; bh=l+ue9QwjC4bgshR3VQ8gPW6MJGNAunyoEVncSkoXgiU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cBeRoVWJ6suEQqEnEc06XLYuH29FkdvfPRFXhd06KvGSsPHpxwuTuUTJADa0kbq0Z8dyOPXab9T0IdCMAcF8ei63WLgHgDw0+P5poJapqgd419GPqsdHbiCcud+I/y5bAXjZcQXB+7aVloR/6tmPlWNAQqEWlS8ZTN6qNP6LuuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 272631D13; Mon, 20 Jan 2025 08:44:32 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 837D33F5A1; Mon, 20 Jan 2025 08:44:00 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 09/18] scripts/runtime: Skip test when kvmtool and $accel is not KVM Date: Mon, 20 Jan 2025 16:43:07 +0000 Message-ID: <20250120164316.31473-10-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 kvmtool, unlike qemu, cannot emulate a different architecture than the host's, and as a result the only $accel parameter it can support is 'kvm'. Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones --- scripts/runtime.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/runtime.bash b/scripts/runtime.bash index ee8a188b22ce..55d58eef9c7c 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -153,6 +153,11 @@ function run() accel="$ACCEL" fi + if [[ "$TARGET" = kvmtool ]] && [[ -n "$accel" ]] && [[ "$accel" != "kvm" ]]; then + print_result "SKIP" $testname "" "kvmtool does not support $accel" + return 2 + fi + # check a file for a particular value before running a test # the check line can contain multiple files to check separated by a space # but each check parameter needs to be of the form = From patchwork Mon Jan 20 16:43:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945260 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CB9F1EB9F7; Mon, 20 Jan 2025 16:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391449; cv=none; b=ai14CVqm5rQ+Krwmyb7vTeUOLMx9kX9eLs9ugba46yMpdQQQjV1EkgnxzwvZGjJbyPgUZ4QSrIldLMHr9ijJX85NAOBgqahG9qcMtZ62SHD86p7RF9Vn2l203mmRf5So8UFLcHM/L7+xEusPSYuXM55D+RoHpDEKXTS6SnhVyzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391449; c=relaxed/simple; bh=guJ8SHnjnRQ7PAUSpfkyhXyfLTmNeo8YLg2jt5EEMEA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iEHp3mrN3gtyfs17J6V6Hb3GPtRD7NQqyPOgOkFsLqeEXLFFZU6WUPMjg379UZsHfl4K5AQQn8jJ9LuxoT81z+P4TGqou7agaiLU1XnjPgeFBM5DdNcH+5m4UIZVd0azmnx6q8cY4QjbDUyqDqZJSijLHACD5lcjkMCnHHiCElQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 9854F1D14; Mon, 20 Jan 2025 08:44:35 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0131C3F5A1; Mon, 20 Jan 2025 08:44:03 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 10/18] scripts/arch-run: Add support for kvmtool Date: Mon, 20 Jan 2025 16:43:08 +0000 Message-ID: <20250120164316.31473-11-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add two new functions, search_kvmtool_binary(), which, like the name suggests, searches for the location of the kvmtool binary, and run_kvmtool(), which runs a test with kvmtool as the VMM. initrd_create() has also been modified to use the kvmtool syntax for supplying an initrd, which is --initrd (two dashes instead of the single dash that qemu uses). arm/run does not know how to use these functions yet, but this will be added in a subsequent patch. Signed-off-by: Alexandru Elisei --- scripts/arch-run.bash | 94 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index d6eaf0ee5f09..34f633cade01 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -75,16 +75,47 @@ run_qemu () return $ret } +run_kvmtool () +{ + local stdout errors ret sig + + initrd_create || return $? + + echo -n "$@" + [ "$ENVIRON_DEFAULT" = "yes" ] && echo -n " #" + echo " $INITRD" + + # stdout to {stdout}, stderr to $errors and stderr + exec {stdout}>&1 + "${@}" $INITRD >(tee /dev/stderr) > /dev/fd/$stdout + ret=$? + exec {stdout}>&- + + return $ret +} + run_test_status () { - local stdout ret + local stdout ret ret_success exec {stdout}>&1 - lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout)) + + # For qemu, an exit status of 1 means that the test completed. For kvmtool, + # 0 means the same thing. + case "$TARGET" in + qemu) + ret_success=1 + lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout)) + ;; + kvmtool) + ret_success=0 + lines=$(run_kvmtool "$@" > >(tee /dev/fd/$stdout)) + ;; + esac ret=$? exec {stdout}>&- - if [ $ret -eq 1 ]; then + if [ $ret -eq $ret_success ]; then testret=$(grep '^EXIT: ' <<<"$lines" | head -n1 | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') if [ "$testret" ]; then if [ $testret -eq 1 ]; then @@ -422,6 +453,25 @@ search_qemu_binary () export PATH=$save_path } +search_kvmtool_binary () +{ + local kvmtoolcmd kvmtool + + for kvmtoolcmd in lkvm vm lkvm-static; do + if $kvmtoolcmd --help 2>/dev/null| grep -q 'The most commonly used'; then + kvmtool="$kvmtoolcmd" + break + fi + done + + if [ -z "$kvmtool" ]; then + echo "A kvmtool binary was not found." >&2 + return 2 + fi + + command -v $kvmtool +} + initrd_cleanup () { rm -f $KVM_UNIT_TESTS_ENV @@ -447,7 +497,18 @@ initrd_create () fi unset INITRD - [ -f "$KVM_UNIT_TESTS_ENV" ] && INITRD="-initrd $KVM_UNIT_TESTS_ENV" + if [ ! -f "$KVM_UNIT_TESTS_ENV" ]; then + return 0 + fi + + case "$TARGET" in + qemu) + INITRD="-initrd $KVM_UNIT_TESTS_ENV" + ;; + kvmtool) + INITRD="--initrd $KVM_UNIT_TESTS_ENV" + ;; + esac return 0 } @@ -471,18 +532,25 @@ env_params () local qemu have_qemu local _ rest - qemu=$(search_qemu_binary) && have_qemu=1 + env_add_params TARGET + + # kvmtool's versioning has been broken since it was split from the kernel + # source. + if [ "$TARGET" = "qemu" ]; then + qemu=$(search_qemu_binary) && have_qemu=1 - if [ "$have_qemu" ]; then - if [ -n "$ACCEL" ] || [ -n "$QEMU_ACCEL" ]; then - [ -n "$ACCEL" ] && QEMU_ACCEL=$ACCEL + if [ "$have_qemu" ]; then + if [ -n "$ACCEL" ] || [ -n "$QEMU_ACCEL" ]; then + [ -n "$ACCEL" ] && QEMU_ACCEL=$ACCEL + fi + QEMU_VERSION_STRING="$($qemu -h | head -1)" + # Shellcheck does not see QEMU_MAJOR|MINOR|MICRO are used + # shellcheck disable=SC2034 + IFS='[ .]' read -r _ _ _ QEMU_MAJOR QEMU_MINOR QEMU_MICRO rest <<<"$QEMU_VERSION_STRING" fi - QEMU_VERSION_STRING="$($qemu -h | head -1)" - # Shellcheck does not see QEMU_MAJOR|MINOR|MICRO are used - # shellcheck disable=SC2034 - IFS='[ .]' read -r _ _ _ QEMU_MAJOR QEMU_MINOR QEMU_MICRO rest <<<"$QEMU_VERSION_STRING" + + env_add_params QEMU_ACCEL QEMU_VERSION_STRING QEMU_MAJOR QEMU_MINOR QEMU_MICRO fi - env_add_params QEMU_ACCEL QEMU_VERSION_STRING QEMU_MAJOR QEMU_MINOR QEMU_MICRO KERNEL_VERSION_STRING=$(uname -r) IFS=. read -r KERNEL_VERSION KERNEL_PATCHLEVEL rest <<<"$KERNEL_VERSION_STRING" From patchwork Mon Jan 20 16:43:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945262 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AAAD1EE024; Mon, 20 Jan 2025 16:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391452; cv=none; b=ebyEisn+KsrDdiQKBLGyNuGYRYt8wTQTAEii/0LPse0Sx9kfD8+nf1kBA7yeQqt2pCOikE3pICU+iSurx3Frbwby2YFuOfmbFPz0Ltx331btiI5AL1prk33MrXpn40rRXHcwxyPiU6bb46n+693kw00Qbz0KQYztveL46x8AcwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391452; c=relaxed/simple; bh=LQRDkRD17AHx/7dGR1PQPz1U+TQtVIHPhH0+e0jOdqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnXmpvqUJp5hFbo2eba5JAII7PvlEWLe3byU6rF5yxMbPx2O5Tld53pSni8NZBqgI7wVWBfvgw2UMbkgCNSHtQEpJy42E2/zt4dXY0HLlIsCGt6/gs6bvAYywoy0mO+Cddxelr2eeE26rG+gIJtMDuWED5eoLsTCiYXSV+SUJqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 18899FEC; Mon, 20 Jan 2025 08:44:39 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7170E3F5A1; Mon, 20 Jan 2025 08:44:07 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 11/18] arm/run: Add support for kvmtool Date: Mon, 20 Jan 2025 16:43:09 +0000 Message-ID: <20250120164316.31473-12-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Teach the arm runner to use kvmtool when kvm-unit-tests has been configured appropriately. The test is ran using run_test_status() because kvmtool does not have a testdev device to return the test exit code, so kvm-unit-tests must always parse the "EXIT: STATUS" line for the exit code. Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones --- arm/run | 183 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 110 insertions(+), 73 deletions(-) diff --git a/arm/run b/arm/run index 9b11feafffdd..880d5afae86d 100755 --- a/arm/run +++ b/arm/run @@ -17,77 +17,114 @@ qemu) exit 3 esac -processor="$PROCESSOR" +arch_run_qemu() +{ + processor="$PROCESSOR" + + if [ "$QEMU" ] && [ -z "$ACCEL" ] && + [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && + [ "$(basename $QEMU)" = "qemu-system-arm" ]; then + ACCEL="tcg" + fi + + set_qemu_accelerator || exit $? + if [ "$ACCEL" = "kvm" ]; then + QEMU_ARCH=$HOST + fi + + qemu=$(search_qemu_binary) || + exit $? + + if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then + echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." + exit 2 + fi + + M='-machine virt' + + if [ "$ACCEL" = "kvm" ]; then + if $qemu $M,\? | grep -q gic-version; then + M+=',gic-version=host' + fi + fi + + if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then + if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then + processor="host" + if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then + processor+=",aarch64=off" + fi + fi + fi + + if [ "$ARCH" = "arm" ]; then + M+=",highmem=off" + fi + + if ! $qemu $M -device '?' | grep -q virtconsole; then + echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." + exit 2 + fi + + if ! $qemu $M -chardev '?' | grep -q testdev; then + echo "$qemu doesn't support chr-testdev. Exiting." + exit 2 + fi + + if [ "$UEFI_SHELL_RUN" != "y" ] && [ "$EFI_USE_ACPI" != "y" ]; then + chr_testdev='-device virtio-serial-device' + chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' + fi + + pci_testdev= + if $qemu $M -device '?' | grep -q pci-testdev; then + pci_testdev="-device pci-testdev" + fi + + A="-accel $ACCEL$ACCEL_PROPS" + command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" + command+=" -display none -serial stdio" + command="$(migration_cmd) $(timeout_cmd) $command" + + if [ "$UEFI_SHELL_RUN" = "y" ]; then + ENVIRON_DEFAULT=n run_test_status $command "$@" + elif [ "$EFI_USE_ACPI" = "y" ]; then + run_test_status $command -kernel "$@" + else + run_qemu $command -kernel "$@" + fi +} + +arch_run_kvmtool() +{ + local command + + kvmtool=$(search_kvmtool_binary) || + exit $? + + if [ "$ACCEL" ] && [ "$ACCEL" != "kvm" ]; then + echo "kvmtool does not support $ACCEL" >&2 + exit 2 + fi + + if ! kvm_available; then + echo "KVM required by kvmtool but not available on the host" >&2 + exit 2 + fi + + command="$(timeout_cmd) $kvmtool run" + if [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ]; then + run_test_status $command --kernel "$@" --aarch32 + else + run_test_status $command --kernel "$@" + fi +} -if [ "$QEMU" ] && [ -z "$ACCEL" ] && - [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] && - [ "$(basename $QEMU)" = "qemu-system-arm" ]; then - ACCEL="tcg" -fi - -set_qemu_accelerator || exit $? -if [ "$ACCEL" = "kvm" ]; then - QEMU_ARCH=$HOST -fi - -qemu=$(search_qemu_binary) || - exit $? - -if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then - echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting." - exit 2 -fi - -M='-machine virt' - -if [ "$ACCEL" = "kvm" ]; then - if $qemu $M,\? | grep -q gic-version; then - M+=',gic-version=host' - fi -fi - -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then - if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then - processor="host" - if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then - processor+=",aarch64=off" - fi - fi -fi - -if [ "$ARCH" = "arm" ]; then - M+=",highmem=off" -fi - -if ! $qemu $M -device '?' | grep -q virtconsole; then - echo "$qemu doesn't support virtio-console for chr-testdev. Exiting." - exit 2 -fi - -if ! $qemu $M -chardev '?' | grep -q testdev; then - echo "$qemu doesn't support chr-testdev. Exiting." - exit 2 -fi - -if [ "$UEFI_SHELL_RUN" != "y" ] && [ "$EFI_USE_ACPI" != "y" ]; then - chr_testdev='-device virtio-serial-device' - chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' -fi - -pci_testdev= -if $qemu $M -device '?' | grep -q pci-testdev; then - pci_testdev="-device pci-testdev" -fi - -A="-accel $ACCEL$ACCEL_PROPS" -command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev" -command+=" -display none -serial stdio" -command="$(migration_cmd) $(timeout_cmd) $command" - -if [ "$UEFI_SHELL_RUN" = "y" ]; then - ENVIRON_DEFAULT=n run_test_status $command "$@" -elif [ "$EFI_USE_ACPI" = "y" ]; then - run_test_status $command -kernel "$@" -else - run_qemu $command -kernel "$@" -fi +case "$TARGET" in +qemu) + arch_run_qemu "$@" + ;; +kvmtool) + arch_run_kvmtool "$@" + ;; +esac From patchwork Mon Jan 20 16:43:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945263 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC5BE1EC00C; Mon, 20 Jan 2025 16:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391456; cv=none; b=Ebw+5oodMU3BJpmJVNjQ/JWVQGoOk1kzOrjwJKdNPF1FtQO4Z7evHC/X7cMWPanfpMWkN9oqI1hQYAflkpKtqxeKtNPjPIUH+PJ1/sEUmR9Li0RoMBTSqVXJpU1PP00fVxZECt4EcXlMjmrOlKJbTrYQrpCbPFUPj0Wk2/pIM58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391456; c=relaxed/simple; bh=5hc11jVUYcRqIGXyoCokB29PqbSsKoLTBuLj1/HgG7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TWoG95tb00CEmXub7QzX9uSYDiOXBEjLWcul97hL4HjBSaUrraBYfppN/PXcKFaMa/CPtrVRMWEwrUqjE/i83LtOg9wF2LgnNyK6tVcjn4H/TUS9JNLPJ1VoXzBxx3sIzrBVYjBmGUfdl59oEjrlwJvOcEFUqtUvrr21N7l/m74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 8FDAE1063; Mon, 20 Jan 2025 08:44:42 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E59EC3F5A1; Mon, 20 Jan 2025 08:44:10 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 12/18] scripts/runtime: Add default arguments for kvmtool Date: Mon, 20 Jan 2025 16:43:10 +0000 Message-ID: <20250120164316.31473-13-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 kvmtool, unless told otherwise, will do its best to make sure that a kernel successfully boots in a virtual machine. Among things like automatically creating a rootfs, it also adds extra parameters to the kernel command line. This is actively harmful to kvm-unit-tests, because some tests parse the kernel command line and they will fail if they encounter the options added by kvmtool. Fortunately for us, kvmtool commit 5613ae26b998 ("Add --nodefaults command line argument") addded the --nodefaults kvmtool parameter which disables all the implicit virtual machine configuration that cannot be disabled by using other parameters, like modifying the kernel command line. Always use --nodefaults to allow a test to run. kvmtool can be too verbose when running a virtual machine, and this is controlled with parameters. Add those to the default kvmtool command line to reduce this verbosity to a minimum. Before: $ vm run arm/selftest.flat --cpus 2 --mem 256 --params "setup smp=2 mem=256" Info: # lkvm run -k arm/selftest.flat -m 256 -c 2 --name guest-5035 Unknown subtest EXIT: STATUS=127 Warning: KVM compatibility warning. virtio-9p device was not detected. While you have requested a virtio-9p device, the guest kernel did not initialize it. Please make sure that the guest kernel was compiled with CONFIG_NET_9P_VIRTIO=y enabled in .config. Warning: KVM compatibility warning. virtio-net device was not detected. While you have requested a virtio-net device, the guest kernel did not initialize it. Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_NET=y enabled in .config. Info: KVM session ended normally. After: $ vm run arm/selftest.flat --nodefaults --network mode=none --loglevel=warning --cpus 2 --mem 256 --params "setup smp=2 mem=256" PASS: selftest: setup: smp: number of CPUs matches expectation INFO: selftest: setup: smp: found 2 CPUs PASS: selftest: setup: mem: memory size matches expectation INFO: selftest: setup: mem: found 256 MB SUMMARY: 2 tests EXIT: STATUS=1 Note that KVMTOOL_DEFAULT_OPTS can be overwritten by an environment variable with the same name, but it's not documented in the help string for run_tests.sh. This has been done on purpose, since overwritting KVMTOOL_DEFAULT_OPTS should only be necessary for debugging or development purposes. Signed-off-by: Alexandru Elisei --- scripts/runtime.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 55d58eef9c7c..abfd1e67b2ef 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -2,6 +2,17 @@ : "${MAX_SMP:=$(getconf _NPROCESSORS_ONLN)}" : "${TIMEOUT:=90s}" +# The following parameters are enabled by default when running a test with +# kvmtool: +# --nodefaults: suppress VM configuration that cannot be disabled otherwise +# (like modifying the supplied kernel command line). Tests that +# use the command line will fail without this parameter. +# --network mode=none: do not create a network device. kvmtool tries to help the +# user by automatically create one, and then prints a warning +# when the VM terminates if the device hasn't been initialized. +# --loglevel=warning: reduce verbosity +: "${KVMTOOL_DEFAULT_OPTS:="--nodefaults --network mode=none --loglevel=warning"}" + PASS() { echo -ne "\e[32mPASS\e[0m"; } SKIP() { echo -ne "\e[33mSKIP\e[0m"; } FAIL() { echo -ne "\e[31mFAIL\e[0m"; } @@ -103,7 +114,7 @@ function run() opts="-smp $smp $qemu_opts" ;; kvmtool) - opts="--cpus $smp $kvmtool_opts" + opts="$KVMTOOL_DEFAULT_OPTS --cpus $smp $kvmtool_opts" ;; esac From patchwork Mon Jan 20 16:43:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945264 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 051EB1DF989; Mon, 20 Jan 2025 16:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391459; cv=none; b=YA5D0eBp9OUXrTtj6zF0XoTyKr6QjyB5tnvYWLQjbQ2K/fIPPz4x6+pRPO/Phprx5mHNzBBnM3pxGLbTKPy+ld8vnbs3SFWWgDl7Hj2zvSHMUqBEp29GADA+YV+qkhKZ7VDNwESjnwKZxqVtb3/zlACnR7PYingTDH9Z2cvB4js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391459; c=relaxed/simple; bh=ovSjkdUX7BuXHroB0uRQIMIyN52F0thSyV5KanQXoeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+W8iKqnAufEShJNlh3L9hvmcSb4hC+TOWwJ+9WJd5Bo3fXjfIH4hNIaQkArbGKjLwhLJuVxx+KTqs2mBJoDVwESEPnCsr6FZamNgJ5QE/e5PvTVrAc/cXItWhIXH+7Ar9eByHHUEaHJB08lKlZ8XKX0MeIdyWr3CNyZHuIlxxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 19A1D106F; Mon, 20 Jan 2025 08:44:46 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A9683F5A1; Mon, 20 Jan 2025 08:44:14 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 13/18] run_tests: Do not probe for maximum number of VCPUs when using kvmtool Date: Mon, 20 Jan 2025 16:43:11 +0000 Message-ID: <20250120164316.31473-14-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The --probe-maxsmp parameter updates MAX_SMP with the maximum number of VCPUs that the host supports. Qemu will exit with an error when creating a virtual machine if the number of VCPUs is exceeded. kvmtool behaves differently: it will automatically limit the number of VCPUs to the what KVM supports, which is exactly what --probe-maxsmp wants to achieve. When doing --probe-maxsmp with kvmtool, print a message explaining why it's redundant and don't do anything else. Signed-off-by: Alexandru Elisei --- run_tests.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index 61480d0c05ed..acaaadbb879b 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -89,7 +89,15 @@ while [ $# -gt 0 ]; do list_tests="yes" ;; --probe-maxsmp) - probe_maxsmp + case "$TARGET" in + qemu) + probe_maxsmp + ;; + kvmtool) + echo "kvmtool automatically limits the number of VCPUs to maximum supported" + echo "The 'smp' test parameter won't be modified" + ;; + esac ;; --) ;; From patchwork Mon Jan 20 16:43:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945265 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867D91EE7CB; Mon, 20 Jan 2025 16:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391462; cv=none; b=dTiRI3jQj1AAyJcN9O3H9H/jmZ9f+9wckPkr3f4w5vslelN8K1EAQ7//tdhbz0hkMeperXWdYOXoLA4X6wwkwMYSyrBfopLfeRqO2A+4pdZaCOR/SyudTD2TvG65sTL31w/5zMqzKXmqrXW06rdZpfHox+LLlwpvNRj2DCqTQrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391462; c=relaxed/simple; bh=F5JLESh64pYGf8TOT5XAacDpOwefATNhBDvIEA6pnoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aEK8AmRXGN7eztZ7SNjWnLdAog5fvICqnGDuDsVCA2y5b63nKtW9K+Hg+BKleTneloe+4KSZcW5ZDKJmUicmTCLzeu8aInmhf2l5FfiGRzCZkOMBZy47UYFbx7PskkL+n7pg5g/IB3TUck9Q2eEy59pP0aMmt+Yt8uYDjMZTJys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 8AD52169C; Mon, 20 Jan 2025 08:44:49 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E750E3F5A1; Mon, 20 Jan 2025 08:44:17 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 14/18] run_tests: Add KVMTOOL environment variable for kvmtool binary path Date: Mon, 20 Jan 2025 16:43:12 +0000 Message-ID: <20250120164316.31473-15-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 kvmtool is often used for prototyping new features, and a developer might not want to install it system-wide. Add a KVMTOOL environment variable to make it easier for tests to use a binary not in $PATH. Signed-off-by: Alexandru Elisei --- run_tests.sh | 1 + scripts/arch-run.bash | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index acaaadbb879b..d38954be9093 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -36,6 +36,7 @@ The following environment variables are used: TIMEOUT Timeout duration for the timeout(1) command CHECK Overwrites the 'check' unit test parameter (see docs/unittests.txt) + KVMTOOL Path to kvmtool binary for ARCH-run EOF } diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 34f633cade01..5d840b72f8cb 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -457,7 +457,7 @@ search_kvmtool_binary () { local kvmtoolcmd kvmtool - for kvmtoolcmd in lkvm vm lkvm-static; do + for kvmtoolcmd in ${KVMTOOL:-lkvm vm lkvm-static}; do if $kvmtoolcmd --help 2>/dev/null| grep -q 'The most commonly used'; then kvmtool="$kvmtoolcmd" break From patchwork Mon Jan 20 16:43:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945266 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16ABC1EEA51; Mon, 20 Jan 2025 16:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391466; cv=none; b=fZAkuT0/giHHXPOSP/ozbfHpKj6uqWJXrH23CTf43LPUWA4GJBYLVZV3zBdqhETmuR/BC6JEcJRndPrcYR+gT/APFFjx9oWKVZxRMppm5YBZSq1mka2r2ArNPBMCb5ThuP7gzNvZHEb/5Sk/eklzDtCQHWHMX0zgaS932nD7hy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391466; c=relaxed/simple; bh=hX5y+GTypT4FSYyuc2jp+IPa0QblQk+VmbjbbPKgJx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i9osS1EJzax4nuxUiaWgZABX1wMMG7meQJAt+l41EkvL8mMWkEzwnZXCFt/uCMtps5cTSVUFxNggBRQVmtKOi9tiKAXY3//rjdhg5BLRDlRIVQ1lJLpVLUqlQhRFbQgiViEf6SuZAZlUs9AhzyBAJWi7ykb2v9wfJ3g0JKUSYPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 2B42E1D15; Mon, 20 Jan 2025 08:44:53 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 644773F5A1; Mon, 20 Jan 2025 08:44:21 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 15/18] Add kvmtool_params to test specification Date: Mon, 20 Jan 2025 16:43:13 +0000 Message-ID: <20250120164316.31473-16-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 arm/arm64 supports running tests under kvmtool, but kvmtool's syntax for running a virtual machine is different than qemu's. To run tests using the automated test infrastructure, add a new test parameter, kvmtool_params. The parameter serves the exact purpose as qemu_params/extra_params, but using kvmtool's syntax. Signed-off-by: Alexandru Elisei --- arm/unittests.cfg | 27 +++++++++++++++++++++++++++ docs/unittests.txt | 8 ++++++++ scripts/common.bash | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 2bdad67d5693..974a5a9e4113 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -16,18 +16,21 @@ file = selftest.flat smp = 2 extra_params = -m 256 -append 'setup smp=2 mem=256' +kvmtool_params = --mem 256 --params 'setup smp=2 mem=256' groups = selftest # Test vector setup and exception handling (kernel mode). [selftest-vectors-kernel] file = selftest.flat extra_params = -append 'vectors-kernel' +kvmtool_params = --params 'vectors-kernel' groups = selftest # Test vector setup and exception handling (user mode). [selftest-vectors-user] file = selftest.flat extra_params = -append 'vectors-user' +kvmtool_params = --params 'vectors-user' groups = selftest # Test SMP support @@ -35,6 +38,7 @@ groups = selftest file = selftest.flat smp = $MAX_SMP extra_params = -append 'smp' +kvmtool_params = --params 'smp' groups = selftest # Test PCI emulation @@ -47,66 +51,77 @@ groups = pci file = pmu.flat groups = pmu extra_params = -append 'cycle-counter 0' +kvmtool_params = --pmu --params 'cycle-counter 0' [pmu-event-introspection] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-event-introspection' +kvmtool_params = --pmu --params 'pmu-event-introspection' [pmu-event-counter-config] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-event-counter-config' +kvmtool_params = --pmu --params 'pmu-event-counter-config' [pmu-basic-event-count] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-basic-event-count' +kvmtool_params = --pmu --params 'pmu-basic-event-count' [pmu-mem-access] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-mem-access' +kvmtool_params = --pmu --params 'pmu-mem-access' [pmu-mem-access-reliability] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-mem-access-reliability' +kvmtool_params = --pmu --params 'pmu-mem-access-reliability' [pmu-sw-incr] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-sw-incr' +kvmtool_params = --pmu --params 'pmu-sw-incr' [pmu-chained-counters] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-chained-counters' +kvmtool_params = --pmu --params 'pmu-chained-counters' [pmu-chained-sw-incr] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-chained-sw-incr' +kvmtool_params = --pmu --params 'pmu-chained-sw-incr' [pmu-chain-promotion] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-chain-promotion' +kvmtool_params = --pmu --params 'pmu-chain-promotion' [pmu-overflow-interrupt] file = pmu.flat groups = pmu arch = arm64 extra_params = -append 'pmu-overflow-interrupt' +kvmtool_params = --pmu --params 'pmu-overflow-interrupt' # Test PMU support (TCG) with -icount IPC=1 #[pmu-tcg-icount-1] @@ -127,48 +142,56 @@ extra_params = -append 'pmu-overflow-interrupt' file = gic.flat smp = $((($MAX_SMP < 8)?$MAX_SMP:8)) extra_params = -machine gic-version=2 -append 'ipi' +kvmtool_params = --irqchip=gicv2 --params 'ipi' groups = gic [gicv2-mmio] file = gic.flat smp = $((($MAX_SMP < 8)?$MAX_SMP:8)) extra_params = -machine gic-version=2 -append 'mmio' +kvmtool_params = --irqchip=gicv2 --params 'mmio' groups = gic [gicv2-mmio-up] file = gic.flat smp = 1 extra_params = -machine gic-version=2 -append 'mmio' +kvmtool_params = --irqchip=gicv2 --params 'mmio' groups = gic [gicv2-mmio-3p] file = gic.flat smp = $((($MAX_SMP < 3)?$MAX_SMP:3)) extra_params = -machine gic-version=2 -append 'mmio' +kvmtool_params = --irqchip=gicv2 --params 'mmio' groups = gic [gicv3-ipi] file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'ipi' +kvmtool_params = --irqchip=gicv3 --params 'ipi' groups = gic [gicv2-active] file = gic.flat smp = $((($MAX_SMP < 8)?$MAX_SMP:8)) extra_params = -machine gic-version=2 -append 'active' +kvmtool_params = --irqchip=gicv2 --params 'active' groups = gic [gicv3-active] file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'active' +kvmtool_params = --irqchip=gicv3 --params 'active' groups = gic [its-introspection] file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'its-introspection' +kvmtool_params = --irqchip=gicv3-its --params 'its-introspection' groups = its arch = arm64 @@ -176,6 +199,7 @@ arch = arm64 file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'its-trigger' +kvmtool_params = --irqchip=gicv3-its --params 'its-trigger' groups = its arch = arm64 @@ -232,6 +256,7 @@ groups = cache file = debug.flat arch = arm64 extra_params = -append 'bp' +kvmtool_params = --params 'bp' groups = debug [debug-bp-migration] @@ -244,6 +269,7 @@ groups = debug migration file = debug.flat arch = arm64 extra_params = -append 'wp' +kvmtool_params = --params 'wp' groups = debug [debug-wp-migration] @@ -256,6 +282,7 @@ groups = debug migration file = debug.flat arch = arm64 extra_params = -append 'ss' +kvmtool_params = --params 'ss' groups = debug [debug-sstep-migration] diff --git a/docs/unittests.txt b/docs/unittests.txt index 3e1a9e563016..ebb6994cab77 100644 --- a/docs/unittests.txt +++ b/docs/unittests.txt @@ -69,6 +69,14 @@ extra_params Alias for 'qemu_params', supported for compatibility purposes. Use 'qemu_params' for new tests. +kvmtool_params +-------------- +Extra parameters supplied to the kvmtool process. Works similarly to +qemu_params and extra_params, but uses kvmtool's syntax for command line +arguments. The example for qemu_params, applied to kvmtool, would be: + +kvmtool_params = --mem 256 --params 'smp=2' + groups ------ groups = ... diff --git a/scripts/common.bash b/scripts/common.bash index 1b5e0d667841..f54ffbd7a87b 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -67,6 +67,10 @@ function for_each_unittest() qemu_opts=$(parse_opts ${BASH_REMATCH[2]}$'\n' $fd) elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *(.*)$ ]]; then qemu_opts=${BASH_REMATCH[2]} + elif [[ $line =~ ^kvmtool_params\ *=\ *'"""'(.*)$ ]]; then + kvmtool_opts=$(parse_opts ${BASH_REMATCH[1]}$'\n' $fd) + elif [[ $line =~ ^kvmtool_params\ *=\ *(.*)$ ]]; then + kvmtool_opts=${BASH_REMATCH[1]} elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then groups=${BASH_REMATCH[1]} elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then From patchwork Mon Jan 20 16:43:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945267 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 971101EEA51; Mon, 20 Jan 2025 16:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391470; cv=none; b=PFcZ8ld5HFzC36nq5TotRXJ9CU7Oj4z7QNlDczrstL/gS2hWkIbo06uz/GpNDrHCrBSV7JIeZUkAuxfL89+lJDcSDTzWlS4NLAKrdGy6l1fxlqVSEx3bv6Njh13ItPoinZarsiwvjFy9X1duTHEX4FMOy0BLHTL+uE2/sNx3omg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391470; c=relaxed/simple; bh=dJJJTcXjiIPSUEWaKKjJ4qjvikCsMRzj4vaP4x+eMZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lyzf4RPo6UUqjsKJdzqXamEb9Jk/FPKOoM5ak04zuzV/43VrglDaenVvFqFRR79QRdnkpxBngBnH0iyFiTKzan7CE1TEksrUNS6gSxE9BqeDtdiIBkkJ+vJJYWO9FnzxbS5rJviod7Il2hso4ZpH584suylatfs03J4hXRBqyEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 AB8FF1D31; Mon, 20 Jan 2025 08:44:56 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 080883F5A1; Mon, 20 Jan 2025 08:44:24 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 16/18] scripts/mkstandalone: Export $TARGET Date: Mon, 20 Jan 2025 16:43:14 +0000 Message-ID: <20250120164316.31473-17-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 $TARGET is needed for the test runner to decide if it should use qemu or kvmtool, so export it. Signed-off-by: Alexandru Elisei --- scripts/mkstandalone.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index 4de97056e641..10abb5e191b7 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -51,6 +51,7 @@ generate_test () config_export ARCH config_export ARCH_NAME config_export PROCESSOR + config_export TARGET echo "echo BUILD_HEAD=$(cat build-head)" From patchwork Mon Jan 20 16:43:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945268 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CF1B1EB9FA; Mon, 20 Jan 2025 16:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391473; cv=none; b=JrL+yq6pX3q7DMnPB1avKzRwNB0pkjEIZGk4GtktOEs82W0Yp1pWqMI9VrxA5uiGpAOymxPtkoRLOJiJ2VW3lMsyn7cn0wP8VN6XKxvdzI38UV8fnM0PX1tqqbMEypHa1LahtPMRKFDNvzlY3M1/veR8m3eXd43l9vk26nH23W4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391473; c=relaxed/simple; bh=Am2z1FqWMNd8WV/ZFvPyfxDhjdXYhvIZKJHgaKv6XPk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RTbvg0UJT9K8Ni4CcvYtzyqOUep+LA5fN211WMKjY0MakbhAdeDhbljUDPt4yqeBdNZmnOGpVdSkWK6RXs91cBDRpaEPgqvofrWW3Im2etb+kyGcwKgxndC9KDGJuJCjXXCwExWT8diDi9AFZJZuCxfXjhSKCba4x4SR9pwBAUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 2F4FC1D34; Mon, 20 Jan 2025 08:45:00 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 849DA3F5A1; Mon, 20 Jan 2025 08:44:28 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 17/18] unittest: Add disabled_if parameter and use it for kvmtool Date: Mon, 20 Jan 2025 16:43:15 +0000 Message-ID: <20250120164316.31473-18-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The pci-test is qemu specific. Other tests perform migration, which isn't supported by kvmtool. In general, kvmtool is not as feature-rich as qemu, so add a new unittest parameter, disabled_if, that causes a test to be skipped if the condition evaluates to true. Signed-off-by: Alexandru Elisei --- arm/unittests.cfg | 7 +++++++ docs/unittests.txt | 13 +++++++++++++ scripts/common.bash | 8 ++++++-- scripts/runtime.bash | 6 ++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 974a5a9e4113..9b1df5e02a58 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -44,6 +44,7 @@ groups = selftest # Test PCI emulation [pci-test] file = pci-test.flat +disabled_if = [[ "$TARGET" != qemu ]] groups = pci # Test PMU support @@ -208,6 +209,7 @@ file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'its-migration' groups = its migration +disabled_if = [[ "$TARGET" != qemu ]] arch = arm64 [its-pending-migration] @@ -215,6 +217,7 @@ file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'its-pending-migration' groups = its migration +disabled_if = [[ "$TARGET" != qemu ]] arch = arm64 [its-migrate-unmapped-collection] @@ -222,6 +225,7 @@ file = gic.flat smp = $MAX_SMP extra_params = -machine gic-version=3 -append 'its-migrate-unmapped-collection' groups = its migration +disabled_if = [[ "$TARGET" != qemu ]] arch = arm64 # Test PSCI emulation @@ -263,6 +267,7 @@ groups = debug file = debug.flat arch = arm64 extra_params = -append 'bp-migration' +disabled_if = [[ "$TARGET" != qemu ]] groups = debug migration [debug-wp] @@ -276,6 +281,7 @@ groups = debug file = debug.flat arch = arm64 extra_params = -append 'wp-migration' +disabled_if = [[ "$TARGET" != qemu ]] groups = debug migration [debug-sstep] @@ -289,6 +295,7 @@ groups = debug file = debug.flat arch = arm64 extra_params = -append 'ss-migration' +disabled_if = [[ "$TARGET" != qemu ]] groups = debug migration # FPU/SIMD test diff --git a/docs/unittests.txt b/docs/unittests.txt index ebb6994cab77..58d1a29146a3 100644 --- a/docs/unittests.txt +++ b/docs/unittests.txt @@ -115,3 +115,16 @@ parameter needs to be of the form = The path and value cannot contain space, =, or shell wildcard characters. Can be overwritten with the CHECK environment variable with the same syntax. + +disabled_if +------ +disabled_if = + +Do not run the test if is met. will be fed unmodified +to a bash 'if' statement and follows the same syntax. + +This can be used to prevent running a test when kvm-unit-tests is configured a +certain way. For example, it can be used to skip a qemu specific test when +using another VMM and using UEFI: + +disabled_if = [[ "$TARGET" != qemu ]] && [[ "$CONFIG_EFI" = y ]] diff --git a/scripts/common.bash b/scripts/common.bash index f54ffbd7a87b..c0ea2eabeda6 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -38,6 +38,7 @@ function for_each_unittest() local accel local timeout local kvmtool_opts + local disabled_cond local rematch exec {fd}<"$unittests" @@ -46,7 +47,7 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" "$disabled_cond" fi testname=$rematch smp=1 @@ -59,6 +60,7 @@ function for_each_unittest() accel="" timeout="" kvmtool_opts="" + disabled_cond="" elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then kernel=$TEST_DIR/${BASH_REMATCH[1]} elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then @@ -79,6 +81,8 @@ function for_each_unittest() machine=${BASH_REMATCH[1]} elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then check=${BASH_REMATCH[1]} + elif [[ $line =~ ^disabled_if\ *=\ *(.*)$ ]]; then + disabled_cond=${BASH_REMATCH[1]} elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then accel=${BASH_REMATCH[1]} elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then @@ -86,7 +90,7 @@ function for_each_unittest() fi done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" "$disabled_cond" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index abfd1e67b2ef..002bd2744d6b 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -108,6 +108,7 @@ function run() local accel="$9" local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default local kvmtool_opts="${11}" + local disabled_cond="${12}" case "$TARGET" in qemu) @@ -186,6 +187,11 @@ function run() done fi + if [[ "$disabled_cond" ]] && (eval $disabled_cond); then + print_result "SKIP" $testname "" "disabled because: $disabled_cond" + return 2 + fi + log=$(premature_failure) && { skip=true if [ "${CONFIG_EFI}" == "y" ]; then From patchwork Mon Jan 20 16:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 13945269 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E959F1EE008; Mon, 20 Jan 2025 16:44:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391477; cv=none; b=s3nE/Wb4FEyclEh2V0+mSsd61QxaTREhuCHmnrz+p0+ZUWU0KeDpxES+TidNkklQ8BvAWdcRYhGibvr4+h6ugh4/jeGqaPLXm8qlS+2HKio5OmMSgYKcp6P9sdbzHN756sEHl6Fpmzz0tLaPePpULpf6DY2l3h2oMarODfFo1mM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737391477; c=relaxed/simple; bh=oQPuFvqZz+8QpVL27r/lIr9FEsSrJtFYCs3MYHG2bUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JBOFauGEcwKO8vjPVR+ETNFuk+VNaZlBM8ZEOolIszzn0YYPvsv4AHG8MU9R8w3aNO9660UMH+mtXB11V/wyfCQSER5kceRkvXZ9FNRR2JxtollNVHq/fg3Fhv/8k+Kfrr/y/7d2l4FehknRTf27rBDHrS5z3XhA+sVhSUwqJso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 00BE31D6F; Mon, 20 Jan 2025 08:45:04 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 08CEE3F5A1; Mon, 20 Jan 2025 08:44:31 -0800 (PST) From: Alexandru Elisei To: andrew.jones@linux.dev, eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com Subject: [kvm-unit-tests PATCH v2 18/18] run_tests: Enable kvmtool Date: Mon, 20 Jan 2025 16:43:16 +0000 Message-ID: <20250120164316.31473-19-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250120164316.31473-1-alexandru.elisei@arm.com> References: <20250120164316.31473-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Everything is in place to run the tests using kvmtool: $ ./configure --target=kvmtool $ make clean && make $ KVMTOOL= ./run_tests.sh so enable it, and remove ERRATA_FORCE=y when configuring for kvmtool, because the runner will generate and pass the correct environment to kvmtool. Missing is support for EFI tests. That's because distros don't ship a EDK2 binary compiled for kvmtool, and on top of that kvm-unit-tests as an EFI app hasn't been tested to work with kvmtool. Signed-off-by: Alexandru Elisei --- Should I also revert commit 35145f140442 ("arm/arm64: kvmtool: force all tests to run") which introduced ERRATA_FORCE? I didn't do this now in case other architectures use it/planning to use it. README.md | 15 +++++++++++++++ arm/run | 2 +- configure | 1 - run_tests.sh | 2 +- scripts/mkstandalone.sh | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index be07dc28a094..5e7706f02553 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,9 @@ or: to run them all. +All tests can be run using QEMU. On arm and arm64, tests can also be run using +kvmtool. + By default the runner script searches for a suitable QEMU binary in the system. To select a specific QEMU binary though, specify the QEMU=path/to/binary environment variable: @@ -80,10 +83,22 @@ For running tests that involve migration from one QEMU instance to another you also need to have the "ncat" binary (from the nmap.org project) installed, otherwise the related tests will be skipped. +To run a test with kvmtool, please configure kvm-unit-tests accordingly first: + + ./configure --arch=arm64 --target=kvmtool + +then run the test(s) like with QEMU above. + +To select a kvmtool binary, specify the KVMTOOL=path/to/binary environment +variable. kvmtool supports only kvm as the accelerator. + ## Running the tests with UEFI Check [x86/efi/README.md](./x86/efi/README.md). +On arm and arm64, this is only supported with QEMU; kvmtool cannot run the +tests under UEFI. + # Tests configuration file The test case may need specific runtime configurations, for diff --git a/arm/run b/arm/run index 880d5afae86d..438a2617e564 100755 --- a/arm/run +++ b/arm/run @@ -10,7 +10,7 @@ if [ -z "$KUT_STANDALONE" ]; then fi case "$TARGET" in -qemu) +qemu | kvmtool) ;; *) echo "'$TARGET' not supported" diff --git a/configure b/configure index 86cf1da36467..17d3d931f2c0 100755 --- a/configure +++ b/configure @@ -299,7 +299,6 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then arm_uart_early_addr=0x09000000 elif [ "$target" = "kvmtool" ]; then arm_uart_early_addr=0x1000000 - errata_force=1 else echo "--target must be one of 'qemu' or 'kvmtool'!" usage diff --git a/run_tests.sh b/run_tests.sh index d38954be9093..3921dcdcb344 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -110,7 +110,7 @@ while [ $# -gt 0 ]; do done case "$TARGET" in -qemu) +qemu | kvmtool) ;; *) echo "$0 does not support '$TARGET'" diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index 10abb5e191b7..16383b05adfa 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -8,7 +8,7 @@ source config.mak source scripts/common.bash case "$TARGET" in -qemu) +qemu | kvmtool) ;; *) echo "'$TARGET' not supported for standlone tests"