Skip to content

Conversation

@alimirjamali
Copy link
Contributor

If we allow users to create custom labels and they backup such qubes, restore operation will fail on new systems without those custom labels. Fix this by reverting to red label and allow users to restore their backup.

fixes: QubesOS/qubes-issues#9781

@alimirjamali alimirjamali force-pushed the restore-missing-label branch 2 times, most recently from a04f8f7 to 8d771e3 Compare February 17, 2025 13:12
@codecov
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.67%. Comparing base (c3759ad) to head (c4940be).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
- Coverage   75.68%   75.67%   -0.02%     
==========================================
  Files          52       52              
  Lines        8975     8977       +2     
==========================================
  Hits         6793     6793              
- Misses       2182     2184       +2     

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

@alimirjamali alimirjamali force-pushed the restore-missing-label branch 2 times, most recently from 5e0974e to 88354e1 Compare February 17, 2025 14:37
@alimirjamali
Copy link
Contributor Author

I am not certain why codecov has marked those two lines as uncovered. The unittests had to be specifically changed since those two lines were indeed working

@marmarek
Copy link
Member

I am not certain why codecov has marked those two lines as uncovered. The unittests had to be specifically changed since those two lines were indeed working

Looks like some backup tests are skipped because scrypt tool is not installed. It isn't available in Fedora repo, only in Qubes repo and this one is not included in the docker used for the test...

@alimirjamali
Copy link
Contributor Author

alimirjamali commented Feb 22, 2025

I am not certain why codecov has marked those two lines as uncovered. The unittests had to be specifically changed since those two lines were indeed working

Looks like some backup tests are skipped because scrypt tool is not installed. It isn't available in Fedora repo, only in Qubes repo and this one is not included in the docker used for the test...

So what is the appropriate solution here? Is there a way to include qubes-vm-r4.3-current-testing in docker to install scrypt binary and re-enable the skipped tests? Or it is necessary to switch to python3-scrypt package and do the decryption directly in Python instead of depending on the external binary?

@alimirjamali alimirjamali force-pushed the restore-missing-label branch 3 times, most recently from 1913e2b to d2a242a Compare February 22, 2025 21:00
marmarek added a commit to fepitre/qubes-g2g-continuous-integration that referenced this pull request Feb 22, 2025
Keep them disabled by default, but allow enabling when needed. For
example it's useful for backup tests, to install scrypt tool.

Related to QubesOS/qubes-core-admin-client#335
@marmarek
Copy link
Member

Rebase on top of #337 (soon main)

@alimirjamali alimirjamali force-pushed the restore-missing-label branch 3 times, most recently from 5f4fbaf to ddf9898 Compare February 23, 2025 06:31
@alimirjamali
Copy link
Contributor Author

Rebase on top of #337 (soon main)

OK. Unit tests are green again and looking at Github report, it appears that backupcompatibility tests are not skipped. But the Codecov report is still not covered.

Another issue is that the backupcompatibility tests are kinda slow. I believe after this is done, it might be better to disable ENABLE_SLOW_TESTS in .gitlab-ci.yml via another PR to make the life easier for other PRs which are not backup related.

@marmarek
Copy link
Member

But the Codecov report is still not covered.

I think you changed label in test in a wrong place. Change it in the qubes.xml, not the parsed structure.

@alimirjamali alimirjamali force-pushed the restore-missing-label branch 2 times, most recently from 41ddf2f to a116092 Compare February 23, 2025 14:08
@marmarek
Copy link
Member

openQA says it breaks restoring backup using a DispVM:

Feb 23 15:01:58.885143 dom0 qrexec-policy-daemon[1693]: qrexec: admin.label.List: disp-backup-restore -> dom0: denied: no matching rule found

Theoretically the policy could be extended to allow listing labels, but maybe it isn't needed? Maybe instead of check before, you can try setting the label and fallback to "red" in case of QubesLabelNotFoundError exception?

@marmarek
Copy link
Member

The policy for DispVM restore is in core-admin. But as said above, maybe this extra permission (and also extra call during usual restore) isn't actually needed?

@alimirjamali
Copy link
Contributor Author

The policy for DispVM restore is in core-admin. But as said above, maybe this extra permission (and also extra call during usual restore) isn't actually needed?

Unfortunatley it is needed. Unless we want to hard-code the choices of default labels, I do not know any other way to test if the label of the VM to restore is one of them.

@marmarek
Copy link
Member

Ah, because label is mandatory to create a VM, setting it cannot be deferred to later. I was thinking about something like:

try:
    vm.label = label
except QubesLabelNotFoundError:
    vm.label = "red"

but that indeed won't work. And worse - it looks like admin.vm.Create raises generic QubesValueError on unknown label (which BTW might be a bug - QubesLabelNotFoundError would be more logical), so you can't even do that try/except with the create call.

@alimirjamali
Copy link
Contributor Author

There is a less invasive and more privacy friendly way by using admin.label.Get call to check of the label exists

@alimirjamali
Copy link
Contributor Author

alimirjamali commented Feb 24, 2025

(which BTW might be a bug - QubesLabelNotFoundError would be more logical)

Should I implement it for core?

@marmarek
Copy link
Member

QubesOS/qubes-core-admin#663

@alimirjamali
Copy link
Contributor Author

QubesOS/qubes-core-admin#663

Very nice. I will amend this PR and revert to try: except: approach as soon as the above is merged.

@marmarek
Copy link
Member

Now that QubesOS/qubes-core-admin#663 is merged you can update this PR. Or do you want me to push an updated package to current-testing first (doesn't matter for openqa)?

@alimirjamali
Copy link
Contributor Author

Now that QubesOS/qubes-core-admin#663 is merged you can update this PR. Or do you want me to push an updated package to current-testing first (doesn't matter for openqa)?

Very nice. Let's see if this works. What about the unittests? Will they fetch the main branch or use current-testing?

@alimirjamali
Copy link
Contributor Author

Ok. It appears that the unittests fail since they depend on current-testing.

@marmarek
Copy link
Member

No, unittests do not use real core-admin. There is a mockup that is configured to mimic its behavior. You need to update it to match the change, specifically to return an exception for the call with scarlet label (the one that is now shown in test failure message as unexpected call).

If we allow users to create custom labels and they backup such qubes,
restore operation will fail on new systems without those custom labels.
Fix this by reverting to red label and allow users to restore their
backup.

fixes: QubesOS/qubes-issues#9781
@marmarek marmarek merged commit f4893d7 into QubesOS:main Mar 3, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to restore backup of qubes with custom labels on new systems

3 participants