Skip to content

vmupdate: add qvm-template-upgrade - #213

Open
nihalxkumar wants to merge 9 commits into
QubesOS:mainfrom
nihalxkumar:qvm-template-upgrade
Open

vmupdate: add qvm-template-upgrade#213
nihalxkumar wants to merge 9 commits into
QubesOS:mainfrom
nihalxkumar:qvm-template-upgrade

Conversation

@nihalxkumar

@nihalxkumar nihalxkumar commented May 25, 2026

Copy link
Copy Markdown
Contributor

This PR introduces the qvm-template-upgrade dom0 command-line utility, that performs an in-place N -> N+1 distribution upgrade of Debian and Fedora TemplateVM or StandaloneVM

fixes: QubesOS/qubes-issues#8605
GSoC 2026 project: Automate Template Version Upgrade

@ben-grande ben-grande left a comment

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.

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
Comment thread vmupdate/template_upgrade.py Outdated
@codecov-commenter

codecov-commenter commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.27544% with 290 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.09%. Comparing base (a571230) to head (721ebef).

Files with missing lines Patch % Lines
vmupdate/tests/test_version_upgrade_agent.py 83.51% 123 Missing ⚠️
vmupdate/agent/source/dnf/dnf5_api.py 2.15% 91 Missing ⚠️
vmupdate/agent/source/apt/apt_api.py 2.50% 39 Missing ⚠️
vmupdate/agent/source/apt/apt_cli.py 89.18% 12 Missing ⚠️
vmupdate/template_upgrade.py 98.05% 6 Missing ⚠️
vmupdate/agent/source/common/package_manager.py 90.56% 5 Missing ⚠️
vmupdate/agent/source/dnf/dnf_api.py 89.79% 5 Missing ⚠️
vmupdate/agent/source/common/progress_reporter.py 92.59% 4 Missing ⚠️
vmupdate/agent/source/dnf/dnf_cli.py 92.30% 3 Missing ⚠️
vmupdate/tests/test_template_upgrade.py 99.82% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
- Coverage   71.36%   68.09%   -3.28%     
==========================================
  Files          12       34      +22     
  Lines        1383     4604    +3221     
==========================================
+ Hits          987     3135    +2148     
- Misses        396     1469    +1073     

☔ View full report in Codecov by Harness.
📢 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.

@nihalxkumar
nihalxkumar marked this pull request as ready for review June 2, 2026 05:29
@ben-grande

Copy link
Copy Markdown
Contributor

PipelineRetryFailed

@nihalxkumar

Copy link
Copy Markdown
Contributor Author

It's showing a successful run

image image

@ben-grande

Copy link
Copy Markdown
Contributor

Some tests are not enabled on this repo, such as mypy, black and pylint. See this as an example: https://github.com/QubesOS/qubes-core-admin/blob/main/.gitlab-ci.yml. Can you create a separate PR to enable those checks?

@nihalxkumar

Copy link
Copy Markdown
Contributor Author

Sure, will do

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
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
Comment thread vmupdate/template_upgrade.py Outdated
@nihalxkumar

Copy link
Copy Markdown
Contributor Author

We can squash here if it's looks fine. Will also have to rebase as this is 24 commits behind.

@ben-grande

Copy link
Copy Markdown
Contributor

Looks fine to squash.

@marmarek

Copy link
Copy Markdown
Member

Oh no, commit message in the other PR closed it ...

@marmarek marmarek reopened this Jun 10, 2026
@marmarek

Copy link
Copy Markdown
Member

I see a conflict here - CI will not run until it's resolved.

@nihalxkumar
nihalxkumar force-pushed the qvm-template-upgrade branch 6 times, most recently from 16b99f5 to f1f8fc1 Compare June 14, 2026 16:29
@nihalxkumar nihalxkumar changed the title qvm-template-upgrade: add CLI skeleton and orchestration flow qvm-template-upgrade: add orchestration workflow and in-VM agent Jun 14, 2026

@ben-grande ben-grande left a comment

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.

I have taken a look through the new code. Thanks for the progress, I like to see it evolving. Just minor review though

Comment thread vmupdate/agent/source/common/package_manager.py
Comment thread vmupdate/agent/source/common/package_manager.py
Comment thread vmupdate/agent/source/dnf/dnf_cli.py Outdated
Comment thread vmupdate/agent/source/dnf/dnf_cli.py Outdated
@nihalxkumar
nihalxkumar force-pushed the qvm-template-upgrade branch from ad97dca to a0289a7 Compare June 15, 2026 17:11
@ben-grande

Copy link
Copy Markdown
Contributor

@nihalxkumar

Copy link
Copy Markdown
Contributor Author

When I tried upgrading fedora 41 -> 42 there was a cleanup failure which happened after the successful version upgrade.

logs as shared privately on tuesday:

https://gist.github.com/nihalxkumar/01fb990deab3960cb28d680773bb1089#file-upgrade42-log-L48-L55

we can see Complete! in the above log.

https://gist.github.com/nihalxkumar/0e4edccb4f4409b1a4daf5c44b6f576f

After version_upgrade() returns success, the agent still runs cleanup. The old code used the cleanup exit code when deciding the final agent exit code.
For dnf this includes DNFCLI.clean() (dnf clean packages), and the transport also removes /run/qubes-update/.

a90eee1 (last commit) is based on that failure boundary. After the release transaction has succeeded, a later cleanup failure should not cause rollback of the upgraded clone.

@ben-grande

Copy link
Copy Markdown
Contributor

But we can't ignore all cleanup failures. We don't know what is causing it, so this needs to be investigated.

Comment thread vmupdate/agent/source/apt/apt_cli.py Outdated
Comment thread vmupdate/agent/source/apt/apt_cli.py Outdated
Comment thread vmupdate/agent/source/apt/apt_cli.py Outdated
Comment thread vmupdate/agent/source/apt/apt_cli.py Outdated

@parulin parulin 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.

I have some suggestion for better integration with the rest of the docs. If you have any question, feel free to ask.

This file is in doc/tools instead of doc/manpages, why?

Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
Comment thread doc/tools/qvm-template-upgrade.rst
@parulin

parulin commented Jul 21, 2026

Copy link
Copy Markdown

As I understand, this tool should also be promoted in qubes-doc, in the user/templates/*/*-upgrade.rst files for fedora and debian.

@nihalxkumar

Copy link
Copy Markdown
Contributor Author

@parulin you are mistaking this repository as qubes-core-admin-client

@nihalxkumar
nihalxkumar force-pushed the qvm-template-upgrade branch from 80e3d99 to c3f550e Compare July 23, 2026 21:04
@nihalxkumar

Copy link
Copy Markdown
Contributor Author

Debian upgrade end-to-end successful

https://gist.github.com/nihalxkumar/3f64e3a056e9ce367e9787d5bd94b9df
https://gist.github.com/nihalxkumar/212e885811589b85fdd23dafdfddf887

@ben-grande ben-grande mentioned this pull request Jul 24, 2026
Comment thread doc/tools/qvm-template-upgrade.rst Outdated
AUTHORS
=======
| Nihal Kumar <nihalxkumar at tutamail dot com>
| Ben Grande <ben at invisiblethingslab dot com> No newline at end of file

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.

Not sure how credit works here, but it could be worth also adding @kennethrrosen as the creator of the tool that lead to this. 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kenneth's script only served as a conceptual inspiration. I have no problems mentioning this but how should I do it?

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.

Exactly. That's in the sense I meant. Maybe:

Suggested change
| Ben Grande <ben at invisiblethingslab dot com>
| Ben Grande <ben at invisiblethingslab dot com>
| Kenneth R. Rosen <kennethrrosen at proton.me>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ben-grande

Copy link
Copy Markdown
Contributor

Hi. Could you please rebase your PR from the main branch to fix the conflicts?

Add a --version-upgrade mode to the in-VM agent so a qube can be moved
to the next major distribution release. The dnf backend distro-syncs
to the target releasever; the apt backend updates, rewrites source
codenames, and dist-upgrades. Both confirm os-release before reporting
success.
The agent emits a final explicit 100% even when callback progress
already reached it, causing a bogus "err: 100.00" line.

Drop the duplicate 100 milestone after progress has finished.
Upgrade a clone of a TemplateVM or StandaloneVM to the next
distribution release, leaving the original qube untouched.
Document the options, the clone name derivation, and which template-*
features the tool rewrites, including why the inherited epoch, version
and release make qvm-template list the upgraded clone as upgradeable.
Progress hit 100% before post-transaction scriptlets finished,
making the bar appear frozen for the remaining work.

Cap package progress at 97% and advance asymptotically through
post-transaction scriptlets. Report 100% after qubes.PostInstall
so the bar stays responsive until everything is done.
During release upgrades the root volume briefly holds both releases,
which can trigger a spurious disk-space warning toast.

Suppress disk-space-not-notify on the clone during the upgrade and
restore it afterwards.
Each Debian release-upgrade step drove the progress bar to 100%,
silencing later steps. Give each step its own weighted slice of the
bar so progress stays proportional throughout the upgrade.
@nihalxkumar
nihalxkumar force-pushed the qvm-template-upgrade branch from c3f550e to 5a78c27 Compare August 24, 2026 12:39
@nihalxkumar nihalxkumar changed the title qvm-template-upgrade: add orchestration workflow and in-VM agent vmupdate: add qvm-template-upgrade Aug 24, 2026
@nihalxkumar
nihalxkumar force-pushed the qvm-template-upgrade branch from 4c27ce0 to 3b2de76 Compare August 24, 2026 13:22
@qubesos-bot

qubesos-bot commented Aug 24, 2026

Copy link
Copy Markdown

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026082500-devel&flavor=pull-requests

Test run included the following:

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update

  • system_tests_network_updates

Failed tests

1 failures
  • system_tests_network_updates

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/176874#dependencies
Nothing fixed

Unstable tests

Details
  • system_tests_network_updates

    system_tests/Fail (2/5 times with errors)
    • job 192061 Tests qubes.tests.integ.dom0_update failed (exit code 1), details r...
    • job 192160 Tests qubes.tests.integ.dom0_update failed (exit code 1), details r...
    system_tests/Fail (1/5 times with errors)
    • job 192568 Tests qubes.tests.integ.dom0_update failed (exit code 1), details r...
    system_tests/Fail (1/5 times with errors)
    • job 191227 Tests qubes.tests.integ.vm_update failed (exit code 1), details rep...
    system_tests/Failed (3/5 times with errors)
    • job 191227 # Test died: Some tests failed at qubesos/tests/system_tests.pm lin...
    • job 192061 # Test died: Some tests failed at qubesos/tests/system_tests.pm lin...
    • job 192160 # Test died: Some tests failed at qubesos/tests/system_tests.pm lin...
    system_tests/Failed (1/5 times with errors)
    • job 192568 # Test died: Some tests failed at qubesos/tests/system_tests.pm lin...
    TC_00_Dom0Upgrade_whonix-gateway-18/test_000_update_salt (1/5 times with errors)
    • job 192568 ?[0;31mDuration: 204145.11 ms?[0;0m... ?[0;31m Changes: ?[0;0m
    TC_00_Dom0Upgrade_whonix-gateway-18/test_005_update_flag_clear (1/5 times with errors)
    • job 192160 Error: Failed to download metadata for repo 'test': Cannot download...
    TC_00_Dom0Upgrade_whonix-gateway-18/test_006_update_flag_clear (1/5 times with errors)
    • job 192160 Error: Failed to download metadata for repo 'test': Cannot download...
    TC_00_Dom0Upgrade_whonix-gateway-18/test_010_instal (1/5 times with errors)
    • job 192061 Error: Failed to download metadata for repo 'test': Cannot download...
    VmUpdates_fedora-44-xfce/test_011_pkcon_via_proxy (1/5 times with errors)
    • job 191227 AssertionError: 7 not found in [0, 100] : pkcon install -y test-pkg...
    VmUpdates_debian-13-xfce/test_110_update_via_proxy_qubes_vm_update (1/5 times with errors)
    • job 191227 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...

Performance Tests

Performance degradation:

No issues

Remaining performance tests:

No remaining performance tests

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.

[Contribution] qvm-upgrade-template (easy in-place upgrades for Debian and Fedora templates)

7 participants