storage/kernels: refuse changes to 'rw' and 'revisions_to_keep'

This pool driver support only rw=False and revisions_to_keep=0 volumes.
Since there is API for changing those properties dynamically, block it
at pool driver level, instead of silently ignoring them.
This commit is contained in:
Marek Marczykowski-Górecki 2018-03-19 21:51:20 +01:00
parent 376c8ec00d
commit a0723a9e32
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -23,18 +23,20 @@
import os
import qubes.exc
from qubes.storage import Pool, StoragePoolException, Volume
class LinuxModules(Volume):
''' A volume representing a ro linux kernel '''
rw = False
def __init__(self, target_dir, kernel_version, **kwargs):
kwargs['vid'] = ''
super(LinuxModules, self).__init__(**kwargs)
self._kernel_version = kernel_version
self.target_dir = target_dir
assert self.revisions_to_keep == 0
assert self.rw is False
@property
def vid(self):
@ -104,6 +106,28 @@ class LinuxModules(Volume):
def is_outdated(self):
return False
@property
def revisions_to_keep(self):
return 0
@revisions_to_keep.setter
def revisions_to_keep(self, value):
# pylint: disable=no-self-use
if value:
raise qubes.exc.QubesValueError(
'LinuxModules supports only revisions_to_keep=0')
@property
def rw(self):
return False
@rw.setter
def rw(self, value):
# pylint: disable=no-self-use
if value:
raise qubes.exc.QubesValueError(
'LinuxModules supports only read-only volumes')
def start(self):
return self
@ -131,7 +155,7 @@ class LinuxKernel(Pool):
def __init__(self, name=None, dir_path=None):
assert dir_path, 'Missing dir_path'
super(LinuxKernel, self).__init__(name=name)
super(LinuxKernel, self).__init__(name=name, revisions_to_keep=0)
self.dir_path = dir_path
def init_volume(self, vm, volume_config):
@ -167,6 +191,17 @@ class LinuxKernel(Pool):
def setup(self):
pass
@property
def revisions_to_keep(self):
return 0
@revisions_to_keep.setter
def revisions_to_keep(self, value):
# pylint: disable=no-self-use
if value:
raise qubes.exc.QubesValueError(
'LinuxModules supports only revisions_to_keep=0')
@property
def volumes(self):
''' Return all known kernel volumes '''