From 3f0097169bb60268cc5dda0c5ea47c31ab57b22f Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 7 Jan 2020 11:24:38 +0000 Subject: trace: update qemu-trace-stap to Python 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qemu-trace-stap does not support Python 3 yet: $ scripts/qemu-trace-stap list path/to/qemu-system-x86_64 Traceback (most recent call last): File "scripts/qemu-trace-stap", line 175, in main() File "scripts/qemu-trace-stap", line 171, in main args.func(args) File "scripts/qemu-trace-stap", line 118, in cmd_list print_probes(args.verbose, "*") File "scripts/qemu-trace-stap", line 114, in print_probes if line.startswith(prefix): TypeError: startswith first arg must be bytes or a tuple of bytes, not str Now that QEMU requires Python 3.5 or later we can switch to pure Python 3. Use Popen()'s universal_newlines=True argument to treat stdout as text instead of binary. Fixes: 62dd1048c0bd ("trace: add ability to do simple printf logging via systemtap") Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1787395 Signed-off-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrangé Message-id: 20200107112438.383958-1-stefanha@redhat.com Message-Id: <20200107112438.383958-1-stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi --- scripts/qemu-trace-stap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/qemu-trace-stap') diff --git a/scripts/qemu-trace-stap b/scripts/qemu-trace-stap index 91d1051..90527eb 100755 --- a/scripts/qemu-trace-stap +++ b/scripts/qemu-trace-stap @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- python -*- # # Copyright (C) 2019 Red Hat, Inc @@ -18,8 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . -from __future__ import print_function - import argparse import copy import os.path @@ -104,7 +102,9 @@ def cmd_list(args): if verbose: print("Listing probes with name '%s'" % script) proc = subprocess.Popen(["stap", "-l", script], - stdout=subprocess.PIPE, env=tapset_env(tapsets)) + stdout=subprocess.PIPE, + universal_newlines=True, + env=tapset_env(tapsets)) out, err = proc.communicate() if proc.returncode != 0: print("No probes found, are the tapsets installed in %s" % tapset_dir(args.binary)) -- cgit v1.1