From d6d293b86c4cc306b31d75c35c1a5954ae9cb080 Mon Sep 17 00:00:00 2001 From: Praveen K Pandey Date: Mon, 13 May 2024 18:36:11 +0530 Subject: [PATCH] Added utility in disk library help to Set io scheduler to a device Added utility in disk library help to Set io scheduler to a device Signed-off-by: Praveen K Pandey --- avocado/utils/disk.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/avocado/utils/disk.py b/avocado/utils/disk.py index 451fa324b7..9954f3f37f 100644 --- a/avocado/utils/disk.py +++ b/avocado/utils/disk.py @@ -475,7 +475,19 @@ def get_io_scheduler(device_name): def __sched_path(device_name): - + file_path = f"/sys/block/{device_name}/queue/scheduler" return file_path + +def set_io_scheduler(device_name, name): + """ + Set io scheduler to a device + :param device_name: Device name example like sda + :param name: io scheduler name + """ + if name not in get_io_scheduler_list(device_name): + raise DiskError(f"No such IO scheduler: {name}") + + with open(__sched_path(device_name), "w", encoding="utf-8") as fp: + fp.write(name)