Skip to content

qvm-template-upgrade: add CLI skeleton and orchestration flow#213

Draft
nihalxkumar wants to merge 3 commits into
QubesOS:mainfrom
nihalxkumar:qvm-template-upgrade
Draft

qvm-template-upgrade: add CLI skeleton and orchestration flow#213
nihalxkumar wants to merge 3 commits into
QubesOS:mainfrom
nihalxkumar:qvm-template-upgrade

Conversation

@nihalxkumar
Copy link
Copy Markdown

This is a PR for the GSoC 2026 project: Automate Template Version Upgrade
introducing the qvm-template-upgrade dom0 command-line utility, which provides the orchestration layer for in-place template version upgrades.

TLDR of what this PR does at the moment:

  • Validates that the target is a TemplateVM.
  • Clones the source template (e.g., fedora-41 -> fedora-42).
  • [Stubbed] Invokes the VM-side package manager agent via qube_connection.py.
  • On success: Updates qvm-features (sets template-name, clears stale RPM data).
  • On failure: Removes the broken clone (unless --keep-on-failure is passed), leaving the original template untouched.

related to QubesOS/qubes-issues#8605.

Copy link
Copy Markdown
Contributor

@ben-grande ben-grande left a comment

Choose a reason for hiding this comment

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

Yay, started. As I've done a review now, I will receive a notification every time you commit. Let me know when you need another look or have doubts by mentioning me.

Comment thread vmupdate/tests/test_template_upgrade.py
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
datetime.now(tz=timezone.utc).strftime(DATE_FMT)


def remove_failed_clone(clone_vm, log):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You might want to include some functions as a method of a class, to avoid passing objects explicitly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done in 4cfd7e4

Comment thread vmupdate/template_upgrade.py Outdated
return log


def validate_template(app, name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adapt the function name also to the new klass it encompasses.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done 🫡

Move validation, cloning, agent execution, finalization, and
rollback into a stateful TemplateUpgrader.

Refresh TemplateVM metadata after success and rewrite existing
StandaloneVM template-name values from the old release to the
new one so updater EOL checks do not use stale metadata.
Also make logging setup best-effort and idempotent.

Update tests for the class-based flow and standalone metadata
handling.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.29851% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.89%. Comparing base (582536c) to head (4cfd7e4).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
vmupdate/template_upgrade.py 83.22% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
+ Coverage   72.63%   74.89%   +2.25%     
==========================================
  Files          10       14       +4     
  Lines        1162     1597     +435     
==========================================
+ Hits          844     1196     +352     
- Misses        318      401      +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants