app: uncouple pool setup from loading initial configuration

And ensure that setup is called on every type of these pools, not just
lvm_thin.
This commit is contained in:
Rusty Bird 2018-09-11 23:50:25 +00:00
parent 8eb9c64f20
commit 53ef5ed431
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF
3 changed files with 19 additions and 7 deletions

View File

@ -21,6 +21,7 @@
#
import collections
import copy
import errno
import functools
import grp
@ -1064,15 +1065,20 @@ class Qubes(qubes.PropertyHolder):
}
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'
@ -1170,6 +1176,11 @@ class Qubes(qubes.PropertyHolder):
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."""

View File

@ -60,6 +60,7 @@ class AdminAPITestCase(qubes.tests.QubesTestCase):
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',

View File

@ -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