From 0f46eed2074c7f35696bb268499cfeeea2438448 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 2 Oct 2026 08:15:36 -0400 Subject: [PATCH] bootc-host-setup: Keep the libvirt session daemon for the whole job bcvk and bootc CI intermittently fail with "Failed to connect socket to '/run/user/1001/libvirt/libvirt-sock': No such file or directory" (bootc-dev/bootc#1843). The libvirt client auto-spawns the session daemon with --timeout=120; when it exits on idle it removes its socket before it releases its pidfile, and a client connecting in between spawns a daemon that exits at once and then gives up after five seconds. It shows up right after test steps that went two minutes without touching libvirt. bcvk now retries in that case (bootc-dev/bcvk#394), but a daemon that never idles out avoids the window entirely, including for the pinned bcvk release. Rather than starting a daemon by hand, connect once (which spawns it, or reuses one that is already running) and turn off its idle timeout with virt-admin, so this works whichever daemon the client picked and is safe to run twice. The test workflow now checks that the daemon is still the same process well past 120 idle seconds and that bcvk can talk to it. Generated-by: AI --- .github/workflows/test-virtualization.yml | 32 +++++++++++++++++++++++ bootc-host-setup/ci/workarounds.sh | 30 ++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-virtualization.yml b/.github/workflows/test-virtualization.yml index 58cf74e..79736f0 100644 --- a/.github/workflows/test-virtualization.yml +++ b/.github/workflows/test-virtualization.yml @@ -42,6 +42,16 @@ jobs: with: libvirt: true + - name: Record the libvirt session daemon + id: libvirt + shell: bash + run: | + set -euo pipefail + pid=$(pgrep -u "$(id -u)" -x 'libvirtd|virtqemud') + test "$(wc -l <<<"$pid")" -eq 1 + ps -o pid=,args= -p "$pid" + printf 'pid=%s\nrecorded=%s\n' "$pid" "$(date +%s)" >> "$GITHUB_OUTPUT" + - name: Verify host QEMU and select acceleration id: qemu shell: bash @@ -146,6 +156,28 @@ jobs: done exit "$main_status" + # Nothing above touched libvirt after the host setup, so a session + # daemon with the default idle timeout (120s) would have exited by now. + - name: Check that the libvirt session daemon outlives its idle timeout + shell: bash + env: + DAEMON_PID: ${{ steps.libvirt.outputs.pid }} + RECORDED: ${{ steps.libvirt.outputs.recorded }} + run: | + set -euo pipefail + idle_timeout=120 + remaining=$((RECORDED + idle_timeout + 30 - $(date +%s))) + if [ "$remaining" -gt 0 ]; then + sleep "$remaining" + fi + ps -o pid=,args= -p "$DAEMON_PID" + if command -v bcvk >/dev/null; then + bcvk libvirt list + else + virsh -c qemu:///session list --all + fi + test "$(pgrep -u "$(id -u)" -x 'libvirtd|virtqemud')" = "$DAEMON_PID" + - name: Upload smoke diagnostics if: ${{ always() && steps.qemu.outputs.full_vm_smoke == 'true' }} uses: actions/upload-artifact@v7 diff --git a/bootc-host-setup/ci/workarounds.sh b/bootc-host-setup/ci/workarounds.sh index c394c5d..8b987e4 100644 --- a/bootc-host-setup/ci/workarounds.sh +++ b/bootc-host-setup/ci/workarounds.sh @@ -99,8 +99,36 @@ EOF printf 'LIBVIRT_DEFAULT_URI=qemu:///session\n' >> "$GITHUB_ENV" } +# The libvirt client auto-spawns the qemu:///session daemon with --timeout=120. +# When that daemon exits on idle it removes its socket before it releases its +# pidfile, and a client connecting in between fails with "Failed to connect +# socket to '.../libvirt-sock': No such file or directory" +# (https://github.com/bootc-dev/bootc/issues/1843). Keep one daemon for the +# whole job instead: connecting starts it, or finds one already running, and +# virt-admin then turns off its idle timeout. This runs last so the daemon +# sees the final QEMU and /dev/kvm permissions when it probes capabilities; +# later steps get this daemon, with this step's environment. Failing here +# only brings the race back, so it is a warning. +keep_ubuntu_libvirt_session() { + [ "$libvirt" = true ] || return 0 + local daemon output errors="" + virsh -c qemu:///session uri + # Ubuntu's client spawns the monolithic libvirtd; virtqemud covers a switch + # to the modular daemons. + for daemon in libvirtd virtqemud; do + if output=$(virt-admin -q -c "${daemon}:///session" daemon-timeout --timeout 0 2>&1); then + printf 'Turned off the idle timeout of the %s session daemon:\n' "$daemon" + pgrep -a -u "$(id -u)" -x "$daemon" + return 0 + fi + errors+="${daemon}: ${output}"$'\n' + done + printf '::warning::Could not turn off the idle timeout of the libvirt session daemon:\n%s' "$errors" >&2 + return 0 +} + case "$ID" in - ubuntu) setup_ubuntu_kvm; setup_ubuntu_qemu; setup_ubuntu_apparmor ;; + ubuntu) setup_ubuntu_kvm; setup_ubuntu_qemu; setup_ubuntu_apparmor; keep_ubuntu_libvirt_session ;; rhel) setup_rhel_libvirt ;; *) printf 'Unsupported host ID: %s\n' "$ID" >&2; exit 1 ;; esac