summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-09-28 12:49:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-01 07:43:33 +0100
commitcb936708402a559cf67217970ce5d3b5049e3ef0 (patch)
tree0aff0a6cf3410329a8aebe0521af28b1caa53264 /meta/lib/oeqa/utils
parentba0f6ca79615579e53369b1614345fc27816307f (diff)
downloadpoky-cb936708402a559cf67217970ce5d3b5049e3ef0.tar.gz
qemurunner: Sanitize output from qemu and qemu pid
Currently the output from qemu could contain control or Unicode characters; having such characters in the log will cause an internal server error when sending the report to error reporting web. Control characters can be found in the command line used to run quemu too. This change sanitize the output from qemu and the command line used to run qemu, this way the logs doesn't contain control or Unicode characters and this will solve the issue of error reporting web and generate better logs. The only Unicode character found in the qemu output is the copyright symbol, it really doesn't interfer removing Unicode characters with debugging. [YOCTO #8225] (From OE-Core rev: 9f25f723828d6709aad581267ccc63d2ade1ff5c) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 5624977561..9c878bc707 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -13,6 +13,7 @@ import re
13import socket 13import socket
14import select 14import select
15import errno 15import errno
16import string
16import threading 17import threading
17from oeqa.utils.dump import HostDumper 18from oeqa.utils.dump import HostDumper
18 19
@@ -61,6 +62,9 @@ class QemuRunner:
61 62
62 def log(self, msg): 63 def log(self, msg):
63 if self.logfile: 64 if self.logfile:
65 # It is needed to sanitize the data received from qemu
66 # because is possible to have control characters or Unicode
67 msg = "".join(filter(lambda x:x in string.printable, msg))
64 with open(self.logfile, "a") as f: 68 with open(self.logfile, "a") as f:
65 f.write("%s" % msg) 69 f.write("%s" % msg)
66 70
@@ -170,6 +174,9 @@ class QemuRunner:
170 cmdline = '' 174 cmdline = ''
171 with open('/proc/%s/cmdline' % self.qemupid) as p: 175 with open('/proc/%s/cmdline' % self.qemupid) as p:
172 cmdline = p.read() 176 cmdline = p.read()
177 # It is needed to sanitize the data received
178 # because is possible to have control characters
179 cmdline = "".join(filter(lambda x:x in string.printable, cmdline))
173 try: 180 try:
174 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) 181 ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
175 if not ips or len(ips) != 3: 182 if not ips or len(ips) != 3: