Skip to content

Commit

Permalink
storage: drop 'internal' and 'removable' volume properties
Browse files Browse the repository at this point in the history
Since dynamic volumes (qvm-block) are moved to devices API, those two
are not needed anymore.

QubesOS/qubes-issues#2256
  • Loading branch information
marmarek committed Jul 4, 2017
1 parent 075d991 commit 0e55429
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 38 deletions.
2 changes: 1 addition & 1 deletion qubes/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def vm_volume_info(self):
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)
Expand Down
13 changes: 4 additions & 9 deletions qubes/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,14 @@ 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.
: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
Expand Down Expand Up @@ -125,8 +121,6 @@ def __init__(self, name, pool, vid, internal=False, removable=False,
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)
Expand Down Expand Up @@ -317,8 +311,6 @@ def config(self):
'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,
Expand Down Expand Up @@ -382,6 +374,9 @@ def init_volume(self, name, volume_config):
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
Expand Down
1 change: 0 additions & 1 deletion qubes/storage/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def volumes(self):
kernel_version,
pool=self,
name=kernel_version,
internal=True,
rw=False
)
for kernel_version in os.listdir(self.dir_path)]
Expand Down
2 changes: 1 addition & 1 deletion qubes/tests/api_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# 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']


Expand Down
7 changes: 0 additions & 7 deletions qubes/tests/integ/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _test_000_volatile(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'save_on_stop': False,
'rw': True,
}
Expand Down Expand Up @@ -91,7 +90,6 @@ def _test_001_non_volatile(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'save_on_stop': True,
'rw': True,
}
Expand Down Expand Up @@ -126,7 +124,6 @@ def _test_002_read_only(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'save_on_stop': False,
'rw': False,
}
Expand Down Expand Up @@ -157,7 +154,6 @@ def _test_003_snapshot(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'save_on_stop': True,
'rw': True,
}
Expand All @@ -166,7 +162,6 @@ def _test_003_snapshot(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'snap_on_start': True,
'source': testvol.vid,
'rw': True,
Expand Down Expand Up @@ -225,7 +220,6 @@ def _test_004_snapshot_non_persistent(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'save_on_stop': True,
'rw': True,
}
Expand All @@ -234,7 +228,6 @@ def _test_004_snapshot_non_persistent(self):
volume_config = {
'pool': self.pool.name,
'size': size,
'internal': False,
'snap_on_start': True,
'source': testvol.vid,
'rw': True,
Expand Down
4 changes: 0 additions & 4 deletions qubes/vm/appvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
'save_on_stop': False,
'rw': False,
'source': None,
'internal': True
},
'private': {
'name': 'private',
Expand All @@ -58,15 +57,13 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
'save_on_stop': True,
'rw': True,
'size': defaults['private_img_size'],
'internal': True
},
'volatile': {
'name': 'volatile',
'pool': 'default',
'snap_on_start': False,
'save_on_stop': False,
'size': defaults['root_img_size'],
'internal': True,
'rw': True,
},
'kernel': {
Expand All @@ -75,7 +72,6 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
'snap_on_start': False,
'save_on_stop': False,
'rw': False,
'internal': True
}
}

Expand Down
4 changes: 0 additions & 4 deletions qubes/vm/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ def __init__(self, *args, **kwargs):
'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,
Expand All @@ -73,7 +70,6 @@ def __init__(self, *args, **kwargs):
'snap_on_start': False,
'save_on_stop': False,
'rw': False,
'internal': True
}
}
if 'name' not in kwargs and 'dispid' in kwargs:
Expand Down
6 changes: 3 additions & 3 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1815,9 +1815,9 @@ def get_prefmem(self):


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}

Expand Down
4 changes: 0 additions & 4 deletions qubes/vm/standalonevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self, *args, **kwargs):
'save_on_stop': True,
'rw': True,
'source': None,
'internal': True,
'size': qubes.config.defaults['root_img_size'],
},
'private': {
Expand All @@ -45,15 +44,13 @@ def __init__(self, *args, **kwargs):
'save_on_stop': True,
'rw': True,
'source': None,
'internal': True,
'size': qubes.config.defaults['private_img_size'],
},
'volatile': {
'name': 'volatile',
'pool': 'default',
'snap_on_start': False,
'save_on_stop': False,
'internal': True,
'rw': True,
'size': qubes.config.defaults['root_img_size'],
},
Expand All @@ -63,7 +60,6 @@ def __init__(self, *args, **kwargs):
'snap_on_start': False,
'save_on_stop': False,
'rw': False,
'internal': True
}
}
super(StandaloneVM, self).__init__(*args, **kwargs)
4 changes: 0 additions & 4 deletions qubes/vm/templatevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __init__(self, *args, **kwargs):
'rw': True,
'source': None,
'size': defaults['root_img_size'],
'internal': True
},
'private': {
'name': 'private',
Expand All @@ -82,23 +81,20 @@ def __init__(self, *args, **kwargs):
'source': None,
'size': defaults['private_img_size'],
'revisions_to_keep': 0,
'internal': True
},
'volatile': {
'name': 'volatile',
'pool': 'default',
'size': defaults['root_img_size'],
'snap_on_start': False,
'save_on_stop': False,
'internal': True,
'rw': True,
},
'kernel': {
'name': 'kernel',
'pool': 'linux-kernel',
'snap_on_start': False,
'save_on_stop': False,
'internal': True,
'rw': False
}
}
Expand Down

0 comments on commit 0e55429

Please sign in to comment.