From cfe33dd17a38880985e118080cec07ec1bc43b4f Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Mon, 1 Feb 2021 17:13:32 +0800 Subject: [PATCH 1/5] virttest: configure qemu upstream Upstream qemu can be configured to virttest Signed-off-by: Ke Zhiming --- tests/virttest | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/virttest b/tests/virttest index dffa8e9..d58a16e 100755 --- a/tests/virttest +++ b/tests/virttest @@ -188,24 +188,38 @@ config_virttest() { sed -i 's/^# \(migrate_dest_pwd = "${remote_pwd}"\)/\1/' $libvirt_base_cfg } +config_qemu_san() { + profile=/etc/profile + lsan_file=/home/suppfile + echo "export LSAN_OPTIONS=suppressions=$lsan_file" >> $profile + echo "export ASAN_OPTIONS=detect_leaks=1:halt_on_error=0:log_path=/home/sanlog/:log_exe_name=1:disable_coredump=0:fast_unwind_on_malloc=0" >> $profile + source $profile + mkdir -p /home/sanlog + chmod 777 /home/sanlog/ + yum install -y libasan +} + prepare_qemu_san() { if [ x$qemu_san == x"enable" ] && [ ! -d /virttest_san_rpm_bak ]; then [ -d /virttest_san_rpm ] || die "Makepkg is short of san packages and needs to be remakepkg with qemu_san/libvirt_san enable" rpm -Uvh /virttest_san_rpm/*.rpm --force || exit $? - # config qemu asan - profile=/etc/profile - echo "export LSAN_OPTIONS=suppressions=/home/suppfile" >> $profile - echo "export ASAN_OPTIONS=detect_leaks=1:halt_on_error=0:log_path=/home/sanlog/:log_exe_name=1:disable_coredump=0:fast_unwind_on_malloc=0" >> $profile - source $profile - mkdir -p /home/sanlog - chmod 777 /home/sanlog/ + config_qemu_san mv /virttest_san_rpm /virttest_san_rpm_bak fi } +prepare_upstream_qemu_san() { + upstream_qemu_path="/usr/libexec/upstream_qemu" + if [ x$upstream_qemu_san == x"enable" ] && [ ! -h /usr/libexec/qemu-kvm ]; then + ln -sf $upstream_qemu_path/qemu-system-$arch /usr/libexec/qemu-kvm + ln -sf $upstream_qemu_path/qemu-img $(which qemu-img) + config_qemu_san + fi +} + # upload sanlog upload_sanlog() { - if [ x$qemu_san == x"enable" ]; then + if [ x$qemu_san == x"enable" -o x$upstream_qemu_san == x"enable" ]; then echo "$vt_reference" > "/home/sanlog/date.log" upload_files -t results "/home/sanlog" rm -rf /home/sanlog/* @@ -385,6 +399,7 @@ run_reference_test() { } prepare_qemu_san +prepare_upstream_qemu_san config_bash_prompt config_umask config_qemu_conf -- Gitee From 889ab738f360854c34f1c0451ea17f04dc59e431 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Mon, 1 Feb 2021 17:19:25 +0800 Subject: [PATCH 2/5] virttest: disable qemu.conf seccomp_sandbox Disable qemu.conf seccom_sandbox so that libvirt can start vm use upstream qemu with enable_sanitizers Signed-off-by: Ke Zhiming --- tests/virttest | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/virttest b/tests/virttest index d58a16e..a460a7c 100755 --- a/tests/virttest +++ b/tests/virttest @@ -246,6 +246,9 @@ config_qemu_conf() { if [ ! -e /etc/libvirt/qemu.conf.bak_by_CI ];then cp /etc/libvirt/qemu.conf /etc/libvirt/qemu.conf.bak_by_CI sed -i 's/^#user/user/;s/^#group/group/' /etc/libvirt/qemu.conf + if [ x$upstream_qemu_san == x"enable" ] && [ x$qemu_san != x"enable" ]; then + sed -i 's/\#seccomp_sandbox = 1/seccomp_sandbox = 0/g' /etc/libvirt/qemu.conf + fi fi } -- Gitee From fe88c10d90d19f4bd368a1d1edf27347df7a7520 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Mon, 1 Feb 2021 20:32:18 +0800 Subject: [PATCH 3/5] virttest: touch the file witch LSAN_OPTIONS set Touch the file witch LSAN_OPTIONS set before use qemu-kvm Signed-off-by: Ke Zhiming --- tests/virttest | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/virttest b/tests/virttest index a460a7c..f31dc00 100755 --- a/tests/virttest +++ b/tests/virttest @@ -196,6 +196,7 @@ config_qemu_san() { source $profile mkdir -p /home/sanlog chmod 777 /home/sanlog/ + touch $lsan_file yum install -y libasan } -- Gitee From b31a37e43367e6dac7ede254548923e576231a22 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Mon, 1 Feb 2021 20:39:40 +0800 Subject: [PATCH 4/5] virttest: prepare upstream qemu san when qemu_san != enable Prepare upstream qemu san when qemu_san not set enable Signed-off-by: Ke Zhiming --- tests/virttest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/virttest b/tests/virttest index f31dc00..e795136 100755 --- a/tests/virttest +++ b/tests/virttest @@ -211,7 +211,7 @@ prepare_qemu_san() { prepare_upstream_qemu_san() { upstream_qemu_path="/usr/libexec/upstream_qemu" - if [ x$upstream_qemu_san == x"enable" ] && [ ! -h /usr/libexec/qemu-kvm ]; then + if [ x$upstream_qemu_san == x"enable" ] && [ ! -h /usr/libexec/qemu-kvm ] && [ x$qemu_san != x"enable" ]; then ln -sf $upstream_qemu_path/qemu-system-$arch /usr/libexec/qemu-kvm ln -sf $upstream_qemu_path/qemu-img $(which qemu-img) config_qemu_san -- Gitee From 334b5af5db18ad57b7818ee6d032672b3dbba07b Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Tue, 2 Feb 2021 17:31:30 +0800 Subject: [PATCH 5/5] virttest: determine whether the dir exists in prepare_upstream_qemu_san Determine whether the directory exists in prepare_upstream_qemu_san. if it does not exist, report an error and exit Signed-off-by: Ke Zhiming --- tests/virttest | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/virttest b/tests/virttest index e795136..dd5896c 100755 --- a/tests/virttest +++ b/tests/virttest @@ -212,6 +212,7 @@ prepare_qemu_san() { prepare_upstream_qemu_san() { upstream_qemu_path="/usr/libexec/upstream_qemu" if [ x$upstream_qemu_san == x"enable" ] && [ ! -h /usr/libexec/qemu-kvm ] && [ x$qemu_san != x"enable" ]; then + [ -d $upstream_qemu_path ] || die "Makepkg is short of upstream qemu san file and needs to be remakepkg with upstream_qemu_san enable" ln -sf $upstream_qemu_path/qemu-system-$arch /usr/libexec/qemu-kvm ln -sf $upstream_qemu_path/qemu-img $(which qemu-img) config_qemu_san -- Gitee