From 2b70fd491ba0be77333fadebea87422f7c4ce1db Mon Sep 17 00:00:00 2001 From: Martin Kalcok Date: Fri, 15 Dec 2023 13:11:44 +0100 Subject: [PATCH] Ubuntu cinc: Include 'perf' in the image. Ubuntu image was missing 'perf'. This change installs required package in the image and includes required workadound to make it work if the image is built on a machine with different kernel than kernel of the machine that runs the container. (more details in in-code comment) Signed-off-by: Martin Kalcok --- image/cinc/install_ubuntu_pkg.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/image/cinc/install_ubuntu_pkg.sh b/image/cinc/install_ubuntu_pkg.sh index d512b2f..f5d190c 100755 --- a/image/cinc/install_ubuntu_pkg.sh +++ b/image/cinc/install_ubuntu_pkg.sh @@ -26,6 +26,7 @@ apt install -yq --no-install-recommends \ libxslt1.1 \ lksctp-tools \ libsctp-dev \ + linux-tools-generic \ make \ meson \ net-tools \ @@ -64,3 +65,24 @@ systemctl mask \ mkdir -pv /bin /tmp/generate_dhclient_script_for_fullstack.sh / || \ echo "Failed to generate dhclient script for fullstack!" + +# Patch perf script. +# On Ubuntu, '/usr/bin/perf' is a shell script that tries to find perf binary +# that exactly matches current running kernel. This will break if +# ovn-fake-multinode container runs on a host with different kernel than the +# host that built the image. +# It's no ideal, but since the perf should be backwards compatible, we can +# circumvent this by linking '/usr/bin/perf' directly to an available +# binary in '/usr/lib/linux-tools-/perf' +PERF_PATH="" + +for PERF_BIN in $(ls /usr/lib/linux-tools-*/perf); do + PERF_PATH=$PERF_BIN +done + +if [ -z "$PERF_PATH" ]; then + echo "Failed to find perf binary" + exit 1 +fi + +ln -s -f "$PERF_PATH" /usr/bin/perf