From a0723a9e3222f740c505536d240330e806c7104e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 19 Mar 2018 21:51:20 +0100 Subject: [PATCH] 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. --- qubes/storage/kernels.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/qubes/storage/kernels.py b/qubes/storage/kernels.py index b39d8b3d..e60ac70e 100644 --- a/qubes/storage/kernels.py +++ b/qubes/storage/kernels.py @@ -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 '''