Skip to content

Commit 06efa9b

Browse files
committed
torture: Add kvm-tranform.sh script for qemu-cmd files
This commit adds a script that transforms qemu-cmd files to allow them and the corresponding kernels to be run in contexts other than the one that they were created for, including on systems other than the one that they were built on. For example, this allows the build products from a --buildonly run to be transformed to allow distributed rcutorture testing. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 9ccba35 commit 06efa9b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0+
3+
#
4+
# Transform a qemu-cmd file to allow reuse.
5+
#
6+
# Usage: kvm-transform.sh bzImage console.log < qemu-cmd-in > qemu-cmd-out
7+
#
8+
# bzImage: Kernel and initrd from the same prior kvm.sh run.
9+
# console.log: File into which to place console output.
10+
#
11+
# The original qemu-cmd file is provided on standard input.
12+
# The transformed qemu-cmd file is on standard output.
13+
# The transformation assumes that the qemu command is confined to a
14+
# single line. It also assumes no whitespace in filenames.
15+
#
16+
# Copyright (C) 2020 Facebook, Inc.
17+
#
18+
# Authors: Paul E. McKenney <[email protected]>
19+
20+
image="$1"
21+
if test -z "$image"
22+
then
23+
echo Need kernel image file.
24+
exit 1
25+
fi
26+
consolelog="$2"
27+
if test -z "$consolelog"
28+
then
29+
echo "Need console log file name."
30+
exit 1
31+
fi
32+
33+
awk -v image="$image" -v consolelog="$consolelog" '
34+
{
35+
line = "";
36+
for (i = 1; i <= NF; i++) {
37+
if (line == "")
38+
line = $i;
39+
else
40+
line = line " " $i;
41+
if ($i == "-serial") {
42+
i++;
43+
line = line " file:" consolelog;
44+
}
45+
if ($i == "-kernel") {
46+
i++;
47+
line = line " " image;
48+
}
49+
}
50+
print line;
51+
}'

0 commit comments

Comments
 (0)