yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
22c213
From e7cdcd1e39c4c030a32c9e8ef79316eae8555bc8 Mon Sep 17 00:00:00 2001
22c213
From: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Date: Thu, 16 Jan 2020 17:52:48 +0000
22c213
Subject: [PATCH 04/15] trace: update qemu-trace-stap to Python 3
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Message-id: <20200116175248.286556-2-stefanha@redhat.com>
22c213
Patchwork-id: 93365
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] trace: update qemu-trace-stap to Python 3
22c213
Bugzilla: 1787395
22c213
RH-Acked-by: John Snow <jsnow@redhat.com>
22c213
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
22c213
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
22c213
qemu-trace-stap does not support Python 3 yet:
22c213
22c213
  $ scripts/qemu-trace-stap list path/to/qemu-system-x86_64
22c213
  Traceback (most recent call last):
22c213
    File "scripts/qemu-trace-stap", line 175, in <module>
22c213
      main()
22c213
    File "scripts/qemu-trace-stap", line 171, in main
22c213
      args.func(args)
22c213
    File "scripts/qemu-trace-stap", line 118, in cmd_list
22c213
      print_probes(args.verbose, "*")
22c213
    File "scripts/qemu-trace-stap", line 114, in print_probes
22c213
      if line.startswith(prefix):
22c213
  TypeError: startswith first arg must be bytes or a tuple of bytes, not str
22c213
22c213
Now that QEMU requires Python 3.5 or later we can switch to pure Python
22c213
3.  Use Popen()'s universal_newlines=True argument to treat stdout as
22c213
text instead of binary.
22c213
22c213
Fixes: 62dd1048c0bd ("trace: add ability to do simple printf logging via systemtap")
22c213
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1787395
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
22c213
Message-id: 20200107112438.383958-1-stefanha@redhat.com
22c213
Message-Id: <20200107112438.383958-1-stefanha@redhat.com>
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
(cherry picked from commit 3f0097169bb60268cc5dda0c5ea47c31ab57b22f)
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 scripts/qemu-trace-stap | 8 ++++----
22c213
 1 file changed, 4 insertions(+), 4 deletions(-)
22c213
22c213
diff --git a/scripts/qemu-trace-stap b/scripts/qemu-trace-stap
22c213
index 91d1051..90527eb 100755
22c213
--- a/scripts/qemu-trace-stap
22c213
+++ b/scripts/qemu-trace-stap
22c213
@@ -1,4 +1,4 @@
22c213
-#!/usr/bin/python
22c213
+#!/usr/bin/env python3
22c213
 # -*- python -*-
22c213
 #
22c213
 # Copyright (C) 2019 Red Hat, Inc
22c213
@@ -18,8 +18,6 @@
22c213
 # You should have received a copy of the GNU General Public License
22c213
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
22c213
 
22c213
-from __future__ import print_function
22c213
-
22c213
 import argparse
22c213
 import copy
22c213
 import os.path
22c213
@@ -104,7 +102,9 @@ def cmd_list(args):
22c213
         if verbose:
22c213
             print("Listing probes with name '%s'" % script)
22c213
         proc = subprocess.Popen(["stap", "-l", script],
22c213
-                                stdout=subprocess.PIPE, env=tapset_env(tapsets))
22c213
+                                stdout=subprocess.PIPE,
22c213
+                                universal_newlines=True,
22c213
+                                env=tapset_env(tapsets))
22c213
         out, err = proc.communicate()
22c213
         if proc.returncode != 0:
22c213
             print("No probes found, are the tapsets installed in %s" % tapset_dir(args.binary))
22c213
-- 
22c213
1.8.3.1
22c213