Blame SOURCES/tuna-Exit-with-error-msg-on-s390-and-s390x-for-unsup.patch

0ebf27
From 1202ad0fdee7d46a7c0a6a6263bb2efd713f8cf8 Mon Sep 17 00:00:00 2001
0ebf27
From: John Kacur <jkacur@redhat.com>
0ebf27
Date: Thu, 14 Mar 2019 17:14:30 +0100
0ebf27
Subject: [PATCH 5/5] tuna: Exit with error msg on s390 and s390x for
0ebf27
 unsupported irq ops
0ebf27
0ebf27
On s390 and s390x any operations involving irqs will fail.
0ebf27
Try to exit cleanly with an error message that these operations are
0ebf27
unsupported on s390 and s390x
0ebf27
0ebf27
Signed-off-by: John Kacur <jkacur@redhat.com>
0ebf27
---
0ebf27
 tuna/tuna.py | 18 +++++++++++++++++-
0ebf27
 1 file changed, 17 insertions(+), 1 deletion(-)
0ebf27
0ebf27
diff --git a/tuna/tuna.py b/tuna/tuna.py
0ebf27
index eae0408c2fe7..42db4cfcee3f 100755
0ebf27
--- a/tuna/tuna.py
0ebf27
+++ b/tuna/tuna.py
0ebf27
@@ -3,6 +3,7 @@
0ebf27
 
0ebf27
 import copy, ethtool, errno, os, procfs, re, schedutils, sys, shlex
0ebf27
 import help, fnmatch
0ebf27
+import platform
0ebf27
 from procfs import utilist
0ebf27
 
0ebf27
 try:
0ebf27
@@ -334,9 +335,24 @@ def affinity_remove_cpus(affinity, cpus, nr_cpus):
0ebf27
 		affinity = list(set(affinity) - set(cpus))
0ebf27
 	return affinity
0ebf27
 
0ebf27
+# True if machine is s390 or s390x
0ebf27
+def is_s390():
0ebf27
+        machine = platform.machine()
0ebf27
+        if re.search('s390', machine):
0ebf27
+                return True
0ebf27
+        else:
0ebf27
+                return False
0ebf27
+
0ebf27
 # Shound be moved to python_linux_procfs.interrupts, shared with interrupts.parse_affinity, etc.
0ebf27
 def parse_irq_affinity_filename(filename, nr_cpus):
0ebf27
-	f = file("/proc/irq/%s" % filename)
0ebf27
+        try:
0ebf27
+	        f = open("/proc/irq/%s" % filename)
0ebf27
+        except IOError as err:
0ebf27
+                if is_s390():
0ebf27
+                        print >> sys.stderr, "This operation is not supported on s390"
0ebf27
+                        print("tuna: %s" % err)
0ebf27
+                        sys.exit(2)
0ebf27
+
0ebf27
 	line = f.readline()
0ebf27
 	f.close()
0ebf27
 	return utilist.bitmasklist(line, nr_cpus)
0ebf27
-- 
0ebf27
2.20.1
0ebf27