Skip to content

Commit

Permalink
dbus: ensure that hotplug operations only work on hotplug plugins
Browse files Browse the repository at this point in the history
This adds a check to instance_acquire_devices to ensure
that the plugin actually supports the requested operation.

Signed-off-by: Adriaan Schmidt <[email protected]>
  • Loading branch information
adriaan42 committed Mar 15, 2024
1 parent b10bafc commit 6c48757
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tuned/daemon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import threading
import tuned.consts as consts
from tuned.utils.commands import commands
from tuned.plugins import hotplug

__all__ = ["Controller"]

Expand Down Expand Up @@ -352,6 +353,10 @@ def instance_acquire_devices(self, devices, instance_name, caller = None):
rets = "Instance '%s' not found" % instance_name
log.error(rets)
return (False, rets)
if not isinstance(instance_target.plugin, hotplug.Plugin):
rets = "Plugin '%s' does not support hotplugging or dynamic instances." % instance_target.plugin.name
log.error(rets)
return (False, rets)
devs = set(self._cmd.devstr2devs(devices))
log.debug("Instance '%s' trying to acquire devices '%s'." % (instance_target.name, str(devs)))
for instance in self._daemon._unit_manager.instances:
Expand Down

0 comments on commit 6c48757

Please sign in to comment.