1
0
Fork 0

dbus: ensure that hotplug operations only work on hotplug plugins

This adds a check to instance_acquire_devices to ensure
that the plugin actually supports the requested operation.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
This commit is contained in:
Adriaan Schmidt 2024-03-15 11:27:17 +01:00
parent b10bafce48
commit 6c48757c2f

View file

@ -5,6 +5,7 @@ from tuned.exceptions import TunedException
import threading
import tuned.consts as consts
from tuned.utils.commands import commands
from tuned.plugins import hotplug
__all__ = ["Controller"]
@ -352,6 +353,10 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
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: