From e227c9ed78a7de1ffaa4f4023dae1da65126405c Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Tue, 22 Jan 2013 20:41:06 +0100 Subject: [PATCH] disk plugin: switch to hotpluggable base, implement necessary switching --- tuned/plugins/plugin_disk.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index 6837f5c..00039cb 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -1,4 +1,4 @@ -import base +import hotplug from decorators import * import tuned.logs import tuned.utils.commands @@ -7,7 +7,7 @@ import re log = tuned.logs.get() -class DiskPlugin(base.Plugin): +class DiskPlugin(hotplug.Plugin): """ Plugin for tuning options of disks. """ @@ -36,6 +36,27 @@ class DiskPlugin(base.Plugin): and device.parent is not None \ and device.parent.subsystem in ["scsi", "virtio"] + def _hardware_events_init(self): + self._hardware_inventory.subscribe(self, "block", self._hardware_events_callback) + + def _hardware_events_cleanup(self): + self._hardware_inventory.unsubscribe(self) + + def _hardware_events_callback(self, event, device): + if self._device_is_supported(device): + super(self.__class__, self)._hardware_events_callback(event, device) + + def _added_device_apply_tuning(self, instance, device_name): + if instance._load_monitor is not None: + log.critical("%s" % device_name) + instance._load_monitor.add_device(device_name) + super(self.__class__, self)._added_device_apply_tuning(instance, device_name) + + def _removed_device_unapply_tuning(self, instance, device_name): + if instance._load_monitor is not None: + instance._load_monitor.remove_device(device_name) + super(self.__class__, self)._removed_device_unapply_tuning(instance, device_name) + def _get_config_options(cls): return { "dynamic" : True, # FIXME: do we want this default?