From 4722b8cec099064f6e5e808410efe7f8d082b450 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Sun, 10 Dec 2023 22:58:09 +0000 Subject: [PATCH] LU-17000 contrib: script to prepare coverity builds Add script 'coverity-run' to semi-automate running and submitting Coverity builds for Lustre. This should make it much easier to reproducibly submit builds to Coverity - and serve as an example of how the Coverity build process works. It should also provide more transparency in how builds are being prepared for Coverity. Add a Vagrantfile for the Vagrant VM used during the build process. Update in-tree Documentation. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: I050b10d9df0e4e4c1b8bcc91a3c296c11f27ffef Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53400 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- .gitignore | 6 + Documentation/clang-and-static-analysis.txt | 4 +- Vagrantfile | 64 ++++++++++ contrib/coverity/.gitignore | 6 + contrib/coverity/coverity-run | 184 ++++++++++++++++++++++++++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile create mode 100644 contrib/coverity/.gitignore create mode 100755 contrib/coverity/coverity-run diff --git a/.gitignore b/.gitignore index ddf3e32..5423df6 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,12 @@ TAGS /.venv /venv +# Vagrant artifacts +.vagrant/ + +# Coverity results +*.tgz + # # Top level generic files # diff --git a/Documentation/clang-and-static-analysis.txt b/Documentation/clang-and-static-analysis.txt index 8230c8c..06b66d2 100644 --- a/Documentation/clang-and-static-analysis.txt +++ b/Documentation/clang-and-static-analysis.txt @@ -121,7 +121,9 @@ a Coverity bug should ideally have a line in the commit message like: This makes it easier to track which bugs still need to be fixed. Currently, the Coverity Scan project is maintained in an adhoc manner. Hence, the build may be outdated. But it -can be updated easily following the instructions on the site. +can be updated easily following the instructions on the site or using the script in +'contrib/coverity' in the Lustre tree. Running 'coverity-run list' will provide more +details. 4.2 References ============== diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..588fecf --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0 + +# +# This file is part of Lustre, http://www.lustre.org/ +# +# contrib/coverity/Vagrantfile +# +# Vagrant definition for a CentOS VM to run a Lustre +# build for Coverity. +# +# Author: Timothy Day +# + +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "centos/8" + + # Customizations + config.vm.provider "libvirt" do |libvirt| + libvirt.machine_virtual_size = 40 + libvirt.memory = 8192 + libvirt.cpus = 4 + end + + config.vm.provision "shell", inline: <<-SHELL + # Volume Setup + sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-* + sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-* + dnf update -y + dnf install -y cloud-utils-growpart + growpart /dev/vda 1 + xfs_growfs /dev/vda1 + + # Networking Setup + GIVEN_IP=$(ip address show eth0 | awk -F' ' '$1 == "inet" { print $2 }' | awk -F'/' '{ print $1 }') + grep $(hostname) /etc/hosts + sed -i "s/$(hostname) //g" /etc/hosts + echo "$GIVEN_IP $(hostname)" >> /etc/hosts + grep $(hostname) /etc/hosts + + # Add repos + dnf config-manager --set-enabled powertools + dnf config-manager --add-repo=https://downloads.whamcloud.com/public/e2fsprogs/latest/el8 + + # General kernel tools + dnf groupinstall -y 'Development Tools' + + # Debug info (needed for ldiskfs) + sudo dnf install -y --enablerepo=*debug* kernel-debuginfo + + # Install Lustre/ZFS dependencies and tools + dnf install -y --nogpgcheck git libyaml-devel libnl3-devel libmount-devel \ + wget ncurses-devel bc dwarves kernel kernel-devel openssl-devel \ + binutils-devel lsof crash kexec-tools perf psmisc e2fsprogs-devel \ + elfutils-libelf-devel libudev-devel libattr-devel libaio-devel libuuid-devel \ + libblkid-devel libtirpc-devel libffi-devel ncompress python3-cffi python3-devel \ + python3-packaging + SHELL +end diff --git a/contrib/coverity/.gitignore b/contrib/coverity/.gitignore new file mode 100644 index 0000000..4456f24 --- /dev/null +++ b/contrib/coverity/.gitignore @@ -0,0 +1,6 @@ +# Vagrant artifacts +.vagrant/ +vagrant-ssh.config + +# Coverity results +*.tgz diff --git a/contrib/coverity/coverity-run b/contrib/coverity/coverity-run new file mode 100755 index 0000000..6e0db09 --- /dev/null +++ b/contrib/coverity/coverity-run @@ -0,0 +1,184 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +# This file is part of Lustre, http://www.lustre.org/ +# +# contrib/coverity/coverity-run +# +# Setup a simple VM for running Coverity builds +# to upload to https://scan.coverity.com/projects/lustre +# +# Author: Timothy Day +# + +# +# Output list of all commands +# +function cr_list() { + less -F < build -> run -> clean + +The tool currently has a dependency on Vagrant and the 'libvirt' +provider. After the scan is run, there will be a tar file in the +'contrib/coverity' directory. This should be uploaded to Coverity +via the web portal using the Lustre version output during the +'run' step as the software version. +EOF + exit +} + +# +# Create VM using Vagrant. +# +function cr_setup() { + vagrant up + + # Save/test ssh config + vagrant ssh-config > vagrant-ssh.config + ssh -F vagrant-ssh.config default "uname -r" + + # Restart VM + vagrant reload +} + +# +# Perform a test build of ZFS and Lustre. User must +# validate that correct modules get built. +# +function cr_build() { + # Build ZFS + ssh -F vagrant-ssh.config default <