Commit Graph

138 Commits

Author SHA1 Message Date
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