Skip to content

Commit f502c03

Browse files
qemu: enable replay (#14181)
This is for Chronos: https://github.com/google/oss-fuzz/tree/master/infra/experimental/chronos Signed-off-by: David Korczynski <[email protected]>
1 parent 3a0965a commit f502c03

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

projects/qemu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ RUN git clone --depth 1 https://gitlab.gnome.org/GNOME/glib.git --branch=$glib_t
2828

2929
RUN git clone --depth 1 https://git.qemu.org/git/qemu.git qemu
3030
WORKDIR qemu
31-
COPY run_tests.sh build.sh $SRC/
31+
COPY run_tests.sh build.sh replay_build.sh $SRC/

projects/qemu/replay_build.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash -eux
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
OSS_FUZZ_BUILD_DIR="./build-oss-fuzz/"
19+
cd $OSS_FUZZ_BUILD_DIR
20+
21+
# Prepare third party libraries directory
22+
DEST_DIR=$OUT
23+
mkdir -p "$DEST_DIR/lib/"
24+
25+
# Build fuzzing harnesses and libs
26+
make "-j$(nproc)" qemu-fuzz-i386 V=1
27+
28+
# Install data files
29+
make install DESTDIR=$DEST_DIR/qemu-bundle
30+
rm -rf $DEST_DIR/qemu-bundle/opt/qemu-oss-fuzz/bin
31+
rm -rf $DEST_DIR/qemu-bundle/opt/qemu-oss-fuzz/libexec
32+
33+
34+
# Copy over the librarise needed by the fuzzer.
35+
# These are the libraries copied from https://github.com/qemu/qemu/blob/88b1716a407459c8189473e4667653cb8e4c3df7/scripts/oss-fuzz/build.sh#L78
36+
# We do it this way, to avoid calling `configure`, which is called twice in the
37+
# build.sh.
38+
# Configure poses problems because it relies on network activity and also
39+
# performance is a lot better without configure.
40+
cp /lib/x86_64-linux-gnu/libstdc++.so.6 /out/lib/
41+
cp /lib/x86_64-linux-gnu/libpixman-1.so.0 /out/lib/
42+
cp /lib/x86_64-linux-gnu/libz.so.1 /out/lib/
43+
cp /lib/x86_64-linux-gnu/libfdt.so.1 /out/lib/
44+
cp /lib/x86_64-linux-gnu/libgio-2.0.so.0 /out/lib/
45+
cp /lib/x86_64-linux-gnu/libgobject-2.0.so.0 /out/lib/
46+
cp /lib/x86_64-linux-gnu/libglib-2.0.so.0 /out/lib/
47+
cp /lib/x86_64-linux-gnu/libslirp.so.0 /out/lib/
48+
cp /lib/x86_64-linux-gnu/libutil.so.1 /out/lib/
49+
cp /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 /out/lib/
50+
cp /lib/x86_64-linux-gnu/libm.so.6 /out/lib/
51+
cp /lib/x86_64-linux-gnu/libpthread.so.0 /out/lib/
52+
cp /lib/x86_64-linux-gnu/librt.so.1 /out/lib/
53+
cp /lib/x86_64-linux-gnu/libdl.so.2 /out/lib/
54+
cp /lib/x86_64-linux-gnu/libresolv.so.2 /out/lib/
55+
cp /lib/x86_64-linux-gnu/libgcc_s.so.1 /out/lib/
56+
cp /lib/x86_64-linux-gnu/libc.so.6 /out/lib/
57+
cp /lib/x86_64-linux-gnu/libffi.so.7 /out/lib/
58+
59+
export ASAN_OPTIONS=detect_leaks=0
60+
targets=$(./qemu-fuzz-i386 | grep generic-fuzz | awk '$1 ~ /\*/ {print $2}')
61+
base_copy="$DEST_DIR/qemu-fuzz-i386-target-$(echo "$targets" | head -n 1)"
62+
63+
cp "./qemu-fuzz-i386" "$base_copy"
64+
65+
# Generate the actual fuzzing harnesses
66+
for target in $(echo "$targets" | tail -n +2);
67+
do
68+
# Skip generic harness.
69+
if [[ $target == "generic-fuzz-"* ]]; then
70+
ln $base_copy \
71+
"$DEST_DIR/qemu-fuzz-i386-target-$target"
72+
fi
73+
done

0 commit comments

Comments
 (0)