From 0e554296e37f7bf0519975f6bd2ab9b4906ff748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 2 Jul 2017 01:07:48 +0200 Subject: [PATCH] storage: drop 'internal' and 'removable' volume properties Since dynamic volumes (qvm-block) are moved to devices API, those two are not needed anymore. QubesOS/qubes-issues#2256 --- qubes/api/admin.py | 2 +- qubes/storage/__init__.py | 13 ++++--------- qubes/storage/kernels.py | 1 - qubes/tests/api_admin.py | 2 +- qubes/tests/integ/storage.py | 7 ------- qubes/vm/appvm.py | 4 ---- qubes/vm/dispvm.py | 4 ---- qubes/vm/qubesvm.py | 6 +++--- qubes/vm/standalonevm.py | 4 ---- qubes/vm/templatevm.py | 4 ---- 10 files changed, 9 insertions(+), 38 deletions(-) diff --git a/qubes/api/admin.py b/qubes/api/admin.py index 5a72c1e2..de5b8ccb 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -261,7 +261,7 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI): volume = self.dest.volumes[self.arg] # properties defined in API volume_properties = [ - 'pool', 'vid', 'size', 'usage', 'rw', 'internal', 'source', + 'pool', 'vid', 'size', 'usage', 'rw', 'source', 'save_on_stop', 'snap_on_start'] return ''.join('{}={}\n'.format(key, getattr(volume, key)) for key in volume_properties) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index ff135af2..63ce351b 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -82,7 +82,7 @@ class Volume(object): #: for sparse volumes usage = 0 - def __init__(self, name, pool, vid, internal=False, removable=False, + def __init__(self, name, pool, vid, revisions_to_keep=0, rw=False, save_on_stop=False, size=0, snap_on_start=False, source=None, **kwargs): ''' Initialize a volume. @@ -90,10 +90,6 @@ class Volume(object): :param str name: The name of the volume inside owning domain :param Pool pool: The pool object :param str vid: Volume identifier needs to be unique in pool - :param bool internal: If `True` volume is hidden when qvm-block ls - is used - :param bool removable: If `True` volume can be detached from vm at - run time :param int revisions_to_keep: Amount of revisions to keep around :param bool rw: If true volume will be mounted read-write :param bool snap_on_start: Create a snapshot from source on @@ -125,8 +121,6 @@ class Volume(object): self.name = str(name) #: :py:class:`Pool` instance owning this volume self.pool = pool - self.internal = internal - self.removable = removable #: How many revisions of the volume to keep. Each revision is created # at :py:meth:`stop`, if :py:attr:`save_on_stop` is True self.revisions_to_keep = int(revisions_to_keep) @@ -317,8 +311,6 @@ class Volume(object): 'name': self.name, 'pool': str(self.pool), 'vid': self.vid, - 'internal': self.internal, - 'removable': self.removable, 'revisions_to_keep': self.revisions_to_keep, 'rw': self.rw, 'save_on_stop': self.save_on_stop, @@ -382,6 +374,9 @@ class Storage(object): pool = getattr(self.vm.app, 'default_pool_' + name) else: pool = self.vm.app.get_pool(volume_config['pool']) + if 'internal' in volume_config: + # migrate old config + del volume_config['internal'] volume = pool.init_volume(self.vm, volume_config) self.vm.volumes[name] = volume return volume diff --git a/qubes/storage/kernels.py b/qubes/storage/kernels.py index 60d304eb..1baf7c78 100644 --- a/qubes/storage/kernels.py +++ b/qubes/storage/kernels.py @@ -167,7 +167,6 @@ class LinuxKernel(Pool): kernel_version, pool=self, name=kernel_version, - internal=True, rw=False ) for kernel_version in os.listdir(self.dir_path)] diff --git a/qubes/tests/api_admin.py b/qubes/tests/api_admin.py index 8b6eadcf..6216d98a 100644 --- a/qubes/tests/api_admin.py +++ b/qubes/tests/api_admin.py @@ -37,7 +37,7 @@ import qubes.storage # properties defined in API volume_properties = [ - 'pool', 'vid', 'size', 'usage', 'rw', 'internal', 'source', + 'pool', 'vid', 'size', 'usage', 'rw', 'source', 'save_on_stop', 'snap_on_start'] diff --git a/qubes/tests/integ/storage.py b/qubes/tests/integ/storage.py index 8f93d9da..401ef08e 100644 --- a/qubes/tests/integ/storage.py +++ b/qubes/tests/integ/storage.py @@ -59,7 +59,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'save_on_stop': False, 'rw': True, } @@ -91,7 +90,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'save_on_stop': True, 'rw': True, } @@ -126,7 +124,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'save_on_stop': False, 'rw': False, } @@ -157,7 +154,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'save_on_stop': True, 'rw': True, } @@ -166,7 +162,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'snap_on_start': True, 'source': testvol.vid, 'rw': True, @@ -225,7 +220,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'save_on_stop': True, 'rw': True, } @@ -234,7 +228,6 @@ class StorageTestMixin(qubes.tests.SystemTestsMixin): volume_config = { 'pool': self.pool.name, 'size': size, - 'internal': False, 'snap_on_start': True, 'source': testvol.vid, 'rw': True, diff --git a/qubes/vm/appvm.py b/qubes/vm/appvm.py index b818c995..8d22e5db 100644 --- a/qubes/vm/appvm.py +++ b/qubes/vm/appvm.py @@ -49,7 +49,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM): 'save_on_stop': False, 'rw': False, 'source': None, - 'internal': True }, 'private': { 'name': 'private', @@ -58,7 +57,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM): 'save_on_stop': True, 'rw': True, 'size': defaults['private_img_size'], - 'internal': True }, 'volatile': { 'name': 'volatile', @@ -66,7 +64,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM): 'snap_on_start': False, 'save_on_stop': False, 'size': defaults['root_img_size'], - 'internal': True, 'rw': True, }, 'kernel': { @@ -75,7 +72,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM): 'snap_on_start': False, 'save_on_stop': False, 'rw': False, - 'internal': True } } diff --git a/qubes/vm/dispvm.py b/qubes/vm/dispvm.py index 8586627b..97d67d49 100644 --- a/qubes/vm/dispvm.py +++ b/qubes/vm/dispvm.py @@ -47,20 +47,17 @@ class DispVM(qubes.vm.qubesvm.QubesVM): 'snap_on_start': True, 'save_on_stop': False, 'rw': False, - 'internal': True }, 'private': { 'name': 'private', 'pool': 'default', 'snap_on_start': True, 'save_on_stop': False, - 'internal': True, 'rw': True, }, 'volatile': { 'name': 'volatile', 'pool': 'default', - 'internal': True, 'snap_on_start': False, 'save_on_stop': False, 'rw': True, @@ -73,7 +70,6 @@ class DispVM(qubes.vm.qubesvm.QubesVM): 'snap_on_start': False, 'save_on_stop': False, 'rw': False, - 'internal': True } } if 'name' not in kwargs and 'dispid' in kwargs: diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 0f2f0530..9b1261af 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -1815,9 +1815,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): def _clean_volume_config(config): - common_attributes = ['name', 'pool', 'size', 'internal', 'removable', - 'revisions_to_keep', 'rw', 'snap_on_start', - 'save_on_stop', 'source'] + common_attributes = ['name', 'pool', 'size', + 'revisions_to_keep', 'rw', 'snap_on_start', + 'save_on_stop', 'source'] config_copy = copy.deepcopy(config) return {k: v for k, v in config_copy.items() if k in common_attributes} diff --git a/qubes/vm/standalonevm.py b/qubes/vm/standalonevm.py index 7aab434d..582ad65e 100644 --- a/qubes/vm/standalonevm.py +++ b/qubes/vm/standalonevm.py @@ -35,7 +35,6 @@ class StandaloneVM(qubes.vm.qubesvm.QubesVM): 'save_on_stop': True, 'rw': True, 'source': None, - 'internal': True, 'size': qubes.config.defaults['root_img_size'], }, 'private': { @@ -45,7 +44,6 @@ class StandaloneVM(qubes.vm.qubesvm.QubesVM): 'save_on_stop': True, 'rw': True, 'source': None, - 'internal': True, 'size': qubes.config.defaults['private_img_size'], }, 'volatile': { @@ -53,7 +51,6 @@ class StandaloneVM(qubes.vm.qubesvm.QubesVM): 'pool': 'default', 'snap_on_start': False, 'save_on_stop': False, - 'internal': True, 'rw': True, 'size': qubes.config.defaults['root_img_size'], }, @@ -63,7 +60,6 @@ class StandaloneVM(qubes.vm.qubesvm.QubesVM): 'snap_on_start': False, 'save_on_stop': False, 'rw': False, - 'internal': True } } super(StandaloneVM, self).__init__(*args, **kwargs) diff --git a/qubes/vm/templatevm.py b/qubes/vm/templatevm.py index 8cd07528..89128ba3 100644 --- a/qubes/vm/templatevm.py +++ b/qubes/vm/templatevm.py @@ -71,7 +71,6 @@ class TemplateVM(QubesVM): 'rw': True, 'source': None, 'size': defaults['root_img_size'], - 'internal': True }, 'private': { 'name': 'private', @@ -82,7 +81,6 @@ class TemplateVM(QubesVM): 'source': None, 'size': defaults['private_img_size'], 'revisions_to_keep': 0, - 'internal': True }, 'volatile': { 'name': 'volatile', @@ -90,7 +88,6 @@ class TemplateVM(QubesVM): 'size': defaults['root_img_size'], 'snap_on_start': False, 'save_on_stop': False, - 'internal': True, 'rw': True, }, 'kernel': { @@ -98,7 +95,6 @@ class TemplateVM(QubesVM): 'pool': 'linux-kernel', 'snap_on_start': False, 'save_on_stop': False, - 'internal': True, 'rw': False } }