hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/testing/selftests/rcutorture/bin/functions.sh
....@@ -1,31 +1,18 @@
11 #!/bin/bash
2
+# SPDX-License-Identifier: GPL-2.0+
23 #
34 # Shell functions for the rest of the scripts.
45 #
5
-# This program is free software; you can redistribute it and/or modify
6
-# it under the terms of the GNU General Public License as published by
7
-# the Free Software Foundation; either version 2 of the License, or
8
-# (at your option) any later version.
9
-#
10
-# This program is distributed in the hope that it will be useful,
11
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
-# GNU General Public License for more details.
14
-#
15
-# You should have received a copy of the GNU General Public License
16
-# along with this program; if not, you can access it online at
17
-# http://www.gnu.org/licenses/gpl-2.0.html.
18
-#
196 # Copyright (C) IBM Corporation, 2013
207 #
21
-# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
8
+# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
229
2310 # bootparam_hotplug_cpu bootparam-string
2411 #
2512 # Returns 1 if the specified boot-parameter string tells rcutorture to
2613 # test CPU-hotplug operations.
2714 bootparam_hotplug_cpu () {
28
- echo "$1" | grep -q "rcutorture\.onoff_"
15
+ echo "$1" | grep -q "torture\.onoff_"
2916 }
3017
3118 # checkarg --argname argtype $# arg mustmatch cannotmatch
....@@ -185,7 +172,7 @@
185172 local console=ttyS0
186173 case "$1" in
187174 qemu-system-x86_64|qemu-system-i386)
188
- echo noapic selinux=0 initcall_debug debug
175
+ echo selinux=0 initcall_debug debug
189176 ;;
190177 qemu-system-aarch64)
191178 console=ttyAMA0
....@@ -204,8 +191,19 @@
204191 # Output arguments for qemu arguments based on the TORTURE_QEMU_MAC
205192 # and TORTURE_QEMU_INTERACTIVE environment variables.
206193 identify_qemu_args () {
194
+ local KVM_CPU=""
195
+ case "$1" in
196
+ qemu-system-x86_64)
197
+ KVM_CPU=kvm64
198
+ ;;
199
+ qemu-system-i386)
200
+ KVM_CPU=kvm32
201
+ ;;
202
+ esac
207203 case "$1" in
208204 qemu-system-x86_64|qemu-system-i386)
205
+ echo -machine q35,accel=kvm
206
+ echo -cpu ${KVM_CPU}
209207 ;;
210208 qemu-system-aarch64)
211209 echo -machine virt,gic-version=host -cpu host
....@@ -217,9 +215,6 @@
217215 then
218216 echo -device spapr-vlan,netdev=net0,mac=$TORTURE_QEMU_MAC
219217 echo -netdev bridge,br=br0,id=net0
220
- elif test -n "$TORTURE_QEMU_INTERACTIVE"
221
- then
222
- echo -net nic -net user
223218 fi
224219 ;;
225220 esac
....@@ -236,7 +231,7 @@
236231 # Returns the number of virtual CPUs available to the aggregate of the
237232 # guest OSes.
238233 identify_qemu_vcpus () {
239
- lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://'
234
+ lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://' -e 's/[ ]*//g'
240235 }
241236
242237 # print_bug
....@@ -277,3 +272,21 @@
277272 esac
278273 fi
279274 }
275
+
276
+# specify_qemu_net qemu-args
277
+#
278
+# Appends a string containing "-net none" to qemu-args, unless the incoming
279
+# qemu-args already contains "-smp" or unless the TORTURE_QEMU_INTERACTIVE
280
+# environment variable is set, in which case the string that is be added is
281
+# instead "-net nic -net user".
282
+specify_qemu_net () {
283
+ if echo $1 | grep -q -e -net
284
+ then
285
+ echo $1
286
+ elif test -n "$TORTURE_QEMU_INTERACTIVE"
287
+ then
288
+ echo $1 -net nic -net user
289
+ else
290
+ echo $1 -net none
291
+ fi
292
+}