Skip to content

Commit fa53e6a

Browse files
chp-iobrendank310
authored andcommitted
utils: Add qemu_strace.sh script to trace IOCTLs
This script allows us to trace the IOCTLs made by Qemu on Linux. This is very useful in order to verify or debug our progress. The following arguments were added to this script: - setup (sets up the directory used by the Qemu) - run (runs Qemu with a simple UEFI VM) The following environment variables can be overridden: - STRACE_PATH - QEMU_PATH - BUILD_DIR While running Qemu, a ./qemu/strace.log file will be generated containing all of the IOCTLs made by Qemu.
1 parent db66c6f commit fa53e6a

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

utils/linux/qemu_strace.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Notes:
5+
#
6+
# Before running this script, OVMF needs to be installed. e.g. on Ubuntu:
7+
# sudo apt install ovmf
8+
#
9+
10+
# Default variables
11+
12+
if [ -z ${QEMU_PATH+x} ]; then
13+
QEMU_PATH=$(dirname $(which qemu-system-x86_64))
14+
fi
15+
16+
if [ -z ${STRACE_PATH+x} ]; then
17+
STRACE_PATH=$(dirname $(which strace))
18+
fi
19+
20+
if [ -z ${BUILD_DIR+x} ]; then
21+
BUILD_DIR="$(pwd)/qemu"
22+
fi
23+
24+
echo STRACE_PATH=${STRACE_PATH}
25+
echo QEMU_PATH=${QEMU_PATH}
26+
echo BUILD_DIR=${BUILD_DIR}
27+
echo
28+
29+
setup() {
30+
mkdir -p $BUILD_DIR/vm_storage/EFI/BOOT
31+
32+
cp /usr/share/OVMF/OVMF_CODE.fd $BUILD_DIR/
33+
cp /usr/share/OVMF/OVMF_VARS.fd $BUILD_DIR/
34+
35+
shell_url="https://github.com/tianocore/edk/blob/master/Other/Maintained/Application/UefiShell/bin/x64/Shell_Full.efi?raw=true"
36+
wget -O $BUILD_DIR/vm_storage/EFI/BOOT/BOOTX64.EFI $shell_url
37+
}
38+
39+
run() {
40+
echo Exit console with: ctrl + a, x
41+
42+
$STRACE_PATH/strace -f -o $BUILD_DIR/strace.log \
43+
$QEMU_PATH/qemu-system-x86_64 \
44+
-machine type=q35,accel=kvm \
45+
-cpu host \
46+
-drive format=raw,file=fat:rw:$BUILD_DIR/vm_storage \
47+
-bios $BUILD_DIR/OVMF_CODE.fd \
48+
-m size=2G \
49+
-nographic
50+
}
51+
52+
case "$1" in
53+
setup)
54+
setup
55+
;;
56+
57+
run)
58+
run
59+
;;
60+
61+
*)
62+
echo $"Usage: $0 {setup|run}"
63+
exit 1
64+
esac

0 commit comments

Comments
 (0)