Skip to content

Commit db2b538

Browse files
committed
tools: qemu64-tpm.sh: make TPM optional
1 parent 4e99075 commit db2b538

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

tools/x86_fsp/qemu/qemu64-tpm.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ set -e
4040
set -x
4141

4242
# Parse command line options
43-
while getopts "d:wp" opt; do
43+
while getopts "d:wpt" opt; do
4444
case "$opt" in
4545
d)
4646
DEBUG_STAGE="$OPTARG"
@@ -51,9 +51,13 @@ while getopts "d:wp" opt; do
5151
p)
5252
CREATE_PIPE=true
5353
;;
54+
t) ENABLE_TPM=true
55+
;;
5456
*)
5557
echo "Usage: $0 [-d DEBUG_STAGE1 | DEBUG_STAGE2] [-w] [-p]"
5658
echo "-p : create /tmp/qemu_mon.in and /tmp/qemu_mon.out pipes for monitor qemu"
59+
echo "-w : wait for GDB to connect to the QEMU gdb server"
60+
echo "-t : enable TPM emulation (requires swtpm)"
5761
exit 1
5862
;;
5963
esac
@@ -102,14 +106,17 @@ else
102106
QEMU=qemu-system-x86_64
103107
fi
104108

105-
killall swtpm || true
106-
sleep 1
107-
echo TPM Emulation ON
108-
mkdir -p /tmp/swtpm
109-
swtpm socket --tpm2 --tpmstate dir=/tmp/swtpm \
110-
--ctrl type=unixio,path=/tmp/swtpm/swtpm-sock --log level=20 &
111-
sleep .5
112-
echo Running QEMU...
109+
if [ "$ENABLE_TPM" = true ]; then
110+
killall swtpm || true
111+
sleep 1
112+
echo TPM Emulation ON
113+
mkdir -p /tmp/swtpm
114+
swtpm socket --tpm2 --tpmstate dir=/tmp/swtpm \
115+
--ctrl type=unixio,path=/tmp/swtpm/swtpm-sock --log level=20 &
116+
sleep .5
117+
QEMU_OPTIONS+=$QEMU_TPM_OPTIONS
118+
fi
113119

114-
echo "$QEMU $QEMU_OPTIONS $QEMU_TPM_OPTIONS"
115-
$QEMU $QEMU_OPTIONS $QEMU_TPM_OPTIONS
120+
echo Running QEMU...
121+
echo "$QEMU $QEMU_OPTIONS"
122+
$QEMU $QEMU_OPTIONS

0 commit comments

Comments
 (0)