From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH 10/18] run_tests: probe for max-smp Date: Thu, 5 Nov 2015 18:24:35 -0600 Message-ID: <1446769483-21586-11-git-send-email-drjones@redhat.com> References: <1446769483-21586-1-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: alex.bennee@linaro.org, cov@codeaurora.org To: pbonzini@redhat.com, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45137 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966038AbbKFAZR (ORCPT ); Thu, 5 Nov 2015 19:25:17 -0500 In-Reply-To: <1446769483-21586-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: KVM can be configured to only support a few vcpus. ARM and AArch64 currently have a default config of only 4. While it's nice to be able to write tests that use the maximum recommended, nr-host-cpus, we can't assume that nr-host-cpus =3D=3D kvm-max-vcpus. This patch allo= ws one to put $MAX_SMP in the smp =3D line of a unittests.cfg file. That variable will then expand to the number of host cpus, or to the maximum vcpus allowed by KVM. [Inspired by a patch from Alex Benn=C3=A9e solving the same issue.] Signed-off-by: Andrew Jones --- arm/unittests.cfg | 3 ++- run_tests.sh | 9 +++++++++ scripts/mkstandalone.sh | 9 ++++++++- x86/unittests.cfg | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 243c13301811b..5e26da1a8c1bc 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -2,6 +2,7 @@ # [unittest_name] # file =3D foo.flat # Name of the flat file to be used # smp =3D 2 # Number of processors the VM will use during this= test +# # Use $MAX_SMP to use the maximum the host supports. # extra_params =3D -append # Additional parameters used # arch =3D arm|arm64 # Only if test case is specific= to one # groups =3D group1 group2 # Used to identify test cases with run_test= s -g ... @@ -34,6 +35,6 @@ groups =3D selftest # Test SMP support [selftest-smp] file =3D selftest.flat -smp =3D `getconf _NPROCESSORS_CONF` +smp =3D $MAX_SMP extra_params =3D -append 'smp' groups =3D selftest diff --git a/run_tests.sh b/run_tests.sh index b1b4c541ecaea..fad22a935b007 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -98,4 +98,13 @@ while getopts "g:hv" opt; do esac done =20 +# +# Probe for MAX_SMP +# +MAX_SMP=3D$(getconf _NPROCESSORS_CONF) +while ./$TEST_DIR-run _NO_FILE_4Uhere_ -smp $MAX_SMP \ + |& grep -q 'exceeds max cpus'; do + ((--MAX_SMP)) +done + for_each_unittest $config run diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index 0c39451e538c9..3ce244aff67b9 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -95,12 +95,19 @@ qemu=3D"$qemu" if [ "\$QEMU" ]; then qemu=3D"\$QEMU" fi + +MAX_SMP=3D"MAX_SMP" echo \$qemu $cmdline -smp $smp $opts =20 cmdline=3D"\`echo '$cmdline' | sed s%$kernel%_NO_FILE_4Uhere_%\`" if \$qemu \$cmdline 2>&1 | grep 'No accelerator found'; then - ret=3D2 + ret=3D2 else + MAX_SMP=3D\`getconf _NPROCESSORS_CONF\` + while \$qemu \$cmdline -smp \$MAX_SMP 2>&1 | grep 'exceeds max cpus' = > /dev/null; do + MAX_SMP=3D\`expr \$MAX_SMP - 1\` + done + cmdline=3D"\`echo '$cmdline' | sed s%$kernel%\$bin%\`" \$qemu \$cmdline -smp $smp $opts ret=3D\$? diff --git a/x86/unittests.cfg b/x86/unittests.cfg index a38544f77c056..337cc19d3d19d 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -2,6 +2,7 @@ # [unittest_name] # file =3D foo.flat # Name of the flat file to be used # smp =3D 2 # Number of processors the VM will use during this test +# # Use $MAX_SMP to use the maximum the host supports. # extra_params =3D -cpu qemu64,+x2apic # Additional parameters used # arch =3D i386/x86_64 # Only if the test case works only on one of th= em # groups =3D group1 group2 # Used to identify test cases with run_test= s -g ... --=20 2.4.3