2016-11-04 13:30:51 +01:00
|
|
|
#
|
|
|
|
# The Qubes OS Project, http://www.qubes-os.org
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016 Marek Marczykowski-Górecki
|
|
|
|
# <marmarek@invisiblethingslab.com>
|
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2016-11-04 13:30:51 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is distributed in the hope that it will be useful,
|
2016-11-04 13:30:51 +01:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-10-12 00:11:50 +02:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
2016-11-04 13:30:51 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
2017-01-18 22:16:46 +01:00
|
|
|
#
|
|
|
|
|
2017-04-18 10:16:14 +02:00
|
|
|
import asyncio
|
2016-11-04 13:30:51 +01:00
|
|
|
import os
|
|
|
|
import shutil
|
2017-07-25 05:44:10 +02:00
|
|
|
import subprocess
|
2019-02-19 00:52:39 +01:00
|
|
|
from contextlib import suppress
|
2016-11-04 13:30:51 +01:00
|
|
|
|
|
|
|
import qubes.storage.lvm
|
|
|
|
import qubes.tests
|
|
|
|
import qubes.tests.storage_lvm
|
2018-09-12 01:50:31 +02:00
|
|
|
import qubes.tests.storage_reflink
|
2019-06-28 12:29:24 +02:00
|
|
|
import qubes.utils
|
2016-11-04 13:30:51 +01:00
|
|
|
import qubes.vm.appvm
|
|
|
|
|
|
|
|
|
2017-07-12 19:01:15 +02:00
|
|
|
class StorageTestMixin(object):
|
2016-11-04 13:30:51 +01:00
|
|
|
def setUp(self):
|
|
|
|
super(StorageTestMixin, self).setUp()
|
|
|
|
self.init_default_template()
|
2019-02-19 00:52:39 +01:00
|
|
|
self.old_default_pool = self.app.default_pool
|
2016-11-04 13:30:51 +01:00
|
|
|
self.vm1 = self.app.add_new_vm(qubes.vm.appvm.AppVM,
|
|
|
|
name=self.make_vm_name('vm1'),
|
|
|
|
label='red')
|
2017-07-25 05:44:10 +02:00
|
|
|
self.loop.run_until_complete(self.vm1.create_on_disk())
|
2016-11-04 13:30:51 +01:00
|
|
|
self.vm2 = self.app.add_new_vm(qubes.vm.appvm.AppVM,
|
|
|
|
name=self.make_vm_name('vm2'),
|
|
|
|
label='red')
|
2017-07-25 05:44:10 +02:00
|
|
|
self.loop.run_until_complete(self.vm2.create_on_disk())
|
2016-11-04 13:30:51 +01:00
|
|
|
self.pool = None
|
|
|
|
self.init_pool()
|
|
|
|
self.app.save()
|
|
|
|
|
2017-09-28 03:03:30 +02:00
|
|
|
def tearDown(self):
|
2019-02-19 00:52:39 +01:00
|
|
|
with suppress(qubes.exc.QubesException):
|
|
|
|
self.loop.run_until_complete(self.vm1.kill())
|
|
|
|
with suppress(qubes.exc.QubesException):
|
|
|
|
self.loop.run_until_complete(self.vm2.kill())
|
|
|
|
del self.app.domains[self.vm1]
|
|
|
|
del self.app.domains[self.vm2]
|
2017-09-28 03:03:30 +02:00
|
|
|
del self.vm1
|
|
|
|
del self.vm2
|
2019-02-19 00:52:39 +01:00
|
|
|
self.app.default_pool = self.old_default_pool
|
|
|
|
self.cleanup_pool()
|
2017-09-28 03:03:30 +02:00
|
|
|
del self.pool
|
|
|
|
super(StorageTestMixin, self).tearDown()
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
def init_pool(self):
|
|
|
|
''' Initialize storage pool to be tested, store it in self.pool'''
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2019-02-19 00:52:39 +01:00
|
|
|
def cleanup_pool(self):
|
|
|
|
''' Remove tested storage pool'''
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
def test_000_volatile(self):
|
|
|
|
'''Test if volatile volume is really volatile'''
|
2017-04-18 10:16:14 +02:00
|
|
|
return self.loop.run_until_complete(self._test_000_volatile())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_000_volatile(self):
|
2016-11-04 13:30:51 +01:00
|
|
|
size = 32*1024*1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'save_on_stop': False,
|
|
|
|
'rw': True,
|
|
|
|
}
|
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol
|
2016-11-04 13:30:51 +01:00
|
|
|
self.app.save()
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from (self.vm1.start())
|
2018-10-27 01:41:30 +02:00
|
|
|
yield from self.wait_for_session(self.vm1)
|
2017-04-18 10:16:14 +02:00
|
|
|
|
|
|
|
# volatile image not clean
|
|
|
|
yield from (self.vm1.run_for_stdio(
|
2016-11-04 13:30:51 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root'))
|
|
|
|
# volatile image not volatile
|
|
|
|
yield from (
|
|
|
|
self.vm1.run_for_stdio('echo test123 > /dev/xvde', user='root'))
|
|
|
|
yield from (self.vm1.shutdown(wait=True))
|
|
|
|
yield from (self.vm1.start())
|
|
|
|
yield from (self.vm1.run_for_stdio(
|
2016-11-04 13:30:51 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root'))
|
2016-11-04 13:30:51 +01:00
|
|
|
|
|
|
|
def test_001_non_volatile(self):
|
|
|
|
'''Test if non-volatile volume is really non-volatile'''
|
2017-04-18 10:16:14 +02:00
|
|
|
return self.loop.run_until_complete(self._test_001_non_volatile())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_001_non_volatile(self):
|
2016-11-04 13:30:51 +01:00
|
|
|
size = 32*1024*1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'save_on_stop': True,
|
|
|
|
'rw': True,
|
|
|
|
}
|
2017-07-25 05:44:10 +02:00
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol
|
2016-11-04 13:30:51 +01:00
|
|
|
self.app.save()
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from self.vm1.start()
|
2018-10-27 01:41:30 +02:00
|
|
|
yield from self.wait_for_session(self.vm1)
|
2017-04-18 10:16:14 +02:00
|
|
|
# non-volatile image not clean
|
|
|
|
yield from self.vm1.run_for_stdio(
|
2016-11-04 13:30:51 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root')
|
|
|
|
|
|
|
|
yield from self.vm1.run_for_stdio('echo test123 > /dev/xvde',
|
|
|
|
user='root')
|
|
|
|
yield from self.vm1.shutdown(wait=True)
|
|
|
|
yield from self.vm1.start()
|
|
|
|
# non-volatile image volatile
|
2017-06-01 00:33:53 +02:00
|
|
|
with self.assertRaises(subprocess.CalledProcessError):
|
|
|
|
yield from self.vm1.run_for_stdio(
|
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(
|
|
|
|
size),
|
|
|
|
user='root')
|
2016-11-04 13:30:51 +01:00
|
|
|
|
|
|
|
def test_002_read_only(self):
|
|
|
|
'''Test read-only volume'''
|
2017-04-18 10:16:14 +02:00
|
|
|
self.loop.run_until_complete(self._test_002_read_only())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_002_read_only(self):
|
2016-11-04 13:30:51 +01:00
|
|
|
size = 32 * 1024 * 1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
2017-02-21 00:49:00 +01:00
|
|
|
'save_on_stop': False,
|
2016-11-04 13:30:51 +01:00
|
|
|
'rw': False,
|
|
|
|
}
|
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol
|
2016-11-04 13:30:51 +01:00
|
|
|
self.app.save()
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from self.vm1.start()
|
|
|
|
# non-volatile image not clean
|
|
|
|
yield from self.vm1.run_for_stdio(
|
2016-11-04 13:30:51 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root')
|
|
|
|
# Write to read-only volume unexpectedly succeeded
|
|
|
|
with self.assertRaises(subprocess.CalledProcessError):
|
|
|
|
yield from self.vm1.run_for_stdio('echo test123 > /dev/xvde',
|
|
|
|
user='root')
|
|
|
|
# read-only volume modified
|
|
|
|
yield from self.vm1.run_for_stdio(
|
2016-11-04 13:30:51 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root')
|
2016-11-04 13:30:51 +01:00
|
|
|
|
|
|
|
def test_003_snapshot(self):
|
|
|
|
'''Test snapshot volume data propagation'''
|
2017-04-18 10:16:14 +02:00
|
|
|
self.loop.run_until_complete(self._test_003_snapshot())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_003_snapshot(self):
|
2016-11-04 13:30:51 +01:00
|
|
|
size = 128 * 1024 * 1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'save_on_stop': True,
|
|
|
|
'rw': True,
|
|
|
|
}
|
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
2016-11-04 13:30:51 +01:00
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'snap_on_start': True,
|
|
|
|
'source': testvol.vid,
|
|
|
|
'rw': True,
|
|
|
|
}
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol
|
2016-11-04 13:30:51 +01:00
|
|
|
testvol_snap = self.vm2.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol_snap.create())
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol_snap
|
2016-11-04 13:30:51 +01:00
|
|
|
self.app.save()
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from self.vm1.start()
|
|
|
|
yield from self.vm2.start()
|
2018-10-27 01:41:30 +02:00
|
|
|
yield from asyncio.wait(
|
|
|
|
[self.wait_for_session(self.vm1), self.wait_for_session(self.vm2)])
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
|
2017-07-25 05:44:10 +02:00
|
|
|
try:
|
|
|
|
yield from self.vm1.run_for_stdio(
|
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.
|
|
|
|
format(size),
|
|
|
|
user='root')
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
self.fail('origin image not clean')
|
2017-04-18 10:16:14 +02:00
|
|
|
|
2017-07-25 05:44:10 +02:00
|
|
|
try:
|
|
|
|
yield from self.vm2.run_for_stdio(
|
|
|
|
'head -c {} /dev/zero | diff -q /dev/xvde -'.format(size),
|
|
|
|
user='root')
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
self.fail('snapshot image not clean')
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield from self.vm1.run_for_stdio(
|
|
|
|
'echo test123 > /dev/xvde && sync',
|
|
|
|
user='root')
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
self.fail('Write to read-write volume failed')
|
|
|
|
try:
|
|
|
|
yield from self.vm2.run_for_stdio(
|
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.
|
|
|
|
format(size),
|
|
|
|
user='root')
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
self.fail('origin changes propagated to snapshot too early')
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from self.vm1.shutdown(wait=True)
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
# after origin shutdown there should be still no change
|
2017-04-18 10:16:14 +02:00
|
|
|
|
2017-07-25 05:44:10 +02:00
|
|
|
try:
|
|
|
|
yield from self.vm2.run_for_stdio(
|
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.
|
|
|
|
format(size),
|
|
|
|
user='root')
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
self.fail('origin changes propagated to snapshot too early2')
|
2017-04-18 10:16:14 +02:00
|
|
|
|
|
|
|
yield from self.vm2.shutdown(wait=True)
|
|
|
|
yield from self.vm2.start()
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
# only after target VM restart changes should be visible
|
2017-04-18 10:16:14 +02:00
|
|
|
|
2017-07-25 05:44:10 +02:00
|
|
|
with self.assertRaises(subprocess.CalledProcessError,
|
|
|
|
msg='origin changes not visible in snapshot'):
|
|
|
|
yield from self.vm2.run_for_stdio(
|
2017-04-18 10:16:14 +02:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(
|
|
|
|
size),
|
|
|
|
user='root')
|
2016-11-04 13:30:51 +01:00
|
|
|
|
2016-11-30 23:35:44 +01:00
|
|
|
def test_004_snapshot_non_persistent(self):
|
|
|
|
'''Test snapshot volume non-persistence'''
|
2017-04-18 10:16:14 +02:00
|
|
|
return self.loop.run_until_complete(
|
|
|
|
self._test_004_snapshot_non_persistent())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_004_snapshot_non_persistent(self):
|
2016-11-30 23:35:44 +01:00
|
|
|
size = 128 * 1024 * 1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'save_on_stop': True,
|
|
|
|
'rw': True,
|
|
|
|
}
|
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
2016-11-30 23:35:44 +01:00
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'snap_on_start': True,
|
|
|
|
'source': testvol.vid,
|
|
|
|
'rw': True,
|
|
|
|
}
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol
|
2016-11-30 23:35:44 +01:00
|
|
|
testvol_snap = self.vm2.storage.init_volume('testvol', volume_config)
|
2019-06-28 12:29:24 +02:00
|
|
|
yield from qubes.utils.coro_maybe(testvol_snap.create())
|
2017-09-28 03:03:30 +02:00
|
|
|
del testvol_snap
|
2016-11-30 23:35:44 +01:00
|
|
|
self.app.save()
|
2017-04-18 10:16:14 +02:00
|
|
|
yield from self.vm2.start()
|
2018-10-27 01:41:30 +02:00
|
|
|
yield from self.wait_for_session(self.vm2)
|
2016-11-30 23:35:44 +01:00
|
|
|
|
2017-04-18 10:16:14 +02:00
|
|
|
# snapshot image not clean
|
|
|
|
yield from self.vm2.run_for_stdio(
|
2016-11-30 23:35:44 +01:00
|
|
|
'head -c {} /dev/zero | diff -q /dev/xvde -'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root')
|
|
|
|
|
|
|
|
# Write to read-write snapshot volume failed
|
|
|
|
yield from self.vm2.run_for_stdio('echo test123 > /dev/xvde && sync',
|
|
|
|
user='root')
|
|
|
|
yield from self.vm2.shutdown(wait=True)
|
|
|
|
yield from self.vm2.start()
|
|
|
|
|
|
|
|
# changes on snapshot survived VM restart
|
|
|
|
yield from self.vm2.run_for_stdio(
|
2016-11-30 23:35:44 +01:00
|
|
|
'head -c {} /dev/zero 2>&1 | diff -q /dev/xvde - 2>&1'.format(size),
|
2017-04-18 10:16:14 +02:00
|
|
|
user='root')
|
2016-11-30 23:35:44 +01:00
|
|
|
|
2019-10-31 01:17:26 +01:00
|
|
|
def test_005_size_after_clone(self):
|
|
|
|
'''Test snapshot volume non-persistence'''
|
|
|
|
return self.loop.run_until_complete(
|
|
|
|
self._test_005_size_after_clone())
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def _test_005_size_after_clone(self):
|
|
|
|
size = 128 * 1024 * 1024
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size,
|
|
|
|
'save_on_stop': True,
|
|
|
|
'rw': True,
|
|
|
|
}
|
|
|
|
testvol = self.vm1.storage.init_volume('testvol', volume_config)
|
|
|
|
yield from qubes.utils.coro_maybe(testvol.create())
|
|
|
|
self.assertEquals(testvol.size, size)
|
|
|
|
volume_config = {
|
|
|
|
'pool': self.pool.name,
|
|
|
|
'size': size // 2,
|
|
|
|
'save_on_stop': True,
|
|
|
|
'rw': True,
|
|
|
|
}
|
|
|
|
testvol2 = self.vm2.storage.init_volume('testvol2', volume_config)
|
|
|
|
yield from qubes.utils.coro_maybe(testvol2.create())
|
|
|
|
self.assertEquals(testvol2.size, size // 2)
|
|
|
|
yield from qubes.utils.coro_maybe(testvol2.import_volume(testvol))
|
|
|
|
self.assertEquals(testvol2.size, size)
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
|
2017-07-12 19:01:15 +02:00
|
|
|
class StorageFile(StorageTestMixin, qubes.tests.SystemTestCase):
|
2016-11-04 13:30:51 +01:00
|
|
|
def init_pool(self):
|
|
|
|
self.dir_path = '/var/tmp/test-pool'
|
2019-02-18 21:13:24 +01:00
|
|
|
self.pool = self.loop.run_until_complete(
|
|
|
|
self.app.add_pool(dir_path=self.dir_path,
|
|
|
|
name='test-pool', driver='file'))
|
2017-09-28 02:47:46 +02:00
|
|
|
os.makedirs(os.path.join(self.dir_path, 'appvms', self.vm1.name),
|
|
|
|
exist_ok=True)
|
|
|
|
os.makedirs(os.path.join(self.dir_path, 'appvms', self.vm2.name),
|
|
|
|
exist_ok=True)
|
2016-11-04 13:30:51 +01:00
|
|
|
|
2019-02-19 00:52:39 +01:00
|
|
|
def cleanup_pool(self):
|
2019-02-18 21:13:24 +01:00
|
|
|
self.loop.run_until_complete(self.app.remove_pool('test-pool'))
|
2016-11-04 13:30:51 +01:00
|
|
|
shutil.rmtree(self.dir_path)
|
|
|
|
|
|
|
|
|
2018-09-12 01:50:31 +02:00
|
|
|
class StorageReflinkMixin(StorageTestMixin):
|
2019-02-19 00:52:39 +01:00
|
|
|
def cleanup_pool(self):
|
2019-02-18 21:13:24 +01:00
|
|
|
self.loop.run_until_complete(self.app.remove_pool(self.pool.name))
|
2018-09-12 01:50:31 +02:00
|
|
|
|
|
|
|
def init_pool(self, fs_type, **kwargs):
|
|
|
|
name = 'test-reflink-integration-on-' + fs_type
|
|
|
|
dir_path = os.path.join('/var/tmp', name)
|
|
|
|
qubes.tests.storage_reflink.mkdir_fs(dir_path, fs_type,
|
|
|
|
cleanup_via=self.addCleanup)
|
2019-02-18 21:13:24 +01:00
|
|
|
self.pool = self.loop.run_until_complete(
|
|
|
|
self.app.add_pool(name=name, dir_path=dir_path,
|
|
|
|
driver='file-reflink', **kwargs))
|
2018-09-12 01:50:31 +02:00
|
|
|
|
|
|
|
class StorageReflinkOnBtrfs(StorageReflinkMixin, qubes.tests.SystemTestCase):
|
|
|
|
def init_pool(self):
|
|
|
|
super().init_pool('btrfs')
|
|
|
|
|
|
|
|
class StorageReflinkOnExt4(StorageReflinkMixin, qubes.tests.SystemTestCase):
|
|
|
|
def init_pool(self):
|
2020-06-22 16:03:19 +02:00
|
|
|
super().init_pool('ext4', setup_check=False)
|
2018-09-12 01:50:31 +02:00
|
|
|
|
|
|
|
|
2016-11-04 13:30:51 +01:00
|
|
|
@qubes.tests.storage_lvm.skipUnlessLvmPoolExists
|
2017-07-12 19:01:15 +02:00
|
|
|
class StorageLVM(StorageTestMixin, qubes.tests.SystemTestCase):
|
2016-11-04 13:30:51 +01:00
|
|
|
def init_pool(self):
|
2019-02-19 00:52:39 +01:00
|
|
|
self.created_pool = False
|
2016-11-04 13:30:51 +01:00
|
|
|
# check if the default LVM Thin pool qubes_dom0/pool00 exists
|
|
|
|
volume_group, thin_pool = \
|
|
|
|
qubes.tests.storage_lvm.DEFAULT_LVM_POOL.split('/', 1)
|
|
|
|
self.pool = self._find_pool(volume_group, thin_pool)
|
|
|
|
if not self.pool:
|
2019-02-18 21:13:24 +01:00
|
|
|
self.pool = self.loop.run_until_complete(
|
|
|
|
self.app.add_pool(**qubes.tests.storage_lvm.POOL_CONF))
|
2016-11-04 13:30:51 +01:00
|
|
|
self.created_pool = True
|
|
|
|
|
2019-02-19 00:52:39 +01:00
|
|
|
def cleanup_pool(self):
|
2016-11-04 13:30:51 +01:00
|
|
|
''' Remove the default lvm pool if it was created only for this test '''
|
|
|
|
if self.created_pool:
|
2019-02-18 21:13:24 +01:00
|
|
|
self.loop.run_until_complete(self.app.remove_pool(self.pool.name))
|
2016-11-04 13:30:51 +01:00
|
|
|
|
|
|
|
def _find_pool(self, volume_group, thin_pool):
|
|
|
|
''' Returns the pool matching the specified ``volume_group`` &
|
|
|
|
``thin_pool``, or None.
|
|
|
|
'''
|
|
|
|
pools = [p for p in self.app.pools
|
|
|
|
if issubclass(p.__class__, qubes.storage.lvm.ThinPool)]
|
|
|
|
for pool in pools:
|
|
|
|
if pool.volume_group == volume_group \
|
|
|
|
and pool.thin_pool == thin_pool:
|
|
|
|
return pool
|
|
|
|
return None
|