Commit Graph

71 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
93608658a9
backup: throttle backup extracting if there is not enough disk space
Instead of failing the restore process, pause data extracting, until
already extracted data gets processed.
This commit implements this for local tar extraction. Extracting data
received from a VM is handled in qfile-(dom0-)unpacker, which also has
similar feature, turned on in 6338b936e2.

Fixes QubesOS/qubes-issues#4791
2021-01-05 04:46:12 +01:00
Marek Marczykowski-Górecki
10d4381c14
backup: check if there is enough disk space available to restore
Avoid failing restore after potentially lengthy processing - check
available space first.

This will be even more important after adding waiting for free space -
then if there won't be enough free space, the process will deadlock.

QubesOS/qubes-issues#4791
2021-01-05 03:33:21 +01:00
Marek Marczykowski-Górecki
16ff6d0552
backup: cleanup retrieve_proc on failure 2021-01-05 03:32:21 +01:00
Marek Marczykowski-Górecki
d906fbc4bb
backup: add function parameter for override temp directory
This will be useful for tests.

QubesOS/qubes-issues#
2021-01-05 03:31:09 +01:00
Marek Marczykowski-Górecki
e6186239ef
Make pylint happy
- fix super-with-arguments
- ignore raise-missing-from - too many intentional usages
2020-08-23 03:31:39 +02:00
Marek Marczykowski-Górecki
c75aeb400a
backup/restore: make error reporting work also for StandaloneVM based DispVM
If management dispvm is based on a StandaloneVM not a AppVM, then there
is just one level of templates, not two.

QubesOS/qubes-issues#4670
2020-08-07 02:12:39 +02:00
Marek Marczykowski-Górecki
1660a1cbf6
backup/restore: better error detection for --paranoid-mode
Xterm doesn't preserve exit code of the process running inside. This
means, the whole xterm always exits with 0, even if qvm-backup-restore
failed.
Fix this by printing the exit code at the end to the log and then extract
that last line from the log on the calling side. This way we can also
distinguish whether qvm-backup-restore or xterm failed.
2020-08-05 05:06:54 +02:00
Marek Marczykowski-Górecki
7d6cb655f8
backup/restore: add option for unattended restore and extracting log
Allow running unattended, with qvm-backup-restore --passphrase-file.
This require few modifications:
 - copy the passphrase file into the DisposableVM (that VM knows the
         passphrase anyway, so there is no extra data leak)
 - close the terminal when operation finishes

Closing the terminal would eliminate almost all the feedback (operation
log, errors, warnings etc), so write it into a file in DisposableVM and
later extract it and show on the stdout. Similar to qvm-run, color it
red as a content coming from a VM.

QubesOS/qubes-issues#5310
2020-08-05 04:37:44 +02:00
Marek Marczykowski-Górecki
cc71dd5876
Add "paranoid restore" mode
Having Admin API, it is possible to do this properly now:
 - create DisposableVM
 - assign it proper permissions to create VMs and control those created
   VMs
 - run restore process inside
 - cleanup DisposableVM afterwards

Since the RestoreInDisposableVM class contains de facto reverse parser
for qvm-backup-restore command line, add a test that will spot when it
gets out of sync.

This feature depends on modifications in various other components,
including:
 - linux-utils and core-agent-linux for update qfile-unpacker
 - core-admin for qrexec policy modification

QubesOS/qubes-issues#5310
2020-08-04 04:06:53 +02:00
Marek Marczykowski-Górecki
6338b936e2
backup/restore: use qfile-unpacker in a VM, request disk space monitoring
Make it possible to use qvm-backup-restore in a VM. This commit is about
accessing backup itself, when stored in another VM. This involve using
qfile-unpacker instead of qfile-dom0-unpacker and also requesting disk
space monitoring, as a VM probably won't have enough space to hold the
whole backup at once.

QubesOS/qubes-issues#4791
QubesOS/qubes-issues#5310
2020-08-04 04:06:30 +02:00
Marek Marczykowski-Górecki
db1d4b5d48
backup/restore: option for alternative qrexec service
Allow setting alternative qrexec service to retrieve backup content. The
service API is slightly different than the default one: it will get only
list of files/directories to extract on its stdin, but not backup
location. The latter could be provided as a service argument, or using
other out-of-band mechanism.
This will be useful for paranoid backup restore mode, to take away
control over location/command from sandboxed qvm-backup-restore process.

QubesOS/qubes-issues#5310
2020-08-04 04:06:30 +02:00
Marek Marczykowski-Górecki
114f6fb250
backup/restore: improve error message about restoring tags
Before reporting a tag as not restored, verify if it really wasn't
restored. Generally created-by-* tags cannot be created manually. But
when restoring a backup in dom0, created-by-dom0 tag is added, which in
many cases will match what want to be restored.

Adjust tests to check this too.
2020-08-04 04:06:29 +02:00
Marek Marczykowski-Górecki
2b6b4e7954
backup/restore: distinguish dom0 by name
Getting name of QubesVM object doesn't require Admin API call that could
be not allowed by this VM

QubesOS/qubes-issues#5310
2020-08-04 04:06:29 +02:00
Marek Marczykowski-Górecki
2d736f5aa8
Make pylint happy 2019-10-05 21:57:48 +02:00
Marek Marczykowski-Górecki
1f1564dcf0
backup/restore: make pylint happy 2019-09-21 03:20:43 +02:00
Marek Marczykowski-Górecki
14f77860bf
backup/restore: add option to use uncommon compression filter anyway
Previous commit introduced protection against uncommon (potentially
malicious) compression filters. This breaks restoring backups made with
a custom compression filter. Add an option to override this check, by
naming compression filter to use explicitly.
2019-09-10 15:24:15 +02:00
Marek Marczykowski-Górecki
10f15e6669
backup/restore: reject uncommon compression filters and improve header validation
Compression filter named in a backup header is executed in restore
environment (commonly dom0). While this field is properly authenticated,
there may be cases where backup archive comes from less
trusted source, like migrating from potentially compromised
system.

Modify backup header parsing code to add field specific validators.
Whitelist only know crypto, hmac and compression algorithms.

Based on a patch by Jean-Philippe Ouellet <jpo@vt.edu>
Reported-by: Jean-Philippe Ouellet <jpo@vt.edu>
2019-09-10 15:24:15 +02:00
Marek Marczykowski-Górecki
d7430d42ce
Make pylint happy
no-else-raise warning
2019-03-07 03:17:29 +01:00
Marek Marczykowski-Górecki
5e4831ede4
backup: Do not try to attach devices during backup verification
The "restored" VM object will be discarded anyway, and it doesn't have
real 'attach' method.

Fixes QubesOS/qubes-issues#4830
2019-02-24 02:26:05 +01:00
Marek Marczykowski-Górecki
89ee4931fb
backup: do not fail restore if scrypt anticipate more time needed
For various reasons, decryption may be slower than initial encryption
(different hardware, different system load etc). Do not fail the restore
operation if scrypt anticipate it will take considerably more time or
memory, than while creating the backup (where the scrypt parameters were
originally set).

Thanks to @jharveyb for the report and suggested solution.
Fixes QubesOS/qubes-issues#4683
2019-01-09 19:09:44 +01:00
Marek Marczykowski-Górecki
0bb35193b4
doc: fix rst syntax in documentation, including docstrings 2018-12-08 23:53:55 +01:00
Marek Marczykowski-Górecki
28067f70ac
backup: simplify test expressions to make pylint happy 2018-12-03 23:27:10 +01:00
Marek Marczykowski-Górecki
907c8da005
Merge remote-tracking branch 'origin/pr/77'
* origin/pr/77:
  Exclude installed_by_rpm when Restoring VM from Backup
2018-09-27 14:57:08 +02:00
jimtahu
5f868b4794
Exclude installed_by_rpm when Restoring VM from Backup
VMs listed as from an rpm when they were really from a backup
lead to a missleading error message when deleting.

Fixes QubesOS/qubes-issues#4192
2018-09-22 22:39:22 -05:00
AJ Jordan
8b38a36de2
Fix typo 2018-09-14 14:48:22 -04:00
Marek Marczykowski-Górecki
55c9a82c0a
Merge branch 'backup-logging-deadlock'
* backup-logging-deadlock:
  backup: avoid deadlock on logging during restore
2018-07-17 15:46:17 +02:00
Marek Marczykowski-Górecki
a7bfc03509
backup: avoid deadlock on logging during restore
When both threads and processes are used, logging module can deadlock.
Workaround this by re-initializating locks in logging module.
See https://bugs.python.org/issue6721 for details.
Revert this commit when the python issue is fixed (in the python version
used for backup restore).
2018-07-16 22:30:35 +02:00
Marek Marczykowski-Górecki
16064f6fb4
Fixes for pylint 2.0
Ignore most of them - we still support python 2.7 here.
Fix no-else-return.
2018-07-16 02:25:25 +02:00
Rusty Bird
0171269138
restore.py: add template-related debug log messages 2018-02-24 12:43:42 +00:00
Rusty Bird
ab65338cfb
restory.py: restore template_for_dispvms property early 2018-02-24 12:43:42 +00:00
Rusty Bird
c86b731d3e
restore.py: factor out _restore_property() helper 2018-02-24 12:43:42 +00:00
Rusty Bird
2ace32bb73
restore.py: deal with DispVM templates 2018-02-24 12:43:42 +00:00
Rusty Bird
68c8b7fafc
restore.py: sort into three tiers in _templates_first() 2018-02-24 12:43:42 +00:00
Rusty Bird
01ce5387d3
restore.py: don't try to restore dispid property 2018-02-23 17:15:20 +00:00
Marek Marczykowski-Górecki
56dc984507
backup: don't crash when no 'qubes' group is present
This is specifically the case on Travis-CI. But since dom0 backup is
restored into separate directory now, instead of directly overriding
user home, this check is much less relevant now.
2018-02-14 04:28:23 +01:00
Marek Marczykowski-Górecki
a821034653
backup: add support for openssl 1.1.0 options
The command for listing available algorithms have changed:
old: openssl list-message-digest-algorithms
new: openssl list -digest-algorithms
2018-02-14 04:28:23 +01:00
Marek Marczykowski-Górecki
04635e7e80
backup: skip dom0's properties while restoring core2 backup
Fixes QubesOS/qubes-issues#3467
2018-02-14 04:28:22 +01:00
Christopher Laprise
e81c2f3cf6
unused variable 2018-02-01 23:20:31 -05:00
Christopher Laprise
e3d12fb96d
style issues 2018-02-01 23:00:06 -05:00
Christopher Laprise
30dd7acaa9
Fix dom0 restore 2018-02-01 22:21:24 -05:00
Christopher Laprise
60bfd63a25
Fix dom0 handling 2018-02-01 19:40:42 -05:00
Christopher Laprise
4b46d59179
Fix AdminVm class name 2018-01-24 20:42:15 -05:00
Marek Marczykowski-Górecki
2861d46dfa
backup/restore: do not shrink volumes on restore
This operation is blocked in current storage pool implementations.
2018-01-18 19:09:38 +01:00
Marek Marczykowski-Górecki
0e033645ad
backup: restore Qubes 3.x VMs as HVMs
Make use of better security of Qubes 4.x by using HVM by default. If
some VMs are incompatible with it (like MirageOS based), user can always
switch it to PV manually later.
2018-01-04 23:39:31 +01:00
Marek Marczykowski-Górecki
c82d5b0a73
Make pylint happy
Updated pylint on Travis-CI is slightly stricter.
2017-12-22 18:38:24 +01:00
Marek Marczykowski-Górecki
796a3d43ae
backup: make pylint happy
Use 'vm_info' instead of restore_info['dom0'], as it is available inside
the loop. And break some lines to not exceed 80 chars..
2017-12-22 17:23:27 +01:00
Marek Marczykowski-Górecki
c2281fefc8
Merge remote-tracking branch 'qubesos/pr/43'
* qubesos/pr/43:
  Fix dom0-related issues
2017-12-22 17:19:59 +01:00
Christopher Laprise
c6bc4f05cb
Fix dom0-related issues 2017-12-11 10:16:53 -05:00
Marek Marczykowski-Górecki
5944de1eed
Make pylint happy 2017-12-10 22:42:48 +01:00
Christopher Laprise
d84423b0b2
verify-only avoid dom0 handler 2017-12-07 22:36:58 -05:00