aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2019-01-23 12:00:15 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2019-01-24 14:16:56 +0000
commit772f1b3721ac138b69c525cb2186b6d72ed200e1 (patch)
tree54dd1f921d4aa12337aa71c1ab724fbc144d9be7 /scripts
parent77606363094332415995db7e09ed532b8903fdb3 (diff)
downloadqemu-772f1b3721ac138b69c525cb2186b6d72ed200e1.zip
qemu-772f1b3721ac138b69c525cb2186b6d72ed200e1.tar.gz
qemu-772f1b3721ac138b69c525cb2186b6d72ed200e1.tar.bz2
trace: forbid use of %m in trace event format strings
The '%m' format instructs glibc's printf()/syslog() implementation to insert the contents of strerror(errno). Since this is a glibc extension it should generally be avoided in QEMU due to need for portability to a variety of platforms. Even though vfio is Linux-only code that could otherwise use "%m", it must still be avoided in trace-events files because several of the backends do not use the format string and so this error information is invisible to them. The errno string value should be given as an explicit trace argument instead, making it accessible to all backends. This also allows it to work correctly with future patches that use the format string with systemtap's simple printf code. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-id: 20190123120016.4538-4-berrange@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/tracetool/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 3478ac9..6fca674 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -274,6 +274,10 @@ class Event(object):
props = groups["props"].split()
fmt = groups["fmt"]
fmt_trans = groups["fmt_trans"]
+ if fmt.find("%m") != -1 or fmt_trans.find("%m") != -1:
+ raise ValueError("Event format '%m' is forbidden, pass the error "
+ "as an explicit trace argument")
+
if len(fmt_trans) > 0:
fmt = [fmt_trans, fmt]
args = Arguments.build(groups["args"])