vm/dispvm: place all volumes in the same pool as DispVM's template
Make all volume's pool controlled by DisposableVM Template. This specifically makes DispVM's volatile volume to be placed directly in the same pool as its template. Fixes QubesOS/qubes-issues#5933
Esse commit está contido em:
pai
410a0728cc
commit
8b760451a6
@ -168,3 +168,28 @@ class TC_00_DispVM(qubes.tests.QubesTestCase):
|
|||||||
self.app.add_new_vm(qubes.vm.dispvm.DispVM,
|
self.app.add_new_vm(qubes.vm.dispvm.DispVM,
|
||||||
name='test-dispvm', template=self.appvm)
|
name='test-dispvm', template=self.appvm)
|
||||||
self.assertFalse(mock_domains.get_new_unused_dispid.called)
|
self.assertFalse(mock_domains.get_new_unused_dispid.called)
|
||||||
|
|
||||||
|
@mock.patch('os.symlink')
|
||||||
|
@mock.patch('os.makedirs')
|
||||||
|
def test_020_copy_storage_pool(self, mock_makedirs, mock_symlink):
|
||||||
|
self.app.pools['alternative'] = qubes.tests.vm.appvm.TestPool(name='alternative')
|
||||||
|
self.appvm.template_for_dispvms = True
|
||||||
|
self.loop.run_until_complete(self.template.create_on_disk())
|
||||||
|
self.loop.run_until_complete(self.appvm.create_on_disk(pool='alternative'))
|
||||||
|
orig_getitem = self.app.domains.__getitem__
|
||||||
|
with mock.patch.object(self.app, 'domains', wraps=self.app.domains) \
|
||||||
|
as mock_domains:
|
||||||
|
mock_domains.configure_mock(**{
|
||||||
|
'get_new_unused_dispid': mock.Mock(return_value=42),
|
||||||
|
'__getitem__.side_effect': orig_getitem
|
||||||
|
})
|
||||||
|
dispvm = self.app.add_new_vm(qubes.vm.dispvm.DispVM,
|
||||||
|
name='test-dispvm', template=self.appvm)
|
||||||
|
self.loop.run_until_complete(dispvm.create_on_disk())
|
||||||
|
self.assertEqual(dispvm.template, self.appvm)
|
||||||
|
self.assertEqual(dispvm.volumes['private'].pool,
|
||||||
|
self.appvm.volumes['private'].pool)
|
||||||
|
self.assertEqual(dispvm.volumes['root'].pool,
|
||||||
|
self.appvm.volumes['root'].pool)
|
||||||
|
self.assertEqual(dispvm.volumes['volatile'].pool,
|
||||||
|
self.appvm.volumes['volatile'].pool)
|
||||||
|
|||||||
@ -109,6 +109,12 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
self.volume_config[name] = config.copy()
|
self.volume_config[name] = config.copy()
|
||||||
if 'vid' in self.volume_config[name]:
|
if 'vid' in self.volume_config[name]:
|
||||||
del self.volume_config[name]['vid']
|
del self.volume_config[name]['vid']
|
||||||
|
# copy pool setting from base AppVM; root and private would be
|
||||||
|
# in the same pool anyway (because of snap_on_start),
|
||||||
|
# but not volatile, which could be surprising
|
||||||
|
elif 'pool' not in self.volume_config[name] \
|
||||||
|
and 'pool' in config:
|
||||||
|
self.volume_config[name]['pool'] = config['pool']
|
||||||
|
|
||||||
super(DispVM, self).__init__(app, xml, *args, **kwargs)
|
super(DispVM, self).__init__(app, xml, *args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Carregando…
Referência em uma nova issue
Block a user