Commit Graph

267 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
d88da1e66b wni: add missing parameter 2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
f6729b4968 wni: use generated password 2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
5dbad01796 Fill some more WNI settings
Especially use new "wni" libvirt driver.
2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
ea68c6a766 xen: fix template vm storage code 2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
11047bf427 Use platform specific locking method
None of found existing portable locking module does support RW locks.
Use lowlevel system locking support - both Windows and Linux support
such feature.

Drop locking code in write_firewall_conf() b/c is is called with
QubesVmCollection lock held anyway.
2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
a5a2c0b97c Revert "release qubes.xml lock on object destroy"
This reverts commit 39e056b74acca3854c5707d8f2cbcd199b8cac75.
This change rely on reverted python-locking use.
2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
5fb1991ad5 QubesWniVmStorage: prefix system user with "qubes-vm-". 2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
f927f12e39 QubesWniVmStorage: pass all positional parameters to base class 2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
392b70a4d8 Create missing private.img when needed
Not only for HVM, but any VM type which support private.img.
2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
21c908b9b2 Move storage-related VM rename code to storage class 2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
ada5ebd784 Use "None" in *_img attr for "not applicable"
Some VM types do not have particular disk image. Instead of enumerating
cases in storage class, signal unused image from VM class by setting
appropriate attr to None.
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
e2bea656b4 Add vm-configs for WNI 2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
ec37a4e681 Rename vm-configs directory to be more generic 2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
35ecfc82ef wni: QubesWniVmStorage and update settings file 2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
e8715cd561 release qubes.xml lock on object destroy
This will ensure that lock will be released even in case of error.
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
50188c8832 Use relative path in system_path dict instead of path templates
This will allow use of correct slashes/backslashes (os.path.join instead
of hardcoded '/').
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
a17f6ef779 Update QubesHVM to use QubesVmStorage classes
Also add external drive support to QubesXenVmStorage (move from
QubesHVM).
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
b323a4d1e3 core: Fix handling the case when no settings file present. 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
50e44ce22d makefile: Improve readability of settings.py install command 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
ec17f7d329 core/xen: setup xen-specific defaults in separate settings file 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
0a1f3d0a44 core: split VM images handling to separate class
This will ease handling different types of VMM (which can require
different image types, location etc).
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
a8bee8d978 Ignore error when 'xen.lowlevel.xs' doesn't exists
There are still few uses of direct xenstore access, most of them are
xen-specific (so doesn't need to be portable). For now simply don't
connect to xenstore when no 'xen.lowlevel.xs' module present. It will
break such xen-specific accesses - it must be somehow reworked - either
by adding appropriate conditionals, or moving such code somewhere else
(custom methods of libvirt driver?).
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
bc58ca5edb Remove import xen.lowlevel.xc
There is still use of it: QubesHost.get_free_xen_memory and
QubesHost.measure_cpu_usage. Will migrate them to libvirt later (for now
some things will be broken - namely qubes-manager).
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
6193b4fea3 Add support for VMM-specific settings. 2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
80c89cc91c Delay resolving system_path['qubes_base_dir']
So changes made by os/vmm-specific settings would be taken into account.
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
f6835346d4 Move initialization code at the end of file
So all of it will be in one place.
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
0009805041 rpm+makefile: move build/install code to Makefile files
This makes build "scripts" not tied to Fedora-specific files. Especially
ease porting to other platforms.
2014-11-19 12:50:24 +01:00
Marek Marczykowski
f159f3e168 Use QubesDB instead of Xenstore.
Mostly done. Things still using xenstore/not working at all:
 - DispVM
 - qubesutils.py (especially qvm-block and qvm-usb code)
 - external IP change notification for ProxyVM (should be done via RPC
   service)
2014-11-19 12:48:28 +01:00
Marek Marczykowski
b8c62c0279 Wrap all VMM connection related object into QubesVMMConnection class
This makes easier to import right objects in submodules (only one
object). This also implement lazy connection - at first access, not at
module import, which speeds up tools, which doesn't need runtime
information (like qvm-prefs or qvm-service). In the future this will
ease migration from xenstore to QubesDB.

Also implement "offline mode" - operate on qubes.xml without connecting
to VMM - raise exception at such try.
This is needed to run tools during installation, where only minimal
set of services are started, especially no libvirt.
2014-11-19 12:48:26 +01:00
Marek Marczykowski
a880483092 Migration to libvirt - core part
Still not all code migrated, added appropriate TODO/FIXME comments.
2014-11-19 12:47:00 +01:00
Marek Marczykowski-Górecki
247cff335f core: fix race condition in qubes.xml locking (#906)
QubesVmCollection.save() overrides qubes.xml by creating new file, then
renaming it over the old one. If any process has that (old) file open
at the same time - especially while waiting on lock_db_for_writing() -
it will end up in accessing old, already unlinked file.

The exact calls would look like:
P1                                      P2
lock_db_for_writing
  fd = open('qubes.xml')
  fcntl(fd, F_SETLK, ...)

                                      lock_db_for_writing
                                          fd = open('qubes.xml')
                                          fcntl(fd, F_SETLK, ...)
...
save():
    open(temp-file)
    write(temp-file, ...)
    ...
    flush(temp-file)
    rename(temp-file, 'qubes.xml')
    close(fd) // close old file

                                      lock_db_for_writing succeed
                                      *** fd points at already unlinked
                                          file
unlock_db
    close(qubes.xml)

To fix that problem, added a check if (already locked) file is still the
same as qubes.xml.
2014-10-22 03:53:30 +02:00
Marek Marczykowski-Górecki
ed0eabb482 backups: use default kernel if saved one is not installed 2014-10-01 03:50:50 +02:00
Marek Marczykowski-Górecki
55d89698a3 backups: minor fixes 2014-09-28 03:20:47 +02:00
Marek Marczykowski-Górecki
77da00e3ca backups: fix handling incomplete restore
We do not cancel the whole restore at first error.
2014-09-28 03:20:40 +02:00
Marek Marczykowski-Górecki
0cd8281ac1 backups: implement compression in backup format 3 (#775)
Since tar multi-archive no longer used, we can simply instruct tar to
pipe output through gzip (or whatever compressor we want). Include used
compressor command in backup header.
2014-09-26 14:42:07 +02:00
Marek Marczykowski-Górecki
fc0c0adff8 backups: do not use tar multi-volume feature, backup format 3 (#902)
Tar multi-volume support is broken when used with sparse files[1], so do
not use it. Instead simply cut the archive manually and concatenate at
restore time. This change require a little modification in restore
process, so make this new backup format ("3"). Also add backup format
version to the header, instead of some guessing code.
For now only cleartext and encrypted backups implemented, compression
will come as a separate commit.
2014-09-26 14:29:20 +02:00
Marek Marczykowski-Górecki
2c3159c7f9 backups: remove trailing semicolon 2014-09-26 03:19:21 +02:00
Marek Marczykowski-Górecki
58128a574a backups: force ASCII when writing backup header 2014-09-26 02:18:47 +02:00
Marek Marczykowski-Górecki
ec45308f1c backups: better handle quiet mode (for tests) 2014-09-25 05:47:35 +02:00
Victor Lopez
99315fd02c support partitions on loop devices
loop device parsing should have "dXpY_style = True" in order to
correctly parse partitions on loop devices.

Reasoning:
==========
Using losetup to create a virtual SD card disk into a loop device and
creating partitions for it results in new devices within an AppVM that
look like: /dev/loop0p1 /dev/loop0p2 and so on.

However as soon as they are created, Qubes Manager rises an exception
and becomes blocked with the following message (redacted):
"QubesException: Invalid device name: loop0p1
at line 639 of file /usr/lib64/python2.7/site-
packages/qubesmanager/main.py

Details:
line: raise QubesException....
func: block_name_to_majorminor
line no.: 181
file: ....../qubes/qubesutils.py
2014-09-19 11:00:56 +02:00
Marek Marczykowski-Górecki
dba6798a60 backups: change default HMAC algorithm to SHA512
Backups should be safe also for long-term, so change HMAC to SHA512,
which should be usable much longer than SHA1.

See this thread for discussion:
https://groups.google.com/d/msg/qubes-devel/5X-WjdP9VqQ/4zI8-QWd0S4J

Additionally save guessed HMAC in artificial header data (when no real
header exists).
2014-09-18 08:35:09 +02:00
Marek Marczykowski-Górecki
a12cf158da backups: handle empty tar output 2014-09-18 07:39:19 +02:00
Marek Marczykowski-Górecki
b506a0cc15 backups: make the restore more defensive
Continue restore even if some fails failed to extract
2014-09-17 23:12:27 +02:00
Marek Marczykowski-Górecki
2c7fbd88e2 backups: include tar error message when reporting problem with inner tar archive
Previously this message goes to /dev/null (unless BACKUP_DEBUG enabled),
so the user got cryptic "Restore failed" message without any clue about
the cause.
2014-09-17 23:12:27 +02:00
Marek Marczykowski-Górecki
ec74ebdc32 backups: fix handling of unicode in error messages, clean up "ERROR:" prefix usage
When non-english language is set, some processes can output non-ASCII
characters in error messages. Handle them nicely.

Also make error messages more consistent about "ERROR:" prefix. Do not
use this prefix in QubesException message, add it just before showing
the message to the user.
2014-09-17 23:12:19 +02:00
Marek Marczykowski-Górecki
228ae07543 backups: improve errors handling
Report nice error message (not a traceback), interrupt the process on
non-recoverable error (when extraction process is already dead).
2014-09-17 14:43:41 +02:00
Marek Marczykowski-Górecki
f0bbb28398 backups: implement verify-only option (#863) 2014-09-17 14:43:27 +02:00
Wojciech Zygmunt Porczyk
d7958625c6 core+modules: provide meaingful repr()s for some classes 2014-08-11 16:34:33 +02:00
Marek Marczykowski-Górecki
2f9247c39d notify: missing import 2014-07-20 13:39:02 +02:00
Marek Marczykowski-Górecki
913dac7b09 core: change default icon size
GUI daemon accepts up to 128x128 icons, so use that size by default.
2014-07-16 02:55:42 +02:00
Wojciech Zygmunt Porczyk
f55fc1655d core/qubes.py: migrate to new label icons 2014-07-10 16:17:58 +02:00
Wojciech Zygmunt Porczyk
8ff423dc9a Fix ignore-username-mismatch (#859) 2014-06-25 16:00:32 +02:00
Marek Marczykowski-Górecki
fcc77167a9 block: fix support for device-mapper devices 2014-06-07 04:54:15 +02:00
Marek Marczykowski-Górecki
a1d6ce433a core: fix name conflict in tray_notify_* functions 2014-06-07 01:13:54 +02:00
Marek Marczykowski-Górecki
1ed9c74d83 Rearrange code to not import PyQt on every qvm-* call
Move notification functions to separate file (out of guihelpers).
2014-06-05 01:59:42 +02:00
Marek Marczykowski-Górecki
44f38fe076 Declare file encoding for all python files, fill missing copyright headers
Without that, python do not accept UTF-8 even in comments.
2014-05-18 21:03:27 +02:00
Marek Marczykowski-Górecki
39496bf65a backups: use more restrictive pattern for directory canonicalization (#840)
The --xform option affects all the names - including symlink targets. So
make the pattern as precise as possible to not break symlinks in dom0
home backup. Still not ideal, but at least limit damage to relative
symlinks pointing at <username> directory (which hopefully user will
not create). Previous version broke all relative symlinks...
2014-05-13 03:18:08 +02:00
Marek Marczykowski-Górecki
b8b2733114 core: fix un-setting global VMs (default netvm, clockvm etc) 2014-05-05 05:24:04 +02:00
Wojciech Zygmunt Porczyk
624ab67e86 qubesutils.py: don't fail on broken symlinks 2014-05-02 17:03:50 +02:00
Wojciech Zygmunt Porczyk
1840420331 qubesutils.py: fix get_disk_usage hidden exception 2014-04-30 15:43:35 +02:00
Wojciech Zygmunt Porczyk
4b15838009 qubesutils.py: remove imported but unused classes
This is needed to remove circular dependency with modules.

This commit is part of #822 fix.
2014-04-28 12:19:52 +02:00
Wojciech Zygmunt Porczyk
ee059df63e qubesutils.py: get_disk_usage
get_disk_usage is moved from code-modules and backup.py and rewritten not to
call external du

This commit is part of #822 fix.
2014-04-24 21:50:12 +02:00
Marek Marczykowski-Górecki
f324f4eef8 core: verify template compatibility when adding new VM
It is done in Qubes Manager, but do it at lower level - especially for
qvm-create tool.
2014-04-18 01:35:12 +02:00
Marek Marczykowski-Górecki
ef09f2ed2a Disable PAT in linux VMs
Apparently kernel patch "x86/cpa: Use pte_attrs instead of pte_flags on
CPA/set_p.._wb/wc operations" (in out repo) doesn't fully solve the
problem and sometimes qubes-gui agent crashes with message like
"qubes-gui:664 map pfn expected mapping type write-back for [mem
0x00093000-0x00093fff], got uncached-minus".
Because PAT we really need only in dom0 (lack of it dramatically
decrease performance of some graphics drivers), we can simply disable it
in VM - as it is currently done in upstream kernel.
2014-04-16 16:44:42 +02:00
Marek Marczykowski-Górecki
5cbfb64a57 qubesutils: enable/disable updates check on all the VMs and dom0 (#800) 2014-04-11 07:06:12 +02:00
Marek Marczykowski-Górecki
bc70581bd3 qubesutils: Add meminfo watching to QubesWatch class (#788) 2014-03-31 03:45:21 +02:00
Marek Marczykowski-Górecki
9e7b8a63bc qubesutils: reduce code duplication in QubesWatch class 2014-03-30 22:53:34 +02:00
Marek Marczykowski-Górecki
5d7688a2fe backups: allow provide full path for the backup (instead of directory) (#801)
This will allow the user to choose custom filename, instead of
auto generated 'qubes-backup-XXX'.
2014-03-17 21:15:39 +01:00
Marek Marczykowski-Górecki
b298110d5f backups: list VMs not selected for backup (#801) 2014-03-14 16:31:04 +01:00
Marek Marczykowski-Górecki
09652cb0f8 core: store date of last backup for each VM 2014-03-10 04:29:14 +01:00
Marek Marczykowski-Górecki
1d4a26f3a8 add convenient symlinks simulating target python files layout 2014-03-10 01:05:01 +01:00
Marek Marczykowski-Górecki
f4194c9d08 backups: implement async backup/restore cancel method (#793)
The backup_cancel() method kills processes registered by main thread and
set "running_backup_operation.canceled" to True. Then main thread get an
error because of killed processes and check if that was because of
cancel request.

Introduce BackupCanceledError, which can report temporary dir to remove.
2014-03-08 03:55:47 +01:00
Marek Marczykowski-Górecki
b52d1a4379 backups: remove unused variables 2014-03-08 03:55:23 +01:00
Marek Marczykowski-Górecki
7e507cba6a backups: fix header handling when restoring from VM
Do wait for nest reported filename only when restoring directly from
dom0. In VM case it isn't necessary and will cause false error report
(because filename will be set to nextfile at the end of restore process,
 so will be treated as spurious file without hmac).
2014-03-08 03:52:21 +01:00
Marek Marczykowski-Górecki
4a56b65b59 backups: fix error reporting, do not report EOF as an error
Do not report main thread error (notified as "ERROR" file) as
ExtractWorker error.
2014-03-08 03:50:08 +01:00
Marek Marczykowski-Górecki
c430355a5b backups: correctly mark if dom0 is present in the backup
Reset dom0 "backup_content" flag to False, then possibly set it to True.
2014-03-08 03:46:41 +01:00
Marek Marczykowski-Górecki
11961cbbff qvm-block: fix handling unusual devices attached to dom0
Simply get device major-minor from /dev/ device file.
This is only partial solution, because this will work only for dom0
devices, but the same problem can apply to VM.
2014-03-05 00:49:28 +01:00
Marek Marczykowski-Górecki
62457da085 Merge branch 'appicons' 2014-02-07 05:52:36 +01:00
Danny Fullerton
8dbc417642 backups: Fix backup's passphrase unicode encoding issue 2014-02-05 06:51:47 +01:00
Marek Marczykowski-Górecki
7278102aef backups: fix VM size calculation
Count only files included in the backup, not all of them (so ignore
temporary files etc).
2014-02-05 05:48:55 +01:00
Marek Marczykowski-Górecki
f461c09d89 backups: improve error message 2014-02-05 04:34:30 +01:00
Marek Marczykowski-Górecki
f2f9f568cd backups: enforce estimated upper limit on extracted files count
Do not allow (compromised) source VM to use all inodes.
2014-02-05 02:48:00 +01:00
Marek Marczykowski-Górecki
038877d35d backups: fix tar output handling
Tar print the filename right _before_ processing the file, so wait for
the next filename before processing actual file.
2014-02-01 14:03:26 +01:00
Marek Marczykowski-Górecki
75c0e775a4 backups: simplify EOL markers handling
Let the python do it right.
2014-02-01 14:02:38 +01:00
Marek Marczykowski-Górecki
a17b7f584d backups: improve exception reporting during extract
Report original exception location, not the wrapper function.
2014-02-01 14:01:21 +01:00
Marek Marczykowski-Górecki
f1bb17a3e1 backups: improve error reporting for invalid backup directory 2014-01-19 04:51:46 +01:00
Marek Marczykowski-Górecki
a6740610e3 backups: fix handling new format without backup header
Tar will report error when 'backup-header' file wasn't found. Ignore
this particular error.
2014-01-19 04:50:56 +01:00
Marek Marczykowski-Górecki
49259dacf6 backup: minor fix in function arguments 2014-01-19 04:50:23 +01:00
Marek Marczykowski-Górecki
849cfbf826 Merge remote-tracking branch 'woju/master' into appicons 2014-01-16 05:13:05 +01:00
Marek Marczykowski-Górecki
26b32ca51e backups: refuse to create encrypted and compressed backup (#775) 2014-01-15 05:00:13 +01:00
Marek Marczykowski-Górecki
357fe37ed2 backups: change data/time delimiter in filename according to ISO 8601 2014-01-15 04:34:51 +01:00
Marek Marczykowski-Górecki
50c00e555e backups: make cleanup code more defensive
If we are killing remaining processes in cause of exception, ignore
failure here (OSError is raised in case of non existing process).
2014-01-15 03:57:59 +01:00
Marek Marczykowski-Górecki
7b1e9f3bfb backups: implement backup header
It stores basic backup information like used hmac/crypto algorithm,
whether backup is encrypted/compressed and possibly more. The header
file is parsed only after successful HMAC verification. Because we do
not know which HMAC algorithm was used before reading the header, try to
guess trying all supported (starting with the default one).

Backup header is stored as the first file, which is always not encrypted
and not compressed. Then qubes.xml follows.
2014-01-15 03:53:45 +01:00
Marek Marczykowski-Górecki
4c29d743c8 backups: introduce configurable HMAC/encryption algo
For now always set it to default values (no frontend application uses
those parameters), but be prepared for further improvements.
2014-01-15 03:50:29 +01:00
Marek Marczykowski-Górecki
4b493b6d9a backups: unify compress/encrypt parameter names 2014-01-15 03:45:12 +01:00
Marek Marczykowski-Górecki
a2037a4985 backups: do not hardcode limit values in the code (#771)
Also introduce limit for stderr read from VM (anti DoS protection).
2014-01-15 03:36:16 +01:00
Marek Marczykowski-Górecki
b85cd0448f backups: minor fixes, mostly formatting 2014-01-15 01:05:54 +01:00
Marek Marczykowski-Górecki
40953176f4 backups: reorganise restore API
Call backup_restore_header from backup_restore_prepare, there is no
sense in requiring the user to call them separately. Also store all
parameters in restore_info object as special '$OPTIONS$' VM to not
require passing them twice (with all the chances for the errors).
2014-01-13 04:45:02 +01:00
Marek Marczykowski-Górecki
338fc74ea2 backups: misc minor fixes 2014-01-13 04:37:54 +01:00
Marek Marczykowski-Górecki
c6ca2725a1 backups: rename classes according to coding style 2014-01-13 04:27:19 +01:00
Wojciech Porczyk
962d3da42e
appicons
labels need to be specified with colour code
also fixed duplicate QubesDispVmLabels
2014-01-11 00:07:55 +01:00
Marek Marczykowski-Górecki
c825a41909 backups: ignore EPIPE on pipe.close()
This is most likely some padding left in output buffer. See #764
comments for details.
2014-01-10 03:31:15 +01:00
Marek Marczykowski-Górecki
6abca8ce57 backups: do not chdir() in main process
This can be any application, for example Qubes Manager. Changing current
dir can have side effects, especially when we do not change it back
after restore (or in any error encountered).
2014-01-10 03:30:59 +01:00
Marek Marczykowski-Górecki
29bd92aad9 backups: terminate Extract_Worker on error in main process 2014-01-10 03:28:53 +01:00
Marek Marczykowski-Górecki
d86865d299 backups: fix passing -z option to openssl
Note that this is not fix #775 in any way.
2014-01-10 03:26:50 +01:00
Marek Marczykowski-Górecki
01312a17d6 backups: improve error handling in Extract_Worker
Terminate children when exception raised. Also rename tar2_command to
tar2_process to improve readability.
2014-01-10 03:23:51 +01:00
Marek Marczykowski-Górecki
eeca3eb697 backups: improve error reporting when something failed in dest VM 2014-01-10 03:20:48 +01:00
Marek Marczykowski-Górecki
bcf1a19807 backups: fix include/exclude of dom0 home in backup
Place it in the list just like the other VMs. Then handle separately.
2014-01-10 03:19:22 +01:00
Danny Fullerton
268dcfd71d Fix qvm-block crash with /dev/mdXpY devices 2014-01-08 11:51:05 +01:00
Marek Marczykowski-Górecki
994e963ab8 backup: fix handling errors in source VM 2013-12-29 03:20:27 +01:00
Olivier MEDOC
3fcfbbac22 backups: fix trailing slashes for anonymized vm dirnames 2013-12-10 17:02:45 +01:00
Marek Marczykowski-Górecki
84f8a8a8f1 backups: fix restore dom0 home from old backup format 2013-12-06 06:55:23 +01:00
Marek Marczykowski-Górecki
99b001502a backups: compression support 2013-12-02 14:05:41 +01:00
Marek Marczykowski-Górecki
1939cf7ce8 backups: report exception on backup write error
This is only partial solution - this happens in separate thread so main
thread may not notice this problem (and simply will wait on work queue).
2013-12-02 14:04:20 +01:00
Marek Marczykowski-Górecki
bc92c20d67 core: do not truncate qubes.xml during save()
Save the next one in temporary file, then move over to destination file.
This way when writing the file to disk fails (e.g. out of disk space),
user still have old file version intact.
2013-12-02 03:50:55 +01:00
Marek Marczykowski-Górecki
93b7924bc6 backups: hide unwanted "next volume requests" from tar 2013-12-02 03:49:44 +01:00
Marek Marczykowski-Górecki
e9f08aefd7 backups: disable debugging code 2013-12-01 02:35:42 +01:00
Marek Marczykowski-Górecki
27f6f0e64e Merge branch 'new-backups'
Conflicts:
	core-modules/000QubesVm.py
2013-11-29 04:00:58 +01:00
Marek Marczykowski-Górecki
b73970c62d core: rename QubesDom0NetVm to QubesAdminVm
This is somehow related to #757, but only first (easier) step. Actual
change of QubesAdminVm base class requires somehow more changes, for
example qvm-ls needs to know how to display this type of VM (none of
template, appvm, netvm).

Make this first step change now, because starting with R2Beta3 dom0 will
be stored in qubes.xml (for new backups purposes) so this rename would
be complicated later.
2013-11-29 03:42:56 +01:00
Marek Marczykowski-Górecki
3d70402778 backups: add support for restoring old backup format
Actually the code is quite similar, so just add few "if" instead of
copying the whole functions.
2013-11-29 03:25:41 +01:00
Marek Marczykowski-Górecki
eaebf04b34 backups: remove some old unneeded code 2013-11-27 03:21:17 +01:00
Marek Marczykowski-Górecki
c8b8cd0d1f backups: fix restore in non-debug mode 2013-11-27 03:20:45 +01:00
Marek Marczykowski-Górecki
105428accb backups: fix encrypted backup restore 2013-11-27 03:20:26 +01:00
Marek Marczykowski-Górecki
10100767da backups: hide VM names in encrypted backup
Even when encrypted backup is selected, file list isn't encrypted. Do
not leak VM names in the filenames.
2013-11-27 03:19:23 +01:00
Marek Marczykowski-Górecki
8bdea5b0ab backups: fix backup of selected appmenus for VM
This wasn't working for a long time...
2013-11-27 03:18:14 +01:00
Marek Marczykowski-Górecki
2d68b79bff backups: fix backup of templates
Template is saved as single archive of the whole VM directory. Preserve
backup directory structure regardless of its content - in this case it
means we need "." archive (with template directory content) placed in
"vm-tempates/<template-name>/" backup directory. This allows restore
process to select right files to restore regardless of VM type.
2013-11-26 16:46:34 +01:00
Marek Marczykowski-Górecki
50662bf090 backups: correctly calculate size of file to backup 2013-11-26 16:46:09 +01:00
Marek Marczykowski-Górecki
0b0d50edf3 backups: move import at the beginning of .py file 2013-11-26 16:45:51 +01:00
Marek Marczykowski-Górecki
0743531244 backups: fix VM exclude logic (restore) 2013-11-25 06:33:06 +01:00
Marek Marczykowski-Górecki
bf6bf8ed8f backups: fix backup header extraction
Pass only 'qubes.xml.000' to tar2qfile - this way it will stop reading
the source after requested file(s).
2013-11-25 06:31:38 +01:00
Marek Marczykowski-Górecki
cc37927080 backups: fix backup cleanup 2013-11-25 05:46:57 +01:00
Marek Marczykowski-Górecki
c781a522d8 backups: move backup code to separate file
Also some major cleanups: Reduce some more code duplication
(verify_hmac, simplify backup_restore_prepare). Rename
backup_dir/backup_tmpdir variables to better match its purpose. Rename
backup_do_copy back to backup_do.  Require QubesVm object (instead of VM
name) as appvm param.
2013-11-25 05:41:13 +01:00
Marek Marczykowski-Górecki
657beaf655 backups: move extracted dom0 home from /var/tmp instead of copy 2013-11-25 01:11:29 +01:00
Marek Marczykowski-Górecki
e31c3ae8e7 backup: reduce volume size to 100M and limit queue length
This way backup process won't need more than 1GB for temporary files and
also will give more precise progress information. For now it looks like
the slowest element is qrexec, so without such limit, all the data would
be prepared (basically making second copy of it in dom0) while only
first few files would be transfered to the VM.
Also backup progress is calculated based on preparation thread, so when
it finishes there is some other time needed to flush all the data to the
VM. Limiting this amount makes progress somehow more accurate (but still
off by 1GB...).
2013-11-25 00:55:59 +01:00
Marek Marczykowski-Górecki
10a01010bb backups: fix handling multi-volume archive during restore
We can't wait for tar next volume prompt using stderr.readline(),
because tar don't output EOL marker after this prompt. The other way
would be switching file descriptor to non-blocking mode and using lower
level os.read(), but this looks like more error-prone way (races...).
So change idea of handling such archives: after switching to next
archive volume, simply send '\n' to tar (which will receive when
needed). When getting "*.000" file, assume that previous archive was
over and wait for previous tar process. Then start the new one.

Also don't give explicit tape length, only turn multi-volume mode on. So
will correctly handle all multi-volume archives, regardless of its size.
2013-11-25 00:48:54 +01:00
Marek Marczykowski-Górecki
7229b78bbf backups: minor reduce code duplication 2013-11-25 00:48:00 +01:00
Marek Marczykowski-Górecki
bc59d7e054 backups: include file path in internal archive, implement dom0 home restore
This is mostly revert of "3d1b40f backups: keep file without path in
inner tar archive" in terms of archive format, but the code is more
robust than old one. Especially reuse already computed dir paths. Also
restore only requested files (based on selected VMs and its qubes.xml
data). Change the restore workflow to restore files first to temporary
directory, then move to final dirs. This approach:
 - will be compatible with hashed vm name in the archive path
 - is required to handle dom0 home backup (directory outside of
   /var/lib/qubes)
 - it should be also more defensive - make any changes in /var/lib/qubes
 only after successful extraction of files and creating Qubes*Vm object

Second change in this commit is implement of dom0 home backup/restore.
As qubes.xml now contains data about dom0, we have information whether
it is included in the backup (before getting actual files).
2013-11-25 00:36:40 +01:00
Marek Marczykowski-Górecki
dc6fd3c8f3 core: store dom0 info in qubes.xml
At least to have there info about its backup.
2013-11-24 23:50:39 +01:00
Marek Marczykowski-Górecki
a64f7c12ad backups: desperate try to improve readability
Especially kill long lines.
2013-11-24 23:49:53 +01:00
Marek Marczykowski-Górecki
c306b9c00a backups: increase readability of long function calls 2013-11-24 23:49:53 +01:00
Marek Marczykowski-Górecki
5477aea877 backups: increase buffer size for better performance
After this change the bottleneck is qrexec throughput.
2013-11-24 23:49:53 +01:00
Marek Marczykowski-Górecki
c64b6c04ce backups: make all the debug easy to disable 2013-11-24 23:49:39 +01:00
Marek Marczykowski-Górecki
005db6a5ab backups: fix race condition in "tape" change event during backup
Ensure that outer tar/encryptor gets all the data *and EOF* before
signalling inner tar to continue. Previously it could happen that inner
tar begins to write next data chunk, while qvm-backup still holds
previous data chunk open.
2013-11-24 03:28:21 +01:00
Marek Marczykowski-Górecki
3d1b40f25c backups: keep file without path in inner tar archive
It is senseless to have full file path in multiple locations:
 - external archive
 - qubes.xml
 - internal archive
Also it is more logical to have only "private.img" file in archive
placed in "appvms/untrusted/private.img.000". Although this is rather
cosmetic change for VMs data, it is required to backup arbitrary
directory, like dom0 user home.

Also use os.path.* instead of manual string operations (split,
partition). It is more foolproof.
2013-11-24 03:23:27 +01:00
Marek Marczykowski-Górecki
61b3a81e82 backup: remove unused argument from backup_prepare 2013-11-24 03:17:15 +01:00
Marek Marczykowski-Górecki
e7701d9c5d backup: check for disk space if target is local directory 2013-11-24 03:15:44 +01:00
Olivier MEDOC
51f119326b backup: improved error handling during restore 2013-11-23 02:44:05 +01:00
Olivier MEDOC
e875ae9d06 backups: use tar2qfile filtering to enable partial backup restore 2013-11-23 02:44:05 +01:00
Marek Marczykowski-Górecki
2005207462 Template support for HVM (#719)
Any HVM (which isn't already template-based) can be a template for
another HVM. For now do not allow simultaneous run of template and its
VM (this assumption simplify the implementation, as no root-cow.img is
needed).
2013-11-19 18:42:59 +01:00
Marek Marczykowski-Górecki
dfa9e7c0df Add device-mapper devices to name->(major,minor) mapping
qvm-block will still not list device-mapper devices, but it would be
much easier to modify it.
2013-11-16 01:29:50 +01:00