diff --git a/tuned/plugins/base.py b/tuned/plugins/base.py index 7bcfc40..6c8ec6c 100644 --- a/tuned/plugins/base.py +++ b/tuned/plugins/base.py @@ -19,6 +19,10 @@ class Plugin(object): def tunable_devices(cls): return None + @classmethod + def is_supported(cls): + return True + # instance methods def __init__(self, devices = None, options = None): diff --git a/tuned/plugins/plugin_eeepc_she.py b/tuned/plugins/plugin_eeepc_she.py index 42041d4..f7b13ef 100644 --- a/tuned/plugins/plugin_eeepc_she.py +++ b/tuned/plugins/plugin_eeepc_she.py @@ -17,11 +17,14 @@ class EeePCSHEPlugin(tuned.plugins.Plugin): self._she_mode = None self._load_monitor = tuned.monitors.get_repository().create("load", devices) + + @classmethod + def is_supported(cls): try: os.open("/sys/devices/platform/eeepc/cpufv", os.O_WRONLY) + return True except: - log.info("eeepc_she is not supported on you system") - raise + return False @classmethod def _get_default_options(cls): diff --git a/tuned/plugins/repository.py b/tuned/plugins/repository.py index 9ad673e..8c49041 100644 --- a/tuned/plugins/repository.py +++ b/tuned/plugins/repository.py @@ -31,6 +31,14 @@ class PluginRepository(tuned.patterns.Singleton): plugin_exception = tuned.plugins.exception.LoadPluginException(plugin_name, exception) raise plugin_exception + def is_supported(self, plugin_name): + try: + plugin_cls = self._loader.load(plugin_name) + return plugin_cls.is_supported() + except Exception as exception: + plugin_exception = tuned.plugins.exception.LoadPluginException(plugin_name, exception) + raise plugin_exception + def delete(self, plugin): assert isinstance(plugin, self._loader.interface) log.debug("removing plugin %s" % plugin) diff --git a/tuned/profile.py b/tuned/profile.py index b1701f7..f7ddfe4 100644 --- a/tuned/profile.py +++ b/tuned/profile.py @@ -134,6 +134,12 @@ class Profile(object): def _store_plugin_config(self, name, plugin_cfg): plugin = plugin_cfg["type"] + + # Check if the plugin is supported on this HW + if not tuned.plugins.get_repository().is_supported(plugin): + log.info("Plugin %s is not supported on this HW" % (plugin)) + return + # If there are no devices set, set all tunable_devices as default if not plugin_cfg.has_key("devices"): try: