yeahuh / rpms / qemu-kvm

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