[PATCH v5 03/13] CI: Add driver domains tests
Marek Marczykowski-Górecki <[email protected]> Wed, 5 Aug 2026 16:55:31 +0200
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <20b70bd488f533cdaa8e72a92a69afc0d5de4d7d.1785941707.git-series.marmarek@invisiblethingslab.com> |
Setup a simple two domU system. One with network backend, running xendriverdomain service, and one with frontend, trying to ping the backend. Contrary to other similar tests, use disk image instead of initrd, to allow bigger rootfs without adding more RAM (for both dom0 and domU). But keep using pxelinux as a bootloader as it's easier to setup than installing grub on the disk. Theoretically, it could be started via direct kernel boot in QEMU, but pxelinux is slightly closer to real-world deployment. Use fakeroot to preserve file owners/permissions. This is especially important for suid binaries like /bin/mount - without fakeroot, they will end up as suid into non-root user. Signed-off-by: Marek Marczykowski-Górecki <[email protected]> --- Changes in v5: - add code comment about sparse files Changes in v3: - add fakeroot - run ldconfig at the disk image creation time, to avoid running it at dom0/domU boot time (which is much slower) Changes in v2: - use heredoc - limit ping loop iterations - use full "backend" / "frontend" in disk image names - print domU consoles directly to /dev/console, to avoid systemd-added messages prefix - terminate test on failure, don't wait for timeout Needs debian/13-x86_64 container rebuild. --- automation/build/debian/13-x86_64.dockerfile | 2 +- automation/gitlab-ci/test.yaml | 8 +- automation/scripts/qemu-driverdomains-x86_64.sh | 135 +++++++++++++++++- 3 files changed, 145 insertions(+) create mode 100755 automation/scripts/qemu-driverdomains-x86_64.sh diff --git a/automation/build/debian/13-x86_64.dockerfile b/automation/build/debian/13-x86_64.dockerfile index 784299d52dc3..5088f7435c1e 100644 --- a/automation/build/debian/13-x86_64.dockerfile +++ b/automation/build/debian/13-x86_64.dockerfile @@ -56,7 +56,9 @@ RUN <<EOF # for test phase, qemu-* jobs busybox-static + e2fsprogs expect + fakeroot ovmf qemu-system-x86 diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml index 61adc1baff30..566d1f4287d7 100644 --- a/automation/gitlab-ci/test.yaml +++ b/automation/gitlab-ci/test.yaml @@ -733,6 +733,14 @@ qemu-alpine-x86_64-gcc: - *x86_64-test-needs - alpine-3.24-x86_64-gcc +qemu-alpine-driverdomains-x86_64-gcc: + extends: .qemu-x86_64 + script: + - ./automation/scripts/qemu-driverdomains-x86_64.sh 2>&1 | tee ${LOGFILE} + needs: + - *x86_64-test-needs + - alpine-3.24-x86_64-gcc + qemu-smoke-x86_64-gcc: extends: .qemu-smoke-x86_64 script: diff --git a/automation/scripts/qemu-driverdomains-x86_64.sh b/automation/scripts/qemu-driverdomains-x86_64.sh new file mode 100755 index 000000000000..bada6599842e --- /dev/null +++ b/automation/scripts/qemu-driverdomains-x86_64.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +set -ex -o pipefail + +cd binaries + +# DomU rootfs + +mkdir -p rootfs +cd rootfs +mkdir -p etc/local.d +passed="ping test passed" +failed="TEST FAILED" +cat > etc/local.d/xen.start << EOF +#!/bin/bash + +set -x + +if grep -q test=backend /proc/cmdline; then + brctl addbr xenbr0 + ip link set xenbr0 up + ip addr add 192.168.0.1/24 dev xenbr0 + bash /etc/init.d/xendriverdomain start + # log backend-related logs to the console + tail -F /var/log/xen/xldevd.log /var/log/xen/xen-hotplug.log >>/dev/console 2>/dev/null & +else + ip link set eth0 up + ip addr add 192.168.0.2/24 dev eth0 + timeout=6 # 6*10s + until ping -c 10 192.168.0.1; do + sleep 1 + if [ \$timeout -le 0 ]; then + echo "${failed}" + exit 1 + fi + ((timeout--)) + done + echo "${passed}" +fi +EOF +chmod +x etc/local.d/xen.start +fakeroot sh -c " + zcat ../rootfs.cpio.gz | cpio -imd + zcat ../xen-tools.cpio.gz | cpio -imd + ldconfig -r . + touch etc/.updated + # this is a sparse file, not really using full 1GiB + mkfs.ext4 -d . ../domU-rootfs.img 1024M +" +cd .. +rm -rf rootfs + +# Dom0 rootfs +mkdir -p rootfs +cd rootfs +fakeroot -s ../fakeroot-save sh -c " + zcat ../rootfs.cpio.gz | cpio -imd + zcat ../xen-tools.cpio.gz | cpio -imd + ldconfig -r . + touch etc/.updated +" +mkdir -p root etc/local.d +cat > root/backend.cfg << EOF +name="backend" +memory=512 +vcpus=1 +kernel="/root/bzImage" +extra="console=hvc0 root=/dev/xvda net.ifnames=0 test=backend" +disk=[ '/root/domU-rootfs-backend.img,raw,xvda,rw' ] +EOF +cat > root/frontend.cfg << EOF +name="frontend" +memory=512 +vcpus=1 +kernel="/root/bzImage" +extra="console=hvc0 root=/dev/xvda net.ifnames=0 test=frontend" +disk=[ '/root/domU-rootfs-frontend.img,raw,xvda,rw' ] +vif=[ 'bridge=xenbr0,backend=backend' ] +EOF + +cat > etc/local.d/xen.start << EOF +#!/bin/bash + +set -x + +bash /etc/init.d/xencommons start + +xl list + +tail -F /var/log/xen/console/guest-backend.log 2>/dev/null | sed -e "s/^/(backend) /" >>/dev/console & +tail -F /var/log/xen/console/guest-frontend.log 2>/dev/null | sed -e "s/^/(frontend) /" >>/dev/console & +xl -vvv create /root/backend.cfg +xl -vvv create /root/frontend.cfg +EOF +chmod +x etc/local.d/xen.start + +cp ../domU-rootfs.img ./root/domU-rootfs-backend.img +cp ../domU-rootfs.img ./root/domU-rootfs-frontend.img +cp ../bzImage ./root/ +mkdir -p etc/default +echo 'XENCONSOLED_TRACE=all' >> etc/default/xencommons +mkdir -p var/log/xen/console +# this is a sparse file, not really using full 2GiB +fakeroot -i ../fakeroot-save mkfs.ext4 -d . ../dom0-rootfs.img 2048M +cd .. +rm -rf rootfs + +cd .. + +cat >> binaries/pxelinux.0 << EOF +#!ipxe + +kernel xen console=com1 console_timestamps=boot +module bzImage console=hvc0 root=/dev/sda net.ifnames=0 +boot +EOF + +# Run the test +rm -f smoke.serial +export TEST_CMD="qemu-system-x86_64 \ + -cpu qemu64,+svm \ + -m 2G -smp 2 \ + -monitor none -serial stdio \ + -nographic \ + -device virtio-net-pci,netdev=n0 \ + -netdev user,id=n0,tftp=binaries,bootfile=/pxelinux.0 \ + -drive file=binaries/dom0-rootfs.img,format=raw" + +export TEST_LOG="smoke.serial" +export BOOT_MSG="Latest ChangeSet: " +# exit early on test failure too, check if it was success below +export LOG_MSG="$passed|$failed" +export PASSED="$passed" + +./automation/scripts/console.exp | sed 's/\r\+$//' -- git-series 0.9.1