From b4c28f673a0a372ad143c926c24554cc96f59d7c Mon Sep 17 00:00:00 2001 From: Adriaan Schmidt Date: Tue, 3 Dec 2024 08:50:53 +0100 Subject: [PATCH] feat: allow dynamic instances of non-hotplug plugins Signed-off-by: Adriaan Schmidt --- tuned/daemon/controller.py | 8 -------- tuned/plugins/base.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py index 726e3a23..29a02794 100644 --- a/tuned/daemon/controller.py +++ b/tuned/daemon/controller.py @@ -467,10 +467,6 @@ def instance_create(self, plugin_name, instance_name, options, caller = None): log.error(rets) return (False, rets) plugin = plugins[plugin_name] - if not isinstance(plugin, hotplug.Plugin): - rets = "Plugin '%s' does not support hotplugging or dynamic instances." % plugin.name - log.error(rets) - return (False, rets) devices = options.pop("devices", None) devices_udev_regex = options.pop("devices_udev_regex", None) script_pre = options.pop("script_pre", None) @@ -525,10 +521,6 @@ def instance_destroy(self, instance_name, caller = None): log.error(rets) return (False, rets) plugin = instance.plugin - if not isinstance(plugin, hotplug.Plugin): - rets = "Plugin '%s' does not support hotplugging or dynamic instances." % plugin.name - log.error(rets) - return (False, rets) devices = instance.processed_devices.copy() try: plugin._remove_devices_nocheck(instance, devices) diff --git a/tuned/plugins/base.py b/tuned/plugins/base.py index b6ac8ddb..aa795fff 100644 --- a/tuned/plugins/base.py +++ b/tuned/plugins/base.py @@ -154,6 +154,9 @@ def _get_device_objects(self, devices): return None def _get_matching_devices(self, instance, devices): + if not self._devices_supported: + return set() + if instance.devices_udev_regex is None: return set(self._device_matcher.match_list(instance.devices_expression, devices)) else: @@ -164,6 +167,18 @@ def _get_matching_devices(self, instance, devices): udev_devices = self._device_matcher_udev.match_list(instance.devices_udev_regex, udev_devices) return set([x.sys_name for x in udev_devices]) + def _add_device(self, device_name): + pass + + def _add_devices_nocheck(self, instance, device_names): + pass + + def _remove_device(self, device_name): + pass + + def _remove_devices_nocheck(self, instance, device_names): + pass + def assign_free_devices(self, instance): if not self._devices_supported: return