Commit Graph

101 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
317d140f46
storage/file: major FilePool/FileVolume cleanup and documentation
This driver isn't used in default Qubes 4.0 installation, but if we do
have it, let it follow defined API and its own documentation. And also
explicitly reject not supported operations:
 - support only revisions_to_keep<=1, but do not support revert() anyway
 (implemented version were wrong on so many levels...)
 - use 'save_on_stop'/'snap_on_start' properties directly instead of
 obsolete volume types
 - don't call sudo - qubesd is running as root
 - consistently use path, path_cow, path_source, path_source_cow

Also, add tests for BlockDevice instance returned by
FileVolume.block_device().

QubesOS/qubes-issues#2256
2017-07-04 14:25:07 +02:00
Marek Marczykowski-Górecki
1a1dd3dba2
storage: make default pool configurable
Do not always use pool named 'default'. Instead, have global
`default_pool` property to specify default storage pools.
Additionally add `default_pool_*` properties for each VM property, so
those can be set separately.

QubesOS/qubes-issues#2256
2017-07-04 14:25:06 +02:00
Marek Marczykowski-Górecki
82c3f85042
storage: add API documentation
QubesOS/qubes-issues#2256
2017-07-04 04:11:14 +02:00
Marek Marczykowski-Górecki
5971873680
storage: drop functions not being part of the API
commit/recover/reset should really be handled in start/stop. Nothing
stops specific pool implementation to define such functions privately.

QubesOS/qubes-issues#2256
2017-07-04 04:11:14 +02:00
Marek Marczykowski-Górecki
820539e909
storage: make volume snap_on_start/save_on_stop explicit
Always define those properties, always include them in volume config.
Also simplify overriding pool based on volume type defined by those:
override pool unless snap_on_start=True.

QubesOS/qubes-issues#2256
2017-07-04 04:11:14 +02:00
Marek Marczykowski-Górecki
697eb05c20
storage: drop rename support
Since VM name is immutable, rename method can be dropped from storage
API.

QubesOS/qubes-issues#2868
2017-07-04 04:11:14 +02:00
Marek Marczykowski-Górecki
fabd8119b4
storage: volume.import_volume now expect create()d volume
This is much more logical for *import*_volume function.

QubesOS/qubes-issues#2256
2017-06-26 13:09:26 +02:00
Marek Marczykowski-Górecki
a748b393f4
storage: move remove() to Volume
This is continuation of 0f12870 "storage: use direct object references,
not only identifiers".

QubesOS/qubes-issues#2256
2017-06-26 13:09:26 +02:00
Marek Marczykowski-Górecki
ae600e24bf
storage: simplify pool.volumes usage
Add convenient collection wrapper for easier getting selected volume.
Storage pool implementation may still provide only volume listing
function (pool.list_volumes), or, additionally, optimized
pool.get_volume.

This means it is both possible to iterate over volumes:
```python
for volume in pool.volumes:
    ...

```

And get a single volume:
```python
volume = pool.volumes[vid]
```

QubesOS/qubes-issues#2256
2017-06-26 13:09:26 +02:00
Marek Marczykowski-Górecki
f976f7ec6c
storage: simplify coroutine handling
Suggested by @woju
2017-06-23 02:35:49 +02:00
Marek Marczykowski-Górecki
f48b1be669
storage: extract single volume clone into clone_volume
This will be useful for admin.vm.volume.Clone implementation.

QubesOS/qubes-issues#2256
2017-06-20 00:54:15 +02:00
Marek Marczykowski-Górecki
0f12870803
storage: use direct object references, not only identifiers
Reference objects, not their IDs - this way when object is modified, it
is visible everywhere where it is used. Main changes:
- volume.pool - Pool object
- volume.source - Volume object

Since volume have Pool object reference now, move volume related
functions into Volume class (from Pool class). This avoids horrible
`storage.get_pool(volume).something(volume)` construct.

One issue here is since volume.source reference a Volume object from a
different VM - VM's template, now VM load order is important. Since we
don't have control over it, initialize vm.storage when needed - possibly
while initializing storage of different VM. Since we don't have cycles
in AppVM-TemplateVM dependencies, it is safe.

Also, since this commit, volume.source (if defined) always points at
volume of the same name from VM's template. Using volumes with something
else as a source is no longer supported.

QubesOS/qubes-issues#2256
2017-06-09 04:55:06 +02:00
Marek Marczykowski-Górecki
d7af67d875
storage: minor error handling fix 2017-05-26 15:08:15 +02:00
Marek Marczykowski-Górecki
3cacf290bb
admin: implement admin.vm.volume.Import
Implement this in two parts:
1. Permissions checks, getting a path from appropriate storage pool
2. Actual data import

The first part is done by qubesd in a standard way, but then, instead of
accepting all the data (which may be several GB), return a path to which
a shell script (in practice: `dd` command) will write the data.
Then the script call back to qubesd again to report success/failure and
qubesd response from that call is actually returned to the user.

This way we do not pass all the data through qubesd, but still can
control the process from there in a meaningful way. Note that the last
part (second call to qubesd) may perform all kind of verification (like
a signature check on the data, or so) and can also prevent VM from
starting (hooking also domain-pre-start event) from not verified image.

QubesOS/qubes-issues#2622
2017-05-26 15:08:14 +02:00
Marek Marczykowski-Górecki
46b60dbf42
storage: add Pool.import_data to the API
Allow importing not only from another volume, but also raw data. In
practice, for all currently implemented storage pools, this is the same
as Pool.export, because path returned there is read-write. But lets not
abuse this fact, some future implementation may need different methods.

QubesOS/qubes-issues#2622
QubesOS/qubes-issues#2256
2017-05-23 15:35:55 +02:00
Marek Marczykowski-Górecki
595d983659
storage: make verify() asyncio aware 2017-05-17 11:17:21 +02:00
Marek Marczykowski-Górecki
b91b89a341
Make pylint ♥ 2017-05-12 17:41:38 +02:00
Marek Marczykowski-Górecki
68d5ca93e1
storage: have QubesVM() handle vm.dir_path, also on clone and rename
Keep it uniform - QubesVM() object is responsible for handling
vm.dir_path, Storage() is responsible for handling disk volumes (which
may live in that directory

QubesOS/qubes-issues#2256
2017-05-12 17:04:18 +02:00
Marek Marczykowski-Górecki
52c3753d61
storage: support asynchronous storage pool implementations
Allow specific pool implementation to provide asynchronous
implementation. vm.storage.* methods will detect if given implementation
is synchronous or asynchronous and will act accordingly.
Then it's up to pool implementation how asynchronous should be achieved.
Do not force it using threads (`run_in_executor()`). But pool
implementation is free to use threads, if consider it safe in a
particular case.

This commit does not touch any pool implementation - all of them are
still synchronous.

QubesOS/qubes-issues#2256
2017-05-12 17:04:18 +02:00
Marek Marczykowski-Górecki
f324d30d4e
quebs: make Label() and storage.Pool() objects hashable 2017-05-12 14:27:47 +02:00
Bahtiar `kalkin-` Gadimov
5bc7a8f9e3
Fix pylint warning no-else-return 2017-04-15 23:49:41 +02:00
Bahtiar `kalkin-` Gadimov
e446e7a2f4
Rename qubes.devices.BlockDevice to qubes.storage.BlockDevice
Signed-off-by: Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
2017-04-15 23:49:36 +02:00
Marek Marczykowski-Górecki
fb7bd6823a
mgmt: implement storage-related methods
QubesOS/qubes-issues#2622
2017-03-16 20:04:01 +01:00
Marek Marczykowski-Górecki
570cbe5225
qubes: py3k related fixes 2017-02-27 02:37:45 +01:00
Wojtek Porczyk
1be75d9c83 misc python3 fixes 2017-02-07 17:07:52 +01:00
Wojtek Porczyk
d74567d65f qubes: port core to python3
fixes QubesOS/qubes-issues#2074
2017-01-20 16:42:51 +01:00
Marek Marczykowski-Górecki
ab9d7fbb76
storage: improve/fix handling extra volumes
Just calling pool.init_volume isn't enough - a lot of code depends on
additional data loaded into vm.storage object. Provide a convenient
wrapper for this.

At the same time, fix loading extra volumes from qubes.xml - don't fail
on volume not mentioned in initial vm.volume_config.

QubesOS/qubes-issues#2256
2016-11-04 14:18:56 +01:00
Marek Marczykowski-Górecki
ae42308f5f
storage: improve handling volume export
1. Add a helper function on vm.storage. This is equivalent of:

    vm.storage.get_pool(vm.volumes[name]).export(vm.volumes[name])

2. Make sure the path returned by `export` on LVM volume is accessible.
2016-09-29 01:59:54 +02:00
Marek Marczykowski-Górecki
1af1784c69
Merge remote-tracking branch 'qubesos/pr/54' into core3-devel
* qubesos/pr/54:
  Fix file storage resize
  Fix lvm reset_cache size cache
2016-09-19 20:36:20 +02:00
Bahtiar `kalkin-` Gadimov
d63d93b0ab
Fix file storage resize 2016-09-05 16:56:57 +02:00
Marek Marczykowski-Górecki
2285789b49
Merge remote-tracking branch 'qubesos/pr/54' into core3-devel
* qubesos/pr/54:
  Volume add size property wrapper
2016-09-04 22:38:06 +02:00
Bahtiar `kalkin-` Gadimov
b863152f73
Volume add size property wrapper 2016-09-04 21:55:56 +02:00
Marek Marczykowski-Górecki
70d3f58024
qubes/storage: misc fixes for VM-exposed block devices handling
Add 'backenddomain' element when source (not target) domain is not dom0.
Fix XML elemenet name. Actually set volume.domain when listing
VM-exposed devices.

QubesOS/qubes-issues#2256
2016-09-03 20:41:02 +02:00
Marek Marczykowski-Górecki
06f46243ec
qubes/storage: add resize to Pool API
It was already implemented by FilePool and used by Storage object, but
wasn't included in base class.
2016-08-18 11:42:00 +02:00
Marek Marczykowski-Górecki
42d6fddcd3
qubes/storage: support on-line resize
Call `qubes.ResizeDisk` qrexec service after resizing volume, to adjust
filesystem size there.
2016-08-18 11:40:38 +02:00
Marek Marczykowski-Górecki
6e383c703d
qubes/storage: allow passing just volume name to storage.resize
It makes much more sense to call:

    vm.storage.resize('private', 10000000000)

instead of:

    vm.storage.resize(vm.volumes['private'], 10000000000)
2016-08-17 22:42:15 +02:00
Marek Marczykowski-Górecki
6490767278
qubes/storage: update vm.storage.commit
Better name it 'commit', as it isn't only for template. And also fix to
call `pool.commit`
2016-08-09 05:14:11 +02:00
Bahtiar `kalkin-` Gadimov
9d30bb132a
Fix umask 2016-08-03 02:57:44 +02:00
Bahtiar `kalkin-` Gadimov
1467f1ede5
Storage add clone support 2016-07-13 22:35:57 +02:00
Bahtiar `kalkin-` Gadimov
7e1563c88d
Add handling for old volume config 2016-07-13 22:34:31 +02:00
Bahtiar `kalkin-` Gadimov
1bccb146d8
Add qubes.storage.isodate() helper function 2016-07-13 22:34:31 +02:00
Bahtiar `kalkin-` Gadimov
7841e3f6c0
qubes.storage rework api 2016-07-13 22:34:30 +02:00
Wojtek Porczyk
1ff1ca37a1 Merge remote-tracking branch 'woju/pull/21/head' into core3-devel
Conflicts:
	qubes/storage/__init__.py
2016-07-02 11:54:56 +02:00
Wojtek Porczyk
c9accc258c Merge remote-tracking branch 'woju/pull/15/head' into core3-devel
Conflicts:
	qubes/storage/__init__.py
	qubes/storage/file.py
	qubes/vm/qubesvm.py
2016-06-28 15:15:00 +02:00
Bahtiar `kalkin-` Gadimov
8fc3772017
Add Volume.__str__() 2016-06-23 13:16:59 +02:00
Bahtiar `kalkin-` Gadimov
3dd77719c1
Pool.create source_volume argument is optional 2016-06-23 13:16:59 +02:00
Bahtiar `kalkin-` Gadimov
b9ddc00741
Add qvm-block 2016-06-23 13:16:08 +02:00
Bahtiar `kalkin-` Gadimov
90c882610e
Storage attach volumes from other pools
- Already attached volumes are ignored
2016-06-23 13:16:07 +02:00
Bahtiar `kalkin-` Gadimov
0ac40ddd4f
Volume.__repr__ returns POOL_NAME:VOLUME_ID 2016-06-23 13:16:04 +02:00
Bahtiar `kalkin-` Gadimov
09727b1cbd
Add Volume.internal field
- Linux kernel volumes are always internal volumes
2016-06-23 13:16:03 +02:00