Skip to content

Libvirt - #44

Open
Villain88 wants to merge 28 commits into
mainfrom
libvirt
Open

Libvirt#44
Villain88 wants to merge 28 commits into
mainfrom
libvirt

Conversation

@Villain88

@Villain88 Villain88 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added libvirt-based VM launching for untrusted, TDX, and SEV-SNP workloads.
    • Added Ubuntu 24.04 and 26.04 libvirt package builds and downloadable archives.
    • Added VM preflight validation, networking options, device passthrough, port forwarding, and debug consoles.
    • Swarm clusters now run and monitor transient libvirt domains.
  • Improvements

    • Enhanced host setup, hardware validation, boot configuration, attestation, and diagnostics.
    • Updated build options and release naming for combined confidential-computing and libvirt packages.
    • VM startup scripts can now be safely sourced without launching a VM.
  • Documentation

    • Added setup, troubleshooting, package-building, and VM management guidance.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34038b05-4a62-4c26-9582-5026d064d9f7

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0143b5c1-eebd-4792-8cf6-8abb61fb6434

📥 Commits

Reviewing files that changed from the base of the PR and between 1892efd and 890753d.

📒 Files selected for processing (2)
  • README.md
  • scripts/setup_libvirt_host.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • scripts/setup_libvirt_host.sh

Walkthrough

This change adds libvirt host provisioning, transient VM launchers, libvirt-backed Swarm lifecycle management, and Ubuntu 24.04/26.04 libvirt package builds. It also updates TDX, SEV-SNP, GRUB, workflow, tests, and operational documentation.

Changes

Libvirt platform integration

Layer / File(s) Summary
Libvirt package build pipeline
.github/workflows/..., build/libvirt/...
The workflow adds SEV+TDX and libvirt targets. Docker builds validate source metadata, create Debian packages, generate checksums, and publish archives.
Libvirt host provisioning
scripts/setup_libvirt_host.sh, scripts/bootstrap_*.sh, scripts/common.sh, scripts/setup_tdx.sh, scripts/setup_snp.sh
The scripts install and verify libvirt, QEMU, passt, AppArmor, IOMMUFD, and mode-specific TDX or SEV-SNP requirements. GRUB and kernel-log handling now use release-specific and current-boot data.
Transient VM launch path
scripts/libvirt_launcher.py, scripts/start_super_protocol_libvirt.sh, scripts/start_super_protocol.sh
The launchers validate VM settings, generate transient-domain XML, configure devices and networking, prepare disks and permissions, and support serial consoles.
Libvirt-backed Swarm lifecycle
scripts/swarm-cluster.sh
Swarm tracks named libvirt domains, checks domain health, protects VFIO devices, and performs graceful shutdown with timeout cleanup.
Validation and documentation
tests/test_libvirt_launcher.py, README.md, docs/swarm.md, build/libvirt/README.md
Tests cover XML generation, capabilities, preflight dispatch, errors, and source safety. Documentation describes setup, packaging, launch, diagnostics, acceptance checks, and domain management.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: ⚪ Minimal · up to 89075

No actionable merge-blocking risk remains; the PR is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant swarm-cluster.sh
  participant start_super_protocol_libvirt.sh
  participant libvirt_launcher.py
  participant libvirt
  Operator->>swarm-cluster.sh: start a named cluster domain
  swarm-cluster.sh->>start_super_protocol_libvirt.sh: pass VM mode and resources
  start_super_protocol_libvirt.sh->>libvirt_launcher.py: run preflight and launch
  libvirt_launcher.py->>libvirt: validate capabilities and create transient domain
  libvirt->>swarm-cluster.sh: provide domain state
  swarm-cluster.sh->>libvirt: request shutdown or destroy after timeout
Loading

Poem

A rabbit checks the host with care,
Domains start in libvirt’s lair.
TDX and SNP pass the gate,
Packages build for twenty-four and twenty-six straight.
Swarm checks health, then shuts down light.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title relates to the main change, but “Libvirt” is too broad to identify the pull request’s primary implementation scope. Use a specific title such as “Add libvirt-based VM launching and package builds”.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch libvirt

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Nitpick comments (11)
build/libvirt/Dockerfile.ubuntu24 (2)

12-19: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

dpkg-parsechangelog and dpkg-buildpackage are not installed explicitly.

prepare-source.sh calls dpkg-parsechangelog and build-packages.sh calls dpkg-buildpackage. Both come from dpkg-dev. The image relies on dpkg-dev arriving as a transitive dependency of devscripts. Add dpkg-dev to the explicit install list so the image does not break if that dependency chain changes.

♻️ Proposed change
         devscripts
+        dpkg-dev \
         equivs \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/Dockerfile.ubuntu24` around lines 12 - 19, Add dpkg-dev
explicitly to the apt-get install list in the Dockerfile’s package installation
step, alongside devscripts and the other build dependencies, so
prepare-source.sh and build-packages.sh have dpkg-parsechangelog and
dpkg-buildpackage available without relying on transitive dependencies.

1-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The two Dockerfiles are identical except for the base image tag. Every fix must be applied twice, which creates drift risk. A single parameterized Dockerfile removes the duplication.

  • build/libvirt/Dockerfile.ubuntu24#L1-L26: replace this file with a shared Dockerfile.ubuntu that uses ARG UBUNTU_VERSION and FROM ubuntu:${UBUNTU_VERSION}.
  • build/libvirt/Dockerfile.ubuntu26#L1-L26: delete this file after the shared Dockerfile exists.
  • build/libvirt/build.sh#L144-L156: drop the dockerfile variable from the case block and pass --build-arg "UBUNTU_VERSION=${ubuntu_version}" with --file "${SCRIPT_DIR}/Dockerfile.ubuntu".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/Dockerfile.ubuntu24` around lines 1 - 26, Replace
build/libvirt/Dockerfile.ubuntu24 (lines 1-26) with shared
build/libvirt/Dockerfile.ubuntu using an UBUNTU_VERSION argument and
ubuntu:${UBUNTU_VERSION} base; delete build/libvirt/Dockerfile.ubuntu26 (lines
1-26). In build/libvirt/build.sh (lines 144-156), remove the dockerfile variable
from the case block and invoke the shared Dockerfile with --file
"${SCRIPT_DIR}/Dockerfile.ubuntu" and the UBUNTU_VERSION build argument.
build/libvirt/README.md (1)

72-86: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a pointer to the runtime requirements.

The document states that the build does not produce python3-libvirt. The launcher in scripts/start_super_protocol_libvirt.sh requires python3-libvirt, passt, acl, and libvirt >= 12.1.0 for GPU passthrough. A short note that links these packages to the host setup step helps operators install a complete set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/README.md` around lines 72 - 86, Update the build documentation
near the package-output description to add a concise pointer to the host
setup/runtime requirements. Reference scripts/start_super_protocol_libvirt.sh
and note that operators must install python3-libvirt, passt, acl, and libvirt >=
12.1.0 for GPU passthrough.
build/libvirt/docker/prepare-source.sh (2)

11-15: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Drop the .git directory from the packaged source tree.

build-packages.sh runs cp -a "${SOURCE_DIR}" "${work_dir}/libvirt" on every container start. The clone keeps .git, so each build copies the full Git metadata. Remove .git after the version check to reduce image size and copy time.

♻️ Proposed change
 cd "${SOURCE_DIR}"
+rm -rf "${SOURCE_DIR}/.git"
 apt-get update
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/docker/prepare-source.sh` around lines 11 - 15, Update the
source preparation flow around the git clone and version check to remove the
cloned repository’s .git directory from SOURCE_DIR after validating the version.
Keep the source files intact so build-packages.sh can continue copying
SOURCE_DIR into the package tree without Git metadata.

11-22: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin the packaging source to an immutable commit.

git clone --branch "${PACKAGING_REF}" resolves a tag on a third-party repository. A tag can be moved or replaced, so the build input is not reproducible. The changelog check at line 17 detects a version change only, not arbitrary content changes. Record the expected commit SHA and verify it after the clone.

🛡️ Proposed hardening
 git clone \
     --branch "${PACKAGING_REF}" \
     --depth 1 \
     "${PACKAGING_REPOSITORY}" \
     "${SOURCE_DIR}"
+
+if [[ -n "${PACKAGING_COMMIT:-}" ]]; then
+    actual_commit=$(git -C "${SOURCE_DIR}" rev-parse HEAD)
+    if [[ "${actual_commit}" != "${PACKAGING_COMMIT}" ]]; then
+        echo "Error: ${PACKAGING_REF} resolves to ${actual_commit}, expected ${PACKAGING_COMMIT}" >&2
+        exit 1
+    fi
+fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/docker/prepare-source.sh` around lines 11 - 22, Pin the clone
in the source-preparation flow to a configured expected commit SHA rather than
relying solely on the movable PACKAGING_REF tag or branch. After cloning, verify
the checked-out commit matches that SHA and fail with an error if it does not;
retain the existing changelog version validation.
.github/workflows/build-packages-self-hosted.yml (2)

62-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Confirm the archive path is excluded from the tar input.

The step writes ${archive_name} into build/libvirt/out/ and then creates the tar from that same directory. The tar only adds ${output_directory}, so the archive does not contain itself. This works, but a rerun leaves a stale .tar.gz in the output root. Consider writing the archive to ${WORK_DIR} or ${RUNNER_TEMP} instead.

♻️ Proposed change
-          archive_path="${WORK_DIR}/build/libvirt/out/${archive_name}"
+          archive_path="${RUNNER_TEMP}/${archive_name}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build-packages-self-hosted.yml around lines 62 - 95,
Update the Build libvirt packages step to write archive_path outside
build/libvirt/out, preferably under WORK_DIR or RUNNER_TEMP, while keeping the
tar input directory and output_directory unchanged. Continue exporting the
resulting archive path through LIBVIRT_ARCHIVE_PATH.

147-156: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

actions/upload-release-asset@v1 is archived and unmaintained.

The repository for this action is archived, so it receives no security or Node runtime updates. The same applies to actions/create-release@v1 at line 115. Migrate both to a maintained action, for example softprops/action-gh-release, or use gh release create and gh release upload from the GitHub CLI.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build-packages-self-hosted.yml around lines 147 - 156,
Replace the archived actions/create-release@v1 and
actions/upload-release-asset@v1 steps with a maintained release workflow,
preferably softprops/action-gh-release or GitHub CLI commands. Preserve the
existing release creation, upload URL usage, libvirt-ubuntu condition, archive
path, asset name, content type, and GITHUB_TOKEN authentication.

Source: Linters/SAST tools

build/libvirt/docker/build-packages.sh (2)

16-22: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Guard the /etc/os-release variables consistently.

Line 18 sources the file with set -u active. Line 19 dereferences ${ID} and ${VERSION_ID} without a default, so the script aborts with an unbound-variable error instead of the intended message if either variable is absent. Line 20 already uses ${VERSION_ID:-unknown}, which shows the intent. Line 37 has the same problem with ${VERSION_CODENAME}.

♻️ Proposed change
-if [[ "${ID}" != "ubuntu" || "${VERSION_ID}" != "${TARGET_UBUNTU_VERSION}" ]]; then
+if [[ "${ID:-}" != "ubuntu" || "${VERSION_ID:-}" != "${TARGET_UBUNTU_VERSION}" ]]; then
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/docker/build-packages.sh` around lines 16 - 22, Update the
validation condition after sourcing /etc/os-release to use safe default
expansions for ID and VERSION_ID, preserving the existing mismatch check and
error message. Also update the VERSION_CODENAME reference around the later
validation at line 37 to avoid unbound-variable failures under set -u, using the
same guarding convention.

66-76: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use one parallel-build control

-jauto takes precedence over parallel=$(nproc) in DEB_BUILD_OPTIONS. Remove the duplicate parallel setting and keep DEB_BUILD_OPTIONS for nocheck only.

♻️ Proposed change
-build_options="parallel=$(nproc)"
+build_options=""
 if [[ "${SKIP_TESTS}" == "true" ]]; then
-    build_options="${build_options} nocheck"
+    build_options="nocheck"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/docker/build-packages.sh` around lines 66 - 76, Update the
build-options setup around DEB_BUILD_OPTIONS to stop adding parallel=$(nproc),
since dpkg-buildpackage already receives -jauto. Keep DEB_BUILD_OPTIONS limited
to the conditional nocheck value while preserving SKIP_TESTS validation and the
existing dpkg-buildpackage invocation.
scripts/start_super_protocol_libvirt.sh (2)

9-17: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Reduce the text coupling to start_super_protocol.sh.

The launcher sources the base script by deleting everything from the literal line parse_args $@ to the end. The guard at Line 9 detects a rename, but any reordering, added trailing helper function, or reformatting of that line silently changes what this launcher inherits. Extract the shared functions into a sourceable library file, and let both scripts source it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start_super_protocol_libvirt.sh` around lines 9 - 17, Extract the
shared release, validation, VFIO, and provider-config preparation functions from
start_super_protocol.sh into a dedicated sourceable library, then update both
start_super_protocol.sh and the launcher to source that library. Remove the
grep/sed marker-based sourcing and ensure the launcher still excludes the
original entrypoint and direct QEMU execution.

446-481: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the nested function definition and use a trap on the loop variables.

create_vm_disks defines cleanup_provider_disk inside itself at Line 459. Bash creates a global function on every call, and the function reads provider_loop and provider_mount, which are local to the caller. The code works today because the trap fires while those locals are in scope, but the pattern is fragile. Also, mount and cp failures leave the loop device attached when errexit triggers before Line 474, and the RETURN trap only fires on function return. Define the cleanup as a top-level helper that takes the loop device and mount point as arguments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start_super_protocol_libvirt.sh` around lines 446 - 481, Replace the
nested cleanup_provider_disk definition inside create_vm_disks with a top-level
cleanup helper that accepts the loop device and mount point as arguments. Trap
cleanup using the current provider_loop and provider_mount values so failures in
mount or cp also detach the loop and remove the temporary mount directory, while
preserving the existing successful cleanup and trap removal behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build/libvirt/build.sh`:
- Around line 158-161: Clean the existing output directory before rebuilding
packages so artifacts from prior runs cannot persist. Update the
output-directory setup around output_dir and mkdir -p to remove any existing
directory first, then recreate it before invoking build-packages.sh.

In `@build/libvirt/docker/build-packages.sh`:
- Around line 95-101: Update the artifact finalization block around the debs
array, sha256sum, and chown commands to handle empty .deb/.ddeb results without
reading stdin or failing on an empty glob. Only generate SHA256SUMS and chown
matching artifacts when they exist, and explicitly chown OUTPUT_DIR itself while
preserving ownership updates for generated files.

In `@docs/swarm.md`:
- Line 71: Update the Ubuntu support requirement in the libvirt launcher
prerequisite entry to include Ubuntu 24.04 and 26.04, and correct the README
anchor to match the documented heading instead of the current ubuntu-2604
fragment.

In `@scripts/bootstrap_snp.sh`:
- Around line 364-365: Update the bootstrap flow around check_os_version and
get_supported_ubuntu_version to stop immediately when
get_supported_ubuntu_version returns a nonzero status, preventing unsupported
Ubuntu releases from reaching firmware, kernel, or setup_libvirt_host
operations. Ensure the failure status is propagated rather than ignored.

In `@scripts/bootstrap_tdx.sh`:
- Around line 11-12: Update the bootstrap version-validation flow in
bootstrap_tdx.sh and bootstrap_snp.sh to check the status returned by
get_supported_ubuntu_version and immediately exit on unsupported releases,
including the setup_libvirt_host tdx path. Preserve the existing
supported-version behavior while ensuring Ubuntu 25.04 cannot continue after
validation failure.

In `@scripts/libvirt_launcher.py`:
- Around line 520-548: Move log_file initialization, stdin terminal setup, and
related local state into the try block that follows receiver.start() in
attach_serial_console, so every setup failure is covered by the existing finally
cleanup. Keep receiver startup before the try as requested, and ensure the
cleanup can safely handle setup failing before the log file or terminal state is
initialized.
- Around line 555-590: Serialize all access to the virStream object used by the
serial-console loop: coordinate the receiver thread’s recv() with the main
thread’s send() and finally-block abort() calls using a shared ownership
mechanism, or restructure the loop around a single stream-owning event loop.
Ensure shutdown can acquire that coordination without being blocked
indefinitely, and update the receiver lifecycle around the existing
receiver.join() flow so no concurrent stream operation remains.

In `@scripts/setup_libvirt_host.sh`:
- Around line 343-394: Check the return status of patch_libvirt_apparmor_profile
in configure_libvirt_apparmor and immediately return 1 when it fails, before
creating or installing the drop-in. Preserve the existing successful flow for
valid AppArmor profiles.
- Around line 259-286: Ensure sourced setup helpers propagate failures instead
of relying on caller errexit: in scripts/setup_libvirt_host.sh#L259-L286, add
explicit failure propagation to assert_no_running_libvirt_domains, wget,
verify_and_extract_libvirt_archive, prepare_libvirt_package_compatibility,
build_libvirt_package_plan, and assert_safe_apt_simulation; in
scripts/setup_libvirt_host.sh#L343-L394, propagate failure from
patch_libvirt_apparmor_profile; and in scripts/setup_libvirt_host.sh#L579-L641,
check python3 -c 'import libvirt', id libvirt-qemu, aa-status --enabled, virsh
uri, and systemctl is-active --quiet qgsd, emitting an error and returning
nonzero when any fails. In scripts/bootstrap_snp.sh#L364-L365 and
scripts/bootstrap_tdx.sh#L11-L12, make get_supported_ubuntu_version failures
exit, and ensure setup_libvirt_host sev-snp at scripts/bootstrap_snp.sh#L443 and
setup_libvirt_host tdx at scripts/bootstrap_tdx.sh#L51 cause the bootstrap to
fail when nonzero.
- Around line 247-257: Update the APT simulation flow that feeds
assert_safe_apt_simulation to run apt-get --simulate with LC_ALL=C, ensuring its
output consistently uses the Remv and downgraded tokens before validation. Keep
the existing safety checks in assert_safe_apt_simulation unchanged.
- Around line 579-641: Update verify_libvirt_host to explicitly check the
results of the python3 libvirt import, id libvirt-qemu, aa-status --enabled, and
virsh URI probe, returning 1 through libvirt_host_error with clear failure
messages when any probe fails. In the tdx branch, explicitly check systemctl
is-active --quiet qgsd and report the service failure before returning 1; do not
rely on the command being the function’s final statement.

In `@scripts/swarm-cluster.sh`:
- Around line 763-783: Add one final domain_alive check in the startup wait flow
after the tmux session disappears and before reporting launcher failure or
calling die. Return success and log that the domain is running when this
re-check succeeds; otherwise preserve the existing diagnostic output and failure
behavior.

---

Nitpick comments:
In @.github/workflows/build-packages-self-hosted.yml:
- Around line 62-95: Update the Build libvirt packages step to write
archive_path outside build/libvirt/out, preferably under WORK_DIR or
RUNNER_TEMP, while keeping the tar input directory and output_directory
unchanged. Continue exporting the resulting archive path through
LIBVIRT_ARCHIVE_PATH.
- Around line 147-156: Replace the archived actions/create-release@v1 and
actions/upload-release-asset@v1 steps with a maintained release workflow,
preferably softprops/action-gh-release or GitHub CLI commands. Preserve the
existing release creation, upload URL usage, libvirt-ubuntu condition, archive
path, asset name, content type, and GITHUB_TOKEN authentication.

In `@build/libvirt/docker/build-packages.sh`:
- Around line 16-22: Update the validation condition after sourcing
/etc/os-release to use safe default expansions for ID and VERSION_ID, preserving
the existing mismatch check and error message. Also update the VERSION_CODENAME
reference around the later validation at line 37 to avoid unbound-variable
failures under set -u, using the same guarding convention.
- Around line 66-76: Update the build-options setup around DEB_BUILD_OPTIONS to
stop adding parallel=$(nproc), since dpkg-buildpackage already receives -jauto.
Keep DEB_BUILD_OPTIONS limited to the conditional nocheck value while preserving
SKIP_TESTS validation and the existing dpkg-buildpackage invocation.

In `@build/libvirt/docker/prepare-source.sh`:
- Around line 11-15: Update the source preparation flow around the git clone and
version check to remove the cloned repository’s .git directory from SOURCE_DIR
after validating the version. Keep the source files intact so build-packages.sh
can continue copying SOURCE_DIR into the package tree without Git metadata.
- Around line 11-22: Pin the clone in the source-preparation flow to a
configured expected commit SHA rather than relying solely on the movable
PACKAGING_REF tag or branch. After cloning, verify the checked-out commit
matches that SHA and fail with an error if it does not; retain the existing
changelog version validation.

In `@build/libvirt/Dockerfile.ubuntu24`:
- Around line 12-19: Add dpkg-dev explicitly to the apt-get install list in the
Dockerfile’s package installation step, alongside devscripts and the other build
dependencies, so prepare-source.sh and build-packages.sh have
dpkg-parsechangelog and dpkg-buildpackage available without relying on
transitive dependencies.
- Around line 1-26: Replace build/libvirt/Dockerfile.ubuntu24 (lines 1-26) with
shared build/libvirt/Dockerfile.ubuntu using an UBUNTU_VERSION argument and
ubuntu:${UBUNTU_VERSION} base; delete build/libvirt/Dockerfile.ubuntu26 (lines
1-26). In build/libvirt/build.sh (lines 144-156), remove the dockerfile variable
from the case block and invoke the shared Dockerfile with --file
"${SCRIPT_DIR}/Dockerfile.ubuntu" and the UBUNTU_VERSION build argument.

In `@build/libvirt/README.md`:
- Around line 72-86: Update the build documentation near the package-output
description to add a concise pointer to the host setup/runtime requirements.
Reference scripts/start_super_protocol_libvirt.sh and note that operators must
install python3-libvirt, passt, acl, and libvirt >= 12.1.0 for GPU passthrough.

In `@scripts/start_super_protocol_libvirt.sh`:
- Around line 9-17: Extract the shared release, validation, VFIO, and
provider-config preparation functions from start_super_protocol.sh into a
dedicated sourceable library, then update both start_super_protocol.sh and the
launcher to source that library. Remove the grep/sed marker-based sourcing and
ensure the launcher still excludes the original entrypoint and direct QEMU
execution.
- Around line 446-481: Replace the nested cleanup_provider_disk definition
inside create_vm_disks with a top-level cleanup helper that accepts the loop
device and mount point as arguments. Trap cleanup using the current
provider_loop and provider_mount values so failures in mount or cp also detach
the loop and remove the temporary mount directory, while preserving the existing
successful cleanup and trap removal behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c5266ce-9f52-4a11-a6f5-b06ba0ed5348

📥 Commits

Reviewing files that changed from the base of the PR and between 6c318cb and 15badfe.

📒 Files selected for processing (21)
  • .github/workflows/build-packages-self-hosted.yml
  • README.md
  • build/libvirt/.dockerignore
  • build/libvirt/Dockerfile.ubuntu24
  • build/libvirt/Dockerfile.ubuntu26
  • build/libvirt/README.md
  • build/libvirt/build.sh
  • build/libvirt/docker/build-packages.sh
  • build/libvirt/docker/prepare-source.sh
  • build/libvirt/out/.gitignore
  • docs/swarm.md
  • scripts/bootstrap_snp.sh
  • scripts/bootstrap_tdx.sh
  • scripts/common.sh
  • scripts/libvirt_launcher.py
  • scripts/setup_libvirt_host.sh
  • scripts/setup_snp.sh
  • scripts/setup_tdx.sh
  • scripts/start_super_protocol_libvirt.sh
  • scripts/swarm-cluster.sh
  • tests/test_libvirt_launcher.py

Comment thread build/libvirt/build.sh
Comment thread build/libvirt/docker/build-packages.sh Outdated
Comment thread docs/swarm.md Outdated
Comment thread scripts/bootstrap_snp.sh Outdated
Comment thread scripts/bootstrap_tdx.sh Outdated
Comment thread scripts/setup_libvirt_host.sh
Comment thread scripts/setup_libvirt_host.sh
Comment thread scripts/setup_libvirt_host.sh
Comment thread scripts/setup_libvirt_host.sh
Comment thread scripts/swarm-cluster.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
build/libvirt/Dockerfile.ubuntu (1)

3-4: 🔒 Security & Privacy | 🔵 Trivial | 🏗️ Heavy lift

Pin the Ubuntu base image for release builds.

The release workflow publishes packages built from ubuntu:${UBUNTU_VERSION}, which is a mutable tag. Pin each Ubuntu version to a target-platform manifest digest, or enforce an accepted update policy before publishing artifacts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build/libvirt/Dockerfile.ubuntu` around lines 3 - 4, Update the
UBUNTU_VERSION base image reference in the Dockerfile to use an immutable
target-platform manifest digest for release builds, or add the release
workflow’s required accepted-update policy before publishing artifacts; preserve
the configurable Ubuntu version while ensuring the resolved image cannot change
unexpectedly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/libvirt_launcher.py`:
- Around line 521-526: Move the domain.openConsole call into the existing try
block in the console-stream setup, while retaining stream creation before it so
any openConsole failure reaches the existing finally cleanup and calls
stream.abort().

---

Nitpick comments:
In `@build/libvirt/Dockerfile.ubuntu`:
- Around line 3-4: Update the UBUNTU_VERSION base image reference in the
Dockerfile to use an immutable target-platform manifest digest for release
builds, or add the release workflow’s required accepted-update policy before
publishing artifacts; preserve the configurable Ubuntu version while ensuring
the resolved image cannot change unexpectedly.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 90cac448-a2dd-4ebc-a341-1a8b8756f46c

📥 Commits

Reviewing files that changed from the base of the PR and between 15badfe and 7d0c8d7.

📒 Files selected for processing (14)
  • .github/workflows/build-packages-self-hosted.yml
  • build/libvirt/Dockerfile.ubuntu
  • build/libvirt/README.md
  • build/libvirt/build.sh
  • build/libvirt/docker/build-packages.sh
  • build/libvirt/docker/prepare-source.sh
  • docs/swarm.md
  • scripts/bootstrap_snp.sh
  • scripts/bootstrap_tdx.sh
  • scripts/libvirt_launcher.py
  • scripts/setup_libvirt_host.sh
  • scripts/start_super_protocol.sh
  • scripts/start_super_protocol_libvirt.sh
  • scripts/swarm-cluster.sh
🚧 Files skipped from review as they are similar to previous changes (9)
  • scripts/bootstrap_tdx.sh
  • scripts/bootstrap_snp.sh
  • build/libvirt/README.md
  • build/libvirt/docker/build-packages.sh
  • build/libvirt/build.sh
  • scripts/start_super_protocol_libvirt.sh
  • docs/swarm.md
  • scripts/swarm-cluster.sh
  • scripts/setup_libvirt_host.sh

Comment thread scripts/libvirt_launcher.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant