Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test-virtualization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion bootc-host-setup/ci/workarounds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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