Skip to contentSkip to conversation

Improvements for the Travis CI

PATCH In review Thomas Huth 4 participants 17 messages Nov 13, 2019 – Nov 14, 2019 KVM

lore
Share & tools
lore
#0 lore raw

cover Improvements for the Travis CI

The first two patches make the test matrix a little bit more flexible, and the fourth patch enables the 32-bit builds on x86.

But the most important patch is likely the third one: It is possible to test with KVM on Travis now, so we can run the tests within a real KVM environment, without TCG! The only caveat is that qemu-system-x86_64 has to run as root ... fixing only the permissions of /dev/kvm did not help here, I still got a "Permission denied" in that case.

Thomas Huth (5):
travis.yml: Re-arrange the test matrix
travis.yml: Install only the required packages for each entry in the
matrix
travis.yml: Test with KVM instead of TCG (on x86) travis.yml: Test the i386 build, too
travis.yml: Expect that at least one test succeeds

 .travis.yml | 155 +++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 104 insertions(+), 51 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/5 travis.yml: Re-arrange the test matrix

We will soon need more control over the individual test matrix entries, so we should not limit the matrix to "env" sections, i.e. put the "matrix:" keyword on the top, not the "env:".

---
 .travis.yml | 92 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 56 insertions(+), 36 deletions(-)
.travis.yml +56 -36
index 6c14953..611bbdc 100644
@@ -16,44 +16,64 @@ addons:
       - qemu-system
 git:
   submodules: false
-env:
-  matrix:
-    - CONFIG=""
-      BUILD_DIR="."
-      TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
+
+matrix:
+  include:
+    - env:
+      - CONFIG=""
+      - BUILD_DIR="."
+      - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
              vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
-    - CONFIG=""
-      BUILD_DIR="x86-builddir"
-      TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
+
+    - env:
+      - CONFIG=""
+      - BUILD_DIR="x86-builddir"
+      - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
              tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
-    - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
-      BUILD_DIR="."
-      TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
-    - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
-      BUILD_DIR="arm-buildir"
-      TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
-    - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
-    - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
-      BUILD_DIR="arm64-buildir"
-      TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
-    - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="spapr_hcall emulator rtas-set-time-of-day"
-      ACCEL="tcg,cap-htm=off"
-    - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
-      BUILD_DIR="ppc64le-buildir"
-      TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
-      ACCEL="tcg,cap-htm=off"
-    - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="diag10 diag308"
-      ACCEL="tcg,firmware=s390x/run"
-    - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
-      BUILD_DIR="s390x-builddir"
-      TESTS="sieve"
-      ACCEL="tcg,firmware=s390x/run"
+
+    - env:
+      - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
+      - BUILD_DIR="."
+      - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
+
+    - env:
+      - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
+      - BUILD_DIR="arm-buildir"
+      - TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
+
+    - env:
+      - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
+
+    - env:
+      - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
+      - BUILD_DIR="arm64-buildir"
+      - TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
+
+    - env:
+      - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="spapr_hcall emulator rtas-set-time-of-day"
+      - ACCEL="tcg,cap-htm=off"
+
+    - env:
+      - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
+      - BUILD_DIR="ppc64le-buildir"
+      - TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
+      - ACCEL="tcg,cap-htm=off"
+
+    - env:
+      - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="diag10 diag308"
+      - ACCEL="tcg,firmware=s390x/run"
+
+    - env:
+      - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
+      - BUILD_DIR="s390x-builddir"
+      - TESTS="sieve"
+      - ACCEL="tcg,firmware=s390x/run"
 
 before_script:
   - mkdir -p $BUILD_DIR && cd $BUILD_DIR
Signature · 1 line
2.23.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [kvm-unit-test PATCH 1/5] travis.yml: Re-arrange the test matrix

Quoted 5 lines · Thomas Huth

We will soon need more control over the individual test matrix entries, so we should not limit the matrix to "env" sections, i.e. put the "matrix:" keyword on the top, not the "env:".

Quoted 99 lines
---
 .travis.yml | 92 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 56 insertions(+), 36 deletions(-)
.travis.yml +49 -36
index 6c14953..611bbdc 100644
@@ -16,44 +16,64 @@ addons:
       - qemu-system
 git:
   submodules: false
-env:
-  matrix:
-    - CONFIG=""
-      BUILD_DIR="."
-      TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
+
+matrix:
+  include:
+    - env:
+      - CONFIG=""
+      - BUILD_DIR="."
+      - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
              vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
-    - CONFIG=""
-      BUILD_DIR="x86-builddir"
-      TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
+
+    - env:
+      - CONFIG=""
+      - BUILD_DIR="x86-builddir"
+      - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
              tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
-    - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
-      BUILD_DIR="."
-      TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
-    - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
-      BUILD_DIR="arm-buildir"
-      TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
-    - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
-    - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
-      BUILD_DIR="arm64-buildir"
-      TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
-    - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="spapr_hcall emulator rtas-set-time-of-day"
-      ACCEL="tcg,cap-htm=off"
-    - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
-      BUILD_DIR="ppc64le-buildir"
-      TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
-      ACCEL="tcg,cap-htm=off"
-    - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
-      BUILD_DIR="."
-      TESTS="diag10 diag308"
-      ACCEL="tcg,firmware=s390x/run"
-    - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
-      BUILD_DIR="s390x-builddir"
-      TESTS="sieve"
-      ACCEL="tcg,firmware=s390x/run"
+
+    - env:
+      - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
+      - BUILD_DIR="."
+      - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
+
+    - env:
+      - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
+      - BUILD_DIR="arm-buildir"
+      - TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
+
+    - env:
+      - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
+
+    - env:
+      - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
+      - BUILD_DIR="arm64-buildir"
+      - TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
+
+    - env:
+      - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="spapr_hcall emulator rtas-set-time-of-day"
+      - ACCEL="tcg,cap-htm=off"
+
+    - env:
+      - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
+      - BUILD_DIR="ppc64le-buildir"
+      - TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
+      - ACCEL="tcg,cap-htm=off"
+
+    - env:
+      - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
+      - BUILD_DIR="."
+      - TESTS="diag10 diag308"

.travis.yml addons: · line 79

Quoted 10 lines
.travis.yml +7 -0
+      - ACCEL="tcg,firmware=s390x/run"
+
+    - env:
+      - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
+      - BUILD_DIR="s390x-builddir"
+      - TESTS="sieve"
+      - ACCEL="tcg,firmware=s390x/run"
 
 before_script:
   - mkdir -p $BUILD_DIR && cd $BUILD_DIR

--
Alex Bennée

#3 lore raw

PATCH 2/5 travis.yml: Install only the required packages for each entry in the matrix

In reply to Thomas Huth

We don't need all cross compiler and QEMU versions for each and every entry in the test matrix, only the ones for the current target architecture. So let's speed up the installation process a little bit by only installing the packages that we really need.

---
 .travis.yml | 53 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 22 deletions(-)
.travis.yml +31 -22
index 611bbdc..3f5b5ee 100644
@@ -1,75 +1,84 @@
 sudo: false
 dist: bionic
 language: c
-compiler:
-  - gcc
 cache: ccache
-addons:
-  apt:
-    packages:
-      # Cross Toolchains
-      - gcc-arm-linux-gnueabihf
-      - gcc-aarch64-linux-gnu
-      - gcc-powerpc64le-linux-gnu
-      - gcc-s390x-linux-gnu
-      # Run dependencies
-      - qemu-system
 git:
   submodules: false
 
 matrix:
   include:
-    - env:
+
+    - addons:
+        apt_packages: gcc qemu-system-x86
+      env:
       - CONFIG=""
       - BUILD_DIR="."
       - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
              vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
 
-    - env:
+    - addons:
+        apt_packages: gcc qemu-system-x86
+      env:
       - CONFIG=""
       - BUILD_DIR="x86-builddir"
       - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
              tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
 
-    - env:
+    - addons:
+        apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
+      env:
       - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
       - BUILD_DIR="."
       - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
 
-    - env:
+    - addons:
+        apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
+      env:
       - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
       - BUILD_DIR="arm-buildir"
       - TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
 
-    - env:
+    - addons:
+        apt_packages: gcc-aarch64-linux-gnu qemu-system-aarch64
+      env:
       - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
       - BUILD_DIR="."
       - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
 
-    - env:
+    - addons:
+        apt_packages: gcc-aarch64-linux-gnu qemu-system-aarch64
+      env:
       - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
       - BUILD_DIR="arm64-buildir"
       - TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
 
-    - env:
+    - addons:
+        apt_packages: gcc-powerpc64le-linux-gnu qemu-system-ppc
+      env:
       - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
       - BUILD_DIR="."
       - TESTS="spapr_hcall emulator rtas-set-time-of-day"
       - ACCEL="tcg,cap-htm=off"
 
-    - env:
+    - addons:
+        apt_packages: gcc-powerpc64le-linux-gnu qemu-system-ppc
+      env:
       - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
       - BUILD_DIR="ppc64le-buildir"
       - TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
       - ACCEL="tcg,cap-htm=off"
 
-    - env:
+    - addons:
+        apt_packages: gcc-s390x-linux-gnu qemu-system-s390x
+      env:
       - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
       - BUILD_DIR="."
       - TESTS="diag10 diag308"
       - ACCEL="tcg,firmware=s390x/run"
 
-    - env:
+    - addons:
+        apt_packages: gcc-s390x-linux-gnu qemu-system-s390x
+      env:
       - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
       - BUILD_DIR="s390x-builddir"
       - TESTS="sieve"
Signature · 1 line
2.23.0
Reviewed-by on v1 2/5
#4 lore raw

Re: [kvm-unit-test PATCH 2/5] travis.yml: Install only the required packages for each entry in the matrix

Quoted 6 lines · Thomas Huth

We don't need all cross compiler and QEMU versions for each and every entry in the test matrix, only the ones for the current target architecture. So let's speed up the installation process a little bit by only installing the packages that we really need.

Quoted 105 lines
---
 .travis.yml | 53 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 22 deletions(-)
.travis.yml +28 -21
index 611bbdc..3f5b5ee 100644
@@ -1,75 +1,84 @@
 sudo: false
 dist: bionic
 language: c
-compiler:
-  - gcc
 cache: ccache
-addons:
-  apt:
-    packages:
-      # Cross Toolchains
-      - gcc-arm-linux-gnueabihf
-      - gcc-aarch64-linux-gnu
-      - gcc-powerpc64le-linux-gnu
-      - gcc-s390x-linux-gnu
-      # Run dependencies
-      - qemu-system
 git:
   submodules: false
 
 matrix:
   include:
-    - env:
+
+    - addons:
+        apt_packages: gcc qemu-system-x86
+      env:
       - CONFIG=""
       - BUILD_DIR="."
       - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
              vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
 
-    - env:
+    - addons:
+        apt_packages: gcc qemu-system-x86
+      env:
       - CONFIG=""
       - BUILD_DIR="x86-builddir"
       - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
              tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
 
-    - env:
+    - addons:
+        apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
+      env:
       - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
       - BUILD_DIR="."
       - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
 
-    - env:
+    - addons:
+        apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
+      env:
       - CONFIG="--arch=arm --cross-prefix=arm-linux-gnueabihf-"
       - BUILD_DIR="arm-buildir"
       - TESTS="pci-test pmu gicv2-active gicv3-active psci selftest-setup"
 
-    - env:
+    - addons:
+        apt_packages: gcc-aarch64-linux-gnu qemu-system-aarch64
+      env:
       - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
       - BUILD_DIR="."
       - TESTS="selftest-vectors-kernel selftest-vectors-user selftest-smp"
 
-    - env:
+    - addons:
+        apt_packages: gcc-aarch64-linux-gnu qemu-system-aarch64
+      env:
       - CONFIG="--arch=arm64 --cross-prefix=aarch64-linux-gnu-"
       - BUILD_DIR="arm64-buildir"
       - TESTS="pci-test pmu gicv2-active gicv3-active psci timer selftest-setup"
 
-    - env:
+    - addons:
+        apt_packages: gcc-powerpc64le-linux-gnu qemu-system-ppc
+      env:
       - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
       - BUILD_DIR="."
       - TESTS="spapr_hcall emulator rtas-set-time-of-day"
       - ACCEL="tcg,cap-htm=off"
 
-    - env:
+    - addons:
+        apt_packages: gcc-powerpc64le-linux-gnu qemu-system-ppc
+      env:
       - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-"
       - BUILD_DIR="ppc64le-buildir"
       - TESTS="rtas-get-time-of-day rtas-get-time-of-day-base"
       - ACCEL="tcg,cap-htm=off"
 
-    - env:
+    - addons:
+        apt_packages: gcc-s390x-linux-gnu qemu-system-s390x
+      env:
       - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
       - BUILD_DIR="."

.travis.yml line 84

Quoted 10 lines
.travis.yml +3 -1
       - TESTS="diag10 diag308"
       - ACCEL="tcg,firmware=s390x/run"
 
-    - env:
+    - addons:
+        apt_packages: gcc-s390x-linux-gnu qemu-system-s390x
+      env:
       - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-"
       - BUILD_DIR="s390x-builddir"
       - TESTS="sieve"

--
Alex Bennée

#5 lore raw

PATCH 3/5 travis.yml: Test with KVM instead of TCG (on x86)

In reply to Thomas Huth

Travis nowadays supports KVM in their CI pipelines, so we can finally run the kvm-unit-tests with KVM instead of TCG here. Unfortunately, there are some quirks: First, the QEMU binary has to be running as root, otherwise you get an "permission denied" error here - even if you fix up the access permissions to /dev/kvm first. Second, not all x86 tests are working in this environment, so we still have to manually select the test set here (but the amount of tests is definitely higher now than what we were able to run with TCG before).

---
 .travis.yml | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
.travis.yml +13 -5
index 3f5b5ee..f91118c 100644
@@ -1,4 +1,4 @@
-sudo: false
+sudo: true
 dist: bionic
 language: c
 cache: ccache
@@ -13,16 +13,21 @@ matrix:
       env:
       - CONFIG=""
       - BUILD_DIR="."
-      - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
-             vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
+      - TESTS="access asyncpf debug emulator ept hypercall hyperv_stimer
+               hyperv_synic idt_test intel_iommu ioapic ioapic-split
+               kvmclock_test msr pcid rdpru realmode rmap_chain s3 umip"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc qemu-system-x86
       env:
       - CONFIG=""
       - BUILD_DIR="x86-builddir"
-      - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
-             tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
+      - TESTS="smptest smptest3 tsc tsc_adjust xsave vmexit_cpuid vmexit_vmcall
+               sieve vmexit_inl_pmtimer vmexit_ipi_halt vmexit_mov_from_cr8
+               vmexit_mov_to_cr8 vmexit_ple_round_robin vmexit_tscdeadline
+               vmexit_tscdeadline_immed  vmx_apic_passthrough_thread syscall"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
@@ -85,6 +90,9 @@ matrix:
       - ACCEL="tcg,firmware=s390x/run"
 
 before_script:
+  - if [ "$ACCEL" = "kvm" ]; then
+      sudo chmod u+s /usr/bin/qemu-system-* ;
+    fi
   - mkdir -p $BUILD_DIR && cd $BUILD_DIR
   - if [ -e ./configure ]; then ./configure $CONFIG ; fi
   - if [ -e ../configure ]; then ../configure $CONFIG ; fi
Signature · 1 line
2.23.0
#6 lore raw

Re: [kvm-unit-test PATCH 3/5] travis.yml: Test with KVM instead of TCG (on x86)

Quoted 5 lines · Thomas Huth

Travis nowadays supports KVM in their CI pipelines, so we can finally run the kvm-unit-tests with KVM instead of TCG here. Unfortunately, there are some quirks: First, the QEMU binary has to be running as root, otherwise you get an "permission denied" error here - even if you fix up the access permissions to /dev/kvm first.

Could it be another resource it's trying to access?

Quoted 47 lines

Second, not all x86 tests are working in
this environment, so we still have to manually select the test set here (but the amount of tests is definitely higher now than what we were able to run with TCG before).

---
 .travis.yml | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
.travis.yml +10 -5
index 3f5b5ee..f91118c 100644
@@ -1,4 +1,4 @@
-sudo: false
+sudo: true
 dist: bionic
 language: c
 cache: ccache
@@ -13,16 +13,21 @@ matrix:
       env:
       - CONFIG=""
       - BUILD_DIR="."
-      - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
-             vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
+      - TESTS="access asyncpf debug emulator ept hypercall hyperv_stimer
+               hyperv_synic idt_test intel_iommu ioapic ioapic-split
+               kvmclock_test msr pcid rdpru realmode rmap_chain s3 umip"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc qemu-system-x86
       env:
       - CONFIG=""
       - BUILD_DIR="x86-builddir"
-      - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
-             tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
+      - TESTS="smptest smptest3 tsc tsc_adjust xsave vmexit_cpuid vmexit_vmcall
+               sieve vmexit_inl_pmtimer vmexit_ipi_halt vmexit_mov_from_cr8
+               vmexit_mov_to_cr8 vmexit_ple_round_robin vmexit_tscdeadline
+               vmexit_tscdeadline_immed  vmx_apic_passthrough_thread syscall"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm

.travis.yml matrix: · line 98

Quoted 9 lines
.travis.yml +3 -0
@@ -85,6 +90,9 @@ matrix:
       - ACCEL="tcg,firmware=s390x/run"
 
 before_script:
+  - if [ "$ACCEL" = "kvm" ]; then
+      sudo chmod u+s /usr/bin/qemu-system-* ;
+    fi
   - mkdir -p $BUILD_DIR && cd $BUILD_DIR
   - if [ -e ./configure ]; then ./configure $CONFIG ; fi
   - if [ -e ../configure ]; then ../configure $CONFIG ; fi

--
Alex Bennée

#7 lore raw

Re: [kvm-unit-test PATCH 3/5] travis.yml: Test with KVM instead of TCG (on x86)

Quoted 10 lines · Alex Bennée
Quoted 5 lines · Thomas Huth

Travis nowadays supports KVM in their CI pipelines, so we can finally run the kvm-unit-tests with KVM instead of TCG here. Unfortunately, there are some quirks: First, the QEMU binary has to be running as root, otherwise you get an "permission denied" error here - even if you fix up the access permissions to /dev/kvm first.

Could it be another resource it's trying to access?

I did some more tests with strace and some "ls -l /dev/kvm" spread around the scripts, and it seems like the permissions get reset on Debian when a process tries to open /dev/kvm ? I.e. after doing a "chmod", I correctly see:

crw-rw-rw- 1 root kvm 10, 232 Nov 13 15:03 /dev/kvm

... but after the run script tried to launch qemu, it's back to:

crw-rw---- 1 root kvm 10, 232 Nov 13 15:03 /dev/kvm

I assume some udev magic is enforcing this?

So it's as Paolo said in his mail, you need to be root or in the kvm group to be able to use KVM on Debian / Ubuntu. Unfortunately a simple "usermod -a -G kvm $USER" also does not seem to work here, since you need a new login shell to take the change into account ... well, I could then run the run_test.sh script through "sudo -E su $USER -c ..." [1] but that's ugly too.

But instead of doing "chmod u+s ...", this seems to be working, too:

sudo chgrp kvm /usr/bin/qemu-system-*
sudo chmod g+s /usr/bin/qemu-system-*

... which sounds like the least ugliest hack to me currently, so I think I'll go with that version.

Thomas

[1] That's also what Travis suggests here:
https://docs.travis-ci.com/user/reference/trusty/#group-membership

#8 lore raw

PATCH v2 1/1 travis.yml: Test with KVM instead of TCG (on x86)

Travis nowadays supports KVM in their CI pipelines, so we can finally run the kvm-unit-tests with KVM instead of TCG here. Unfortunately, there are some quirks:

First, /dev/kvm is not accessible on Ubuntu by default. You have to be "root" or in the "kvm" group to access it. But changing the group of the current user is not taking into account for the current shell process, so that would need some indirections in the yml file. Thus the yml script now rather changes the group and "g+s" permission of the qemu binary instead.

Second, not all x86 tests are working in this environment, so we still have to manually select the test set here (but the amount of tests is definitely higher now than what we were able to run with TCG before).

---
v2: Use chgrp + "chmod g+s" instead "chmod u+s" to get it running

 .travis.yml | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
.travis.yml +14 -5
index 3f5b5ee..89c50fe 100644
@@ -1,4 +1,4 @@
-sudo: false
+sudo: true
 dist: bionic
 language: c
 cache: ccache
@@ -13,16 +13,21 @@ matrix:
       env:
       - CONFIG=""
       - BUILD_DIR="."
-      - TESTS="vmexit_cpuid vmexit_mov_from_cr8 vmexit_mov_to_cr8 vmexit_ipi
-             vmexit_ple_round_robin vmexit_tscdeadline vmexit_tscdeadline_immed"
+      - TESTS="access asyncpf debug emulator ept hypercall hyperv_stimer
+               hyperv_synic idt_test intel_iommu ioapic ioapic-split
+               kvmclock_test msr pcid rdpru realmode rmap_chain s3 umip"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc qemu-system-x86
       env:
       - CONFIG=""
       - BUILD_DIR="x86-builddir"
-      - TESTS="ioapic-split ioapic smptest smptest3 eventinj msr port80 syscall
-             tsc rmap_chain umip intel_iommu vmexit_inl_pmtimer vmexit_ipi_halt"
+      - TESTS="smptest smptest3 tsc tsc_adjust xsave vmexit_cpuid vmexit_vmcall
+               sieve vmexit_inl_pmtimer vmexit_ipi_halt vmexit_mov_from_cr8
+               vmexit_mov_to_cr8 vmexit_ple_round_robin vmexit_tscdeadline
+               vmexit_tscdeadline_immed  vmx_apic_passthrough_thread syscall"
+      - ACCEL="kvm"
 
     - addons:
         apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
@@ -85,6 +90,10 @@ matrix:
       - ACCEL="tcg,firmware=s390x/run"
 
 before_script:
+  - if [ "$ACCEL" = "kvm" ]; then
+      sudo chgrp kvm /usr/bin/qemu-system-* ;
+      sudo chmod g+s /usr/bin/qemu-system-* ;
+    fi
   - mkdir -p $BUILD_DIR && cd $BUILD_DIR
   - if [ -e ./configure ]; then ./configure $CONFIG ; fi
   - if [ -e ../configure ]; then ../configure $CONFIG ; fi
Signature · 1 line
2.23.0
#9 lore raw

PATCH 4/5 travis.yml: Test the i386 build, too

In reply to Thomas Huth

After installing gcc-multilib, we can also test the 32-bit builds on Travis.

---
 .travis.yml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
.travis.yml +15 -0
index f91118c..9ceb04d 100644
@@ -29,6 +29,21 @@ matrix:
                vmexit_tscdeadline_immed  vmx_apic_passthrough_thread syscall"
       - ACCEL="kvm"
 
+    - addons:
+        apt_packages: gcc gcc-multilib qemu-system-x86
+      env:
+      - CONFIG="--arch=i386"
+      - BUILD_DIR="."
+      - TESTS="eventinj port80 sieve tsc taskswitch umip vmexit_ple_round_robin"
+
+    - addons:
+        apt_packages: gcc gcc-multilib qemu-system-x86
+      env:
+      - CONFIG="--arch=i386"
+      - BUILD_DIR="i386-builddir"
+      - TESTS="vmexit_mov_from_cr8 vmexit_ipi vmexit_ipi_halt vmexit_mov_to_cr8
+               vmexit_cpuid vmexit_tscdeadline vmexit_tscdeadline_immed"
+
     - addons:
         apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
       env:
Signature · 1 line
2.23.0
Reviewed-by on v1 4/5
#10 lore raw

Re: [kvm-unit-test PATCH 4/5] travis.yml: Test the i386 build, too

Quoted 4 lines · Thomas Huth

After installing gcc-multilib, we can also test the 32-bit builds on Travis.

Quoted 20 lines
---
 .travis.yml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
.travis.yml +8 -0
index f91118c..9ceb04d 100644
@@ -29,6 +29,21 @@ matrix:
                vmexit_tscdeadline_immed  vmx_apic_passthrough_thread syscall"
       - ACCEL="kvm"
 
+    - addons:
+        apt_packages: gcc gcc-multilib qemu-system-x86
+      env:
+      - CONFIG="--arch=i386"
+      - BUILD_DIR="."
+      - TESTS="eventinj port80 sieve tsc taskswitch umip vmexit_ple_round_robin"
+
+    - addons:

.travis.yml matrix: · line 49

Quoted 10 lines
.travis.yml +7 -0
+        apt_packages: gcc gcc-multilib qemu-system-x86
+      env:
+      - CONFIG="--arch=i386"
+      - BUILD_DIR="i386-builddir"
+      - TESTS="vmexit_mov_from_cr8 vmexit_ipi vmexit_ipi_halt vmexit_mov_to_cr8
+               vmexit_cpuid vmexit_tscdeadline vmexit_tscdeadline_immed"
+
     - addons:
         apt_packages: gcc-arm-linux-gnueabihf qemu-system-arm
       env:

--
Alex Bennée

#11 lore raw

PATCH 5/5 travis.yml: Expect that at least one test succeeds

In reply to Thomas Huth

While working on the travis.yml file, I've run into cases where all tests are reported as "SKIP" by the run_test.sh script (e.g. when QEMU could not be started). This should not result in a successful test run, so mark it as failed if not at least one test passed.

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
.travis.yml +1 -0
index 9ceb04d..aacf7d2 100644
@@ -115,3 +115,4 @@ script:
   - make -j3
   - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
   - if grep -q FAIL results.txt ; then exit 1 ; fi
+  - if ! grep -q PASS results.txt ; then exit 1 ; fi
Signature · 1 line
2.23.0
#12 lore raw

Re: [kvm-unit-test PATCH 5/5] travis.yml: Expect that at least one test succeeds

Quoted 5 lines · Thomas Huth

While working on the travis.yml file, I've run into cases where all tests are reported as "SKIP" by the run_test.sh script (e.g. when QEMU could not be started). This should not result in a successful test run, so mark it as failed if not at least one test passed.

But doesn't this mean you could have everything fail except one pass and still report success?

Quoted 11 lines
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
.travis.yml +0 -0
index 9ceb04d..aacf7d2 100644

.travis.yml script: · line 118

Quoted 4 lines
.travis.yml +1 -0
@@ -115,3 +115,4 @@ script:
   - make -j3
   - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
   - if grep -q FAIL results.txt ; then exit 1 ; fi
+  - if ! grep -q PASS results.txt ; then exit 1 ; fi

--
Alex Bennée

#13 lore raw

Re: [kvm-unit-test PATCH 5/5] travis.yml: Expect that at least one test succeeds

Quoted 11 lines · Alex Bennée
Quoted 5 lines · Thomas Huth

While working on the travis.yml file, I've run into cases where all tests are reported as "SKIP" by the run_test.sh script (e.g. when QEMU could not be started). This should not result in a successful test run, so mark it as failed if not at least one test passed.

But doesn't this mean you could have everything fail except one pass and still report success?

The FAILs are already handled one line earlier...

Quoted 6 lines
Quoted 6 lines
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
Quoted 8 lines

.travis.yml script: · line 117

Quoted 8 lines
.travis.yml +0 -0
index 9ceb04d..aacf7d2 100644
@@ -115,3 +115,4 @@ script:
   - make -j3
   - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
   - if grep -q FAIL results.txt ; then exit 1 ; fi

... here -----------^

Quoted 1 line

.travis.yml script: · line 118

Quoted 1 line
.travis.yml +1 -0
+  - if ! grep -q PASS results.txt ; then exit 1 ; fi

Maybe it would also be nicer to provide proper exit values in the run_tests.sh script, but the logic there gives me a bad headache... grep'ing for FAIL and PASS in the yml script is way more easy.

Thomas

Reviewed-by
#14 lore raw

Re: [kvm-unit-test PATCH 5/5] travis.yml: Expect that at least one test succeeds

Quoted 10 lines · Thomas Huth
Quoted 9 lines · Alex Bennée
Quoted 5 lines · Thomas Huth

While working on the travis.yml file, I've run into cases where all tests are reported as "SKIP" by the run_test.sh script (e.g. when QEMU could not be started). This should not result in a successful test run, so mark it as failed if not at least one test passed.

Quoted 4 lines
Quoted 2 lines

But doesn't this mean you could have everything fail except one pass and still report success?

The FAILs are already handled one line earlier...

Oops I should have noticed that:

Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
Quoted 8 lines

.travis.yml script: · line 117

Quoted 8 lines
.travis.yml +0 -0
index 9ceb04d..aacf7d2 100644
@@ -115,3 +115,4 @@ script:
   - make -j3
   - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
   - if grep -q FAIL results.txt ; then exit 1 ; fi

... here -----------^

Quoted 7 lines
Quoted 1 line

.travis.yml script: · line 118

Quoted 1 line
.travis.yml +1 -0
+  - if ! grep -q PASS results.txt ; then exit 1 ; fi

Maybe it would also be nicer to provide proper exit values in the run_tests.sh script, but the logic there gives me a bad headache... grep'ing for FAIL and PASS in the yml script is way more easy.

Thomas

--
Alex Bennée

maintainer
#15 lore raw
In reply to Thomas Huth
Quoted 8 lines · Thomas Huth

The first two patches make the test matrix a little bit more flexible, and the fourth patch enables the 32-bit builds on x86.

But the most important patch is likely the third one: It is possible to test with KVM on Travis now, so we can run the tests within a real KVM environment, without TCG! The only caveat is that qemu-system-x86_64 has to run as root ... fixing only the permissions of /dev/kvm did not help here, I still got a "Permission denied" in that case.

Ah, that's Debian. You need to be in group kvm or root to run KVM.

Looks good, can you include it in the next pull request?

Paolo

Quoted 11 lines

Thomas Huth (5):
travis.yml: Re-arrange the test matrix
travis.yml: Install only the required packages for each entry in the
matrix
travis.yml: Test with KVM instead of TCG (on x86) travis.yml: Test the i386 build, too
travis.yml: Expect that at least one test succeeds

 .travis.yml | 155 +++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 104 insertions(+), 51 deletions(-)
#16 lore raw
In reply to Thomas Huth
Quoted 17 lines · Thomas Huth

The first two patches make the test matrix a little bit more flexible, and the fourth patch enables the 32-bit builds on x86.

But the most important patch is likely the third one: It is possible to test with KVM on Travis now, so we can run the tests within a real KVM environment, without TCG! The only caveat is that qemu-system-x86_64 has to run as root ... fixing only the permissions of /dev/kvm did not help here, I still got a "Permission denied" in that case.

Thomas Huth (5):
travis.yml: Re-arrange the test matrix
travis.yml: Install only the required packages for each entry in the
matrix
travis.yml: Test with KVM instead of TCG (on x86) travis.yml: Test the i386 build, too
travis.yml: Expect that at least one test succeeds

Quoted 3 lines
  .travis.yml | 155 +++++++++++++++++++++++++++++++++++-----------------
  1 file changed, 104 insertions(+), 51 deletions(-)

As discussed, queued to

https://github.com/davidhildenbrand/kvm-unit-tests.git s390x-next

for now. PULL request early next week.

Signature · 3 lines
Thanks,

David / dhildenb