Skip to content

Commit

Permalink
app: uncouple pool setup from loading initial configuration
Browse files Browse the repository at this point in the history
And ensure that setup is called on every type of these pools, not just
lvm_thin.
  • Loading branch information
rustybird committed Sep 11, 2018
1 parent 8eb9c64 commit 53ef5ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
23 changes: 17 additions & 6 deletions qubes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#

import collections
import copy
import errno
import functools
import grp
Expand Down Expand Up @@ -1064,15 +1065,20 @@ def load_initial_values(self):
}
assert max(self.labels.keys()) == qubes.config.max_default_label

pool_configs = copy.deepcopy(qubes.config.defaults['pool_configs'])

root_volume_group, root_thin_pool = \
qubes.storage.DirectoryThinPool.thin_pool('/')

if root_thin_pool:
self.add_pool(
volume_group=root_volume_group, thin_pool=root_thin_pool,
name='lvm', driver='lvm_thin')
# pool based on /var/lib/qubes will be created here:
for name, config in qubes.config.defaults['pool_configs'].items():
lvm_config = {
'name': 'lvm',
'driver': 'lvm_thin',
'volume_group': root_volume_group,
'thin_pool': root_thin_pool
}
pool_configs[lvm_config['name']] = lvm_config

for name, config in pool_configs.items():
self.pools[name] = self._get_pool(**config)

self.default_pool_kernel = 'linux-kernel'
Expand Down Expand Up @@ -1170,6 +1176,11 @@ def get_label(self, label):

raise KeyError(label)

def setup_pools(self):
""" Run implementation specific setup for each storage pool. """
for pool in self.pools.values():
pool.setup()

def add_pool(self, name, **kwargs):
""" Add a storage pool to config."""

Expand Down
1 change: 1 addition & 0 deletions qubes/tests/api_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def setUp(self):
app = qubes.Qubes('/tmp/qubes-test.xml', load=False)
app.vmm = unittest.mock.Mock(spec=qubes.app.VMMConnection)
app.load_initial_values()
app.setup_pools()
app.default_kernel = '1.0'
app.default_netvm = None
self.template = app.add_new_vm('TemplateVM', label='black',
Expand Down
2 changes: 1 addition & 1 deletion qubes/tools/qubes_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main(args=None):

args = parser.parse_args(args)
qubes.Qubes.create_empty_store(args.app,
offline_mode=args.offline_mode)
offline_mode=args.offline_mode).setup_pools()
return 0


Expand Down

0 comments on commit 53ef5ed

Please sign in to comment.