Skip to content

Commit

Permalink
feat: allow dynamic instances of non-hotplug plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Adriaan Schmidt <[email protected]>
  • Loading branch information
adriaan42 committed Dec 3, 2024
1 parent 41cac0f commit cc9a1e1
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tuned/daemon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -525,13 +521,11 @@ 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)
has_devices = isinstance(plugin, hotplug.Plugin)
devices = instance.processed_devices.copy()
try:
plugin._remove_devices_nocheck(instance, devices)
if has_devices:
plugin._remove_devices_nocheck(instance, devices)
self._daemon._unit_manager.instances.remove(instance)
plugin.instance_unapply_tuning(instance)
plugin.destroy_instance(instance)
Expand All @@ -540,7 +534,8 @@ def instance_destroy(self, instance_name, caller = None):
log.error(rets)
return (False, rets)
log.info("Deleted instance '%s'" % instance_name)
for device in devices:
# _add_device() will find a suitable plugin instance
plugin._add_device(device)
if has_devices:
for device in devices:
# _add_device() will find a suitable plugin instance
plugin._add_device(device)
return (True, "OK")

0 comments on commit cc9a1e1

Please sign in to comment.