Commit Graph

268 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
e0686e1e02 backup: initial conversion to core3 API 2016-04-07 13:05:25 +02:00
Wojtek Porczyk
9eafa57539 Merge remote-tracking branch 'marmarek/master' into core3-devel
The following list is bollocks. There were many, many more.

Conflicts:
    core-modules/003QubesTemplateVm.py
    core-modules/005QubesNetVm.py
    core/qubes.py
    core/storage/__init__.py
    core/storage/xen.py
    doc/qvm-tools/qvm-pci.rst
    doc/qvm-tools/qvm-prefs.rst
    qubes/tools/qmemmand.py
    qvm-tools/qvm-create
    qvm-tools/qvm-prefs
    qvm-tools/qvm-start
    tests/__init__.py
    vm-config/xen-vm-template-hvm.xml

This commit took 2 days (26-27.01.2016) and put our friendship to test.
    --Wojtek and Marek
2016-03-03 01:13:51 +01:00
Marek Marczykowski-Górecki
8b9049d8c6
core/hvm: create root-cow.img if it's missing
It should be created at VM creation time (or template changes commit).
But for example for HVM templates created before implementing
QubesOS/qubes-issues#1573, there would be no such image. So create it
when needed, just before VM startup

Fixes QubesOS/qubes-issues#1602
2016-01-11 21:53:33 +01:00
Marek Marczykowski-Górecki
ba3b908b73
backup: do not dereference symlinks in dom0 user home backup
Symlinks there should be preserved. Additionally broken symlink would
cause the backup to fail.

Fixes QubesOS/qubes-issues#1515
2016-01-07 05:48:33 +01:00
Marek Marczykowski-Górecki
35cb82cd2b
storage: use root-cow.img for HVM template, to support reverting changes
We still can't support running HVM template and its VMs simultaneously
(easily), but still, have root-cow.img handled for HVM template, to
allow qvm-revert-template-changes.

Fixes QubesOS/qubes-issues#1573
2016-01-07 05:48:32 +01:00
Marek Marczykowski-Górecki
fa196f1350
storage: actually use storage.root_img and such properties
Actual VM root disk used hardcoded image names, instead of properties
set for that purpose...
2016-01-07 05:48:32 +01:00
Bahtiar `kalkin-` Gadimov
c8d26c253e Storage refactor device config generation
- QubesVmStorage provides now a default get_config_params() method which should
  be enough for all possible Storage implementations.
- When writing a custom Storage implementation, one has just to reimplement the
  following methods:
  * root_dev_config()
  * private_dev_config()
  * volatile_dev_config()
- QubesVmStorage provides a default implementation of other_dev_config(),
  because it can be shared by all storage implementations
2015-12-22 11:24:28 +01:00
Marek Marczykowski-Górecki
b114d291ca
Merge remote-tracking branch 'qubesos/pr/12'
* qubesos/pr/12:
  Fix circular deps workaround in Pool.vmdir_path()
  Move device names from XenStorage to QubesVmStorage
  Provide method format_disk_dev() to all storages
  Move the vmdir logic from XenPool to Pool
2015-11-27 20:00:37 +01:00
Marek Marczykowski-Górecki
24d660d61e
backup: add option to on-the-fly renaming conflicting VMs
Fixes QubesOS/qubes-issues#869
2015-11-27 20:00:34 +01:00
Marek Marczykowski-Górecki
2fdbf51ccc
core: have QubesVmCollection.unlock_db no-op if not locked 2015-11-27 20:00:19 +01:00
Bahtiar `kalkin-` Gadimov
f5cef35cdf Fix circular deps workaround in Pool.vmdir_path() 2015-11-25 16:01:28 +01:00
Bahtiar `kalkin-` Gadimov
85421e3f48 Move device names from XenStorage to QubesVmStorage 2015-11-25 12:49:56 +01:00
Bahtiar `kalkin-` Gadimov
9b23576ff6 Provide method format_disk_dev() to all storages
The method XenStorage._format_disk_dev() generates the xml config for a device.
It is not specific to the Xen file storage implementation. It can and must be
reused by other storage implementations
2015-11-25 12:48:47 +01:00
Bahtiar `kalkin-` Gadimov
feaaaa75fa Move the vmdir logic from XenPool to Pool
Any storage implementation needs this logic for saving the vm config and
`*.desktop` files.
2015-11-25 12:47:25 +01:00
Marek Marczykowski-Górecki
0c476f014d
backup: avoid deadlock when VM process fails
If SendWorker queue is full, check if that thread is still alive.
Otherwise it would deadlock on putting an entry to that queue.
This also requires that SendWorker must ensure that the main thread
isn't currently waiting for queue space when it fails. We can do this by
simply removing an entry from a queue - so on the next iteration
SendWorker would be already dead and main thread would notice it.
Getting an entry from queue in such (error) situation is harmless,
because other checks will notice it's an error condition.

Fixes QubesOS/qubes-issues#1359
2015-11-25 01:35:04 +01:00
Bahtiar `kalkin-` Gadimov
885dc5cd81 Rename storage dir to dir_path, type to driver
Bad idea to use attributes which are named after built in functions.
2015-11-21 14:46:23 +01:00
Bahtiar `kalkin-` Gadimov
9eee00c6d7 QubesNetVm and subclasses use servicevm/ as vmdir 2015-11-17 21:21:02 +01:00
Bahtiar `kalkin-` Gadimov
1934f06869 XenStorage add DisposableVm handling 2015-11-17 21:15:13 +01:00
Bahtiar `kalkin-` Gadimov
76224dac86 Path to the Vm images is set by the storage
- This moves the logic for setting the path to the storage specific class like
  XenStore
2015-11-17 19:37:20 +01:00
Bahtiar `kalkin-` Gadimov
0bc0bc9045 XenStorage make sure subdirs exist in pool dir 2015-11-17 19:37:20 +01:00
Bahtiar `kalkin-` Gadimov
58f23ca392 Add configurable pool_dir to XenPool 2015-11-17 19:37:20 +01:00
Bahtiar `kalkin-` Gadimov
16d480cf4c Add storage add_pool & remove_pool 2015-11-17 19:37:19 +01:00
Bahtiar `kalkin-` Gadimov
26711e7e9a Use default pool_config if pool name is 'default' 2015-11-17 19:37:19 +01:00
Bahtiar `kalkin-` Gadimov
78891dd70f QubesVm save the name of the storage pool used 2015-11-17 19:37:19 +01:00
Bahtiar `kalkin-` Gadimov
d1685a13df Add storage.pool_exists 2015-11-17 19:37:19 +01:00
Bahtiar `kalkin-` Gadimov
8e0207a199 Rename QubesXenVmStorage to XenStorage 2015-11-17 19:37:19 +01:00
Bahtiar `kalkin-` Gadimov
bfaf37dae5 Add pool config parsing 2015-11-17 19:37:18 +01:00
Bahtiar `kalkin-` Gadimov
15d5e6edbb Add Pool & XenPool 2015-11-17 19:37:18 +01:00
Bahtiar `kalkin-` Gadimov
7550fccf94 Removed WNI 2015-11-17 19:37:18 +01:00
Rusty Bird
3e3ac36f58
cp --reflink=auto to speed up clone/backup/restore on btrfs 2015-11-10 17:10:03 +00:00
Marek Marczykowski-Górecki
f714a8224b
backup: follow symbolic links
For a long time Qubes backup did not include symlinked files, which
apparently is quite common practice for users with multiple disks (for
example HDD + SSD). It is covered in documentation
(https://www.qubes-os.org/doc/secondary-storage/), but better solution
would be to simply include symlinked files.

Restore of such files would (of course) not preserve the symlinks -
normal files will be restored instead. But that's fine. If the user want
to move the data to another location, he/she can do that and restore the
symlink.

The only possible breakage from this change is having a copy (instead of
symlink) to a VM icon. But storing that symlink in a backup was broken
for some time (because of --xform usage) and it is handled during
restore, so not a real problem.

This doesn't cover all the problems with symlinked VM images - the other
one is qvm-block behaviour, which would treat such images as non-system
disks, so easily detachable (which would break VM operation). But that's
another story.

Fixes QubesOS/qubes-issues#1384
2015-11-07 05:03:54 +01:00
Marek Marczykowski-Górecki
8275e828af
backup: move existing directories out of the way during restore
In most cases it would be some leftover after failed restore, or even
the reason why the user is restoring a VM in the first place. Move it to
nearby directory, but do not remove - backup tool should _never_ remove
any data.

When the pre-existing directory would not be moved, restore utility
(`shutil.move`) would place the data inside of that directory, with
additional directory level (for example `/var/lib/qubes/appvms/work/work`),
which would be wrong and would later fail on `vm.verify_files`. And more
importantly - such VM would not work.

Fixes QubesOS/qubes-issues#1386
2015-11-07 05:03:54 +01:00
Marek Marczykowski-Górecki
0695e7ba78
utils/QubesWatch: register libvirt event loop only when really launched
Registering event implementation in libvirt and then not calling it is
harmful, because libvirt expects it working. Known drawbacks:
- keep-alives are advertised as supported but not really sent (cause
  dropping connections)
- connections are not closed (sockets remains open, effectively leaking
  file descriptors)

So call libvirt.virEventRegisterDefaultImpl only when it will be really
used (libvirt.virEventRunDefaultImpl called), which means calling it in
QubesWatch. Registering events implementation have effect only on new
libvirt connections, so start a new one for QubesWatch.

Fixes QubesOS/qubes-issues#1380
2015-11-07 03:51:51 +01:00
Marek Marczykowski-Górecki
93b7b3cb72
utils/QubesWatch: improve error handling (minor) 2015-11-07 03:51:50 +01:00
Marek Marczykowski-Górecki
d38883833a
core: ensure that QubesDB connections are closed when disposing a VM collection
There are some circular dependencies (TemplateVM.appvms,
NetVM.connected_vms, and probably more), which prevents garbage
collector from cleaning them.

Fixes QubesOS/qubes-issues#1380
2015-11-07 03:51:50 +01:00
Marek Marczykowski-Górecki
de295136ce
Fix "utils/QubesWatch: use timers to retry QubesDB watch registration" 2015-10-27 21:47:01 +01:00
Wojtek Porczyk
ea44c0acf3 qubes: pylint fixes
Fix bunch of errors and warnings.
2015-10-05 23:49:39 +02:00
Wojtek Porczyk
c538d536c8 core3: move qmemman
This is part of fixing qvm-start.

qmemman was moved with minimal touching, mainly module names.

Moved function parsing human-readable sizes from core2. This function is
wrong, because it treats k/M/G as 1024-based, but leave it for now.
2015-10-05 12:46:14 +02:00
Wojtek Porczyk
fcdb579bab core3: qubesmanager notifying extension
core/notify.py was excavated and tray notifying remnants were moved to
qubes.log. They are unused as yet.

Also extension events are fixed.
2015-10-05 12:46:14 +02:00
Marek Marczykowski-Górecki
64590423fd
Merge branch 'bug1110'
Fixes QubesOS/qubes-issues#1110
2015-10-02 01:58:46 +02:00
Marek Marczykowski-Górecki
ef6095662e
utils/QubesWatch: register domain watches on VIR_DOMAIN_EVENT_RESUMED
QubesVM.start() first creates domain as paused, completes its setup
(including starting qubesdb-daemon and creating appropriate entries),
then resumes the domain. So wait for that resume to be sure that
`qubesdb-daemon` is already running and populated.

QubesOS/qubes-issues#1110
2015-09-25 22:02:53 +02:00
Marek Marczykowski-Górecki
5f0d564051
utils/QubesWatch: use timers to retry QubesDB watch registration
QubesWatch._register_watches is called from libvirt event callback,
asynchronously to qvm-start. This means that `qubesdb-daemon` may
not be running or populated yet.

If first QubesDB connection (or watch registration) fails, schedule next
try using timers in libvirt event API (as it is base of QubesWatch
mainloop), instead of some sleep loop. This way other events will be
processed in the meantime.

QubesOS/qubes-issues#1110
2015-09-25 20:37:44 +02:00
Marek Marczykowski-Górecki
9205fbb336 backup: fix R2B3 and older backup restore (#1124)
Similar issue to qubesos/qubes-issues#1124
2015-09-06 00:06:09 +02:00
Marek Marczykowski-Górecki
76bddaa280 core: use vm.absolute_path to parse paths in qubes.xml
This makes easier to handle some corner cases. One of them is having
entry without `dir_path` defined. This may happen when migrating from R2
(using backup+restore or in-place) while some DisposableVM was running
(even if not included in the backup itself).

Fixes qubesos/qubes-issues#1124
Reported by @doncohen, thanks @wyory for providing more details.
2015-09-04 01:58:53 +02:00
Marek Marczykowski-Górecki
26cf723841
core/hvm: fix external disks handling 2015-08-09 21:21:27 +02:00
Marek Marczykowski-Górecki
46b94b6682
Make qubes-set-updates set also default state for new VMs
This makes possible to also check if the "updates check enabled" state
is consistent across VMs.

Fixes qubesos/qubes-issues#892
2015-08-05 01:04:43 +02:00
Marek Marczykowski-Górecki
8f862cdf69
core/hvm: check if VM serving cdrom content is running 2015-07-25 04:17:59 +02:00
Marek Marczykowski-Górecki
6df309351d
block: fix detection if the block device is attached anywhere 2015-07-13 00:58:11 +02:00
Marek Marczykowski-Górecki
4bf73a5d7f Increase default swiotlb size to 16MB (#1038)
Fixes qubesos/qubes-issues#1038
2015-07-01 04:46:46 +02:00
Marek Marczykowski-Górecki
310ba9f1df block: do not treat disks of not running VMs as used
There are legitimate use cases when one want to attach disk of one VM to
some other. Do not try to detach the disk from powered down VM in such
case.
2015-07-01 04:42:44 +02:00