Blob Blame History Raw
From 9ac6c7acac23cf8d2311f1f066d2e17b808a1101 Mon Sep 17 00:00:00 2001
From: Petr Oros <poros@redhat.com>
Date: Wed, 4 Dec 2013 08:27:15 +0000
Subject: [PATCH] CLI: fix traceback where enter -p policy without prio

commit  443234bd24c794068a752d567bb7f4d903fbbaac upstream
Bugzilla: 1035794

Tuna throwing value error when not specified priority.
Example: tuna -t PID_OF_SOME_PROCESS -p OTHER
Here "other" not priority, but scheduler policy.
For RR and FIFO default 1. For OTHER and BATCH default 0.
After patch apply, tuna use first part of string as policy and remaining part as priority.
All unacceptable values cause exception in schedutils library and tuna show error

Tested-by: Jiri Kastner <jkastner@redhat.com>
Signed-off-by: Petr Oros <poros@redhat.com>
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
 tuna/tuna.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tuna/tuna.py b/tuna/tuna.py
index 6dfe740..0feb521 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -490,10 +490,14 @@ def thread_set_priority(tid, policy, rtprio):
 
 def threads_set_priority(tids, parm, affect_children = False):
 	parms = parm.split(":")
+	rtprio = 0
 	policy = None
-	if len(parms) != 1:
+	if parms[0].upper() in ["OTHER", "BATCH", "IDLE", "FIFO", "RR"]:
 		policy = schedutils.schedfromstr("SCHED_%s" % parms[0].upper())
-		rtprio = int(parms[1])
+		if len(parms) > 1:
+			rtprio = int(parms[1])
+		elif parms[0].upper() in ["FIFO", "RR"]:
+			rtprio = 1
 	else:
 		rtprio = int(parms[0])
 
-- 
1.8.1.4