diff --git a/avocado/utils/disk.py b/avocado/utils/disk.py index 1694072a61..e740701961 100644 --- a/avocado/utils/disk.py +++ b/avocado/utils/disk.py @@ -474,4 +474,17 @@ def get_io_scheduler(device_name): def __sched_path(device_name): - return "/sys/block/%s/queue/scheduler" % device_name \ No newline at end of file + return "/sys/block/%s/queue/scheduler" % device_name + + +def set_io_scheduler(device_name, name): + """ + Set io scheduler to a device + :param device_name: Device name example like sda , hda + :param name: io scheduler name + """ + if name not in get_io_scheduler_list(device_name): + raise DiskError("No such IO scheduler: %s" % name) + + with open(__sched_path(device_name), "w") as fp: + fp.write(name)