yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-python-futurize-f-libfuturize.fixes.fix_print_with_i.patch

26ba25
From 141ae90648a8bb4c26238cfde4d4946e6cff3108 Mon Sep 17 00:00:00 2001
26ba25
From: Eduardo Habkost <ehabkost@redhat.com>
26ba25
Date: Mon, 25 Jun 2018 21:23:43 +0100
26ba25
Subject: [PATCH 02/15] python: futurize -f
26ba25
 libfuturize.fixes.fix_print_with_import
26ba25
26ba25
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
26ba25
Message-id: <20180625212346.26440-2-ehabkost@redhat.com>
26ba25
Patchwork-id: 81049
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 1/4] python: futurize -f libfuturize.fixes.fix_print_with_import
26ba25
Bugzilla: 1571533
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
26ba25
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
26ba25
Change all Python code to use print as a function.
26ba25
26ba25
This is necessary for Python 3 compatibility.
26ba25
26ba25
Done using:
26ba25
26ba25
  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
26ba25
    sort -u | grep -v README.sh4)
26ba25
  $ futurize -w -f libfuturize.fixes.fix_print_with_import $py
26ba25
26ba25
Backport conflicts:
26ba25
 * tests/docker/docker.py: class ProbeCommand doesn't exist
26ba25
   in the RHEL8 tree
26ba25
26ba25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
Acked-by: Fam Zheng <famz@redhat.com>
26ba25
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
Message-Id: <20180608122952.2009-2-ehabkost@redhat.com>
26ba25
[ehabkost: fixup tests/docker/docker.py]
26ba25
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
(cherry picked from commit f03868bd5653265e97b253102d77d83ea85efdea)
26ba25
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 scripts/analyse-9p-simpletrace.py        | 89 ++++++++++++++++----------------
26ba25
 scripts/analyse-locks-simpletrace.py     |  1 +
26ba25
 scripts/analyze-migration.py             | 11 ++--
26ba25
 scripts/device-crash-test                |  3 +-
26ba25
 scripts/dump-guest-memory.py             |  1 +
26ba25
 scripts/kvm/kvm_flightrecorder           | 21 ++++----
26ba25
 scripts/kvm/vmxcap                       |  1 +
26ba25
 scripts/qmp/qemu-ga-client               |  1 +
26ba25
 scripts/qmp/qmp                          | 17 +++---
26ba25
 scripts/qmp/qmp-shell                    | 35 +++++++------
26ba25
 scripts/qmp/qom-get                      |  7 +--
26ba25
 scripts/qmp/qom-list                     | 11 ++--
26ba25
 scripts/qmp/qom-set                      |  5 +-
26ba25
 scripts/qmp/qom-tree                     | 11 ++--
26ba25
 scripts/replay-dump.py                   | 21 ++++----
26ba25
 scripts/signrom.py                       |  1 +
26ba25
 scripts/simpletrace.py                   |  3 +-
26ba25
 scripts/vmstate-static-checker.py        | 85 +++++++++++++++---------------
26ba25
 tests/docker/docker.py                   | 11 ++--
26ba25
 tests/docker/travis.py                   | 15 +++---
26ba25
 tests/guest-debug/test-gdbstub.py        |  1 +
26ba25
 tests/image-fuzzer/runner.py             | 38 ++++++--------
26ba25
 tests/migration/guestperf/engine.py      | 29 ++++++-----
26ba25
 tests/migration/guestperf/plot.py        | 17 +++---
26ba25
 tests/migration/guestperf/shell.py       | 19 +++----
26ba25
 tests/qemu-iotests/149                   |  3 +-
26ba25
 tests/qemu-iotests/165                   |  3 +-
26ba25
 tests/qemu-iotests/iotests.py            |  5 +-
26ba25
 tests/qemu-iotests/nbd-fault-injector.py |  7 +--
26ba25
 tests/qemu-iotests/qcow2.py              | 39 +++++++-------
26ba25
 tests/qemu-iotests/qed.py                | 17 +++---
26ba25
 tests/vm/basevm.py                       |  3 +-
26ba25
 32 files changed, 278 insertions(+), 253 deletions(-)
26ba25
26ba25
diff --git a/scripts/analyse-9p-simpletrace.py b/scripts/analyse-9p-simpletrace.py
26ba25
index 3c3dee4..710e01a 100755
26ba25
--- a/scripts/analyse-9p-simpletrace.py
26ba25
+++ b/scripts/analyse-9p-simpletrace.py
26ba25
@@ -3,6 +3,7 @@
26ba25
 # Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
26ba25
 #
26ba25
 # Author: Harsh Prateek Bora
26ba25
+from __future__ import print_function
26ba25
 import os
26ba25
 import simpletrace
26ba25
 
26ba25
@@ -79,135 +80,135 @@ symbol_9p = {
26ba25
 
26ba25
 class VirtFSRequestTracker(simpletrace.Analyzer):
26ba25
         def begin(self):
26ba25
-                print "Pretty printing 9p simpletrace log ..."
26ba25
+                print("Pretty printing 9p simpletrace log ...")
26ba25
 
26ba25
         def v9fs_rerror(self, tag, id, err):
26ba25
-                print "RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")"
26ba25
+                print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")
26ba25
 
26ba25
         def v9fs_version(self, tag, id, msize, version):
26ba25
-                print "TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
26ba25
+                print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
26ba25
 
26ba25
         def v9fs_version_return(self, tag, id, msize, version):
26ba25
-                print "RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
26ba25
+                print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
26ba25
 
26ba25
         def v9fs_attach(self, tag, id, fid, afid, uname, aname):
26ba25
-                print "TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")"
26ba25
+                print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")
26ba25
 
26ba25
         def v9fs_attach_return(self, tag, id, type, version, path):
26ba25
-                print "RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})"
26ba25
+                print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
26ba25
 
26ba25
         def v9fs_stat(self, tag, id, fid):
26ba25
-                print "TSTAT (tag =", tag, ", fid =", fid, ")"
26ba25
+                print("TSTAT (tag =", tag, ", fid =", fid, ")")
26ba25
 
26ba25
         def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
26ba25
-                print "RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")"
26ba25
+                print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")
26ba25
 
26ba25
         def v9fs_getattr(self, tag, id, fid, request_mask):
26ba25
-                print "TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")"
26ba25
+                print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")
26ba25
 
26ba25
         def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
26ba25
-                print "RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")"
26ba25
+                print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")
26ba25
 
26ba25
         def v9fs_walk(self, tag, id, fid, newfid, nwnames):
26ba25
-                print "TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")"
26ba25
+                print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")
26ba25
 
26ba25
         def v9fs_walk_return(self, tag, id, nwnames, qids):
26ba25
-                print "RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")"
26ba25
+                print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")
26ba25
 
26ba25
         def v9fs_open(self, tag, id, fid, mode):
26ba25
-                print "TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")"
26ba25
+                print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")
26ba25
 
26ba25
         def v9fs_open_return(self, tag, id, type, version, path, iounit):
26ba25
-                print "ROPEN (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
26ba25
+                print("ROPEN (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
26ba25
 
26ba25
         def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
26ba25
-                print "TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")"
26ba25
+                print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")
26ba25
 
26ba25
         def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
26ba25
-                print "RLCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
26ba25
+                print("RLCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
26ba25
 
26ba25
         def v9fs_fsync(self, tag, id, fid, datasync):
26ba25
-                print "TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")"
26ba25
+                print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")
26ba25
 
26ba25
         def v9fs_clunk(self, tag, id, fid):
26ba25
-                print "TCLUNK (tag =", tag, ", fid =", fid, ")"
26ba25
+                print("TCLUNK (tag =", tag, ", fid =", fid, ")")
26ba25
 
26ba25
         def v9fs_read(self, tag, id, fid, off, max_count):
26ba25
-                print "TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")"
26ba25
+                print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")
26ba25
 
26ba25
         def v9fs_read_return(self, tag, id, count, err):
26ba25
-                print "RREAD (tag =", tag, ", count =", count, ", err =", err, ")"
26ba25
+                print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")
26ba25
 
26ba25
         def v9fs_readdir(self, tag, id, fid, offset, max_count):
26ba25
-                print "TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")"
26ba25
+                print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")
26ba25
 
26ba25
         def v9fs_readdir_return(self, tag, id, count, retval):
26ba25
-                print "RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")"
26ba25
+                print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")
26ba25
 
26ba25
         def v9fs_write(self, tag, id, fid, off, count, cnt):
26ba25
-                print "TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")"
26ba25
+                print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")
26ba25
 
26ba25
         def v9fs_write_return(self, tag, id, total, err):
26ba25
-                print "RWRITE (tag =", tag, ", total =", total, ", err =", err, ")"
26ba25
+                print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")
26ba25
 
26ba25
         def v9fs_create(self, tag, id, fid, name, perm, mode):
26ba25
-                print "TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")"
26ba25
+                print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")
26ba25
 
26ba25
         def v9fs_create_return(self, tag, id, type, version, path, iounit):
26ba25
-                print "RCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
26ba25
+                print("RCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
26ba25
 
26ba25
         def v9fs_symlink(self, tag, id, fid, name, symname, gid):
26ba25
-                print "TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")"
26ba25
+                print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")
26ba25
 
26ba25
         def v9fs_symlink_return(self, tag, id, type, version, path):
26ba25
-                print "RSYMLINK (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "})"
26ba25
+                print("RSYMLINK (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "})")
26ba25
 
26ba25
         def v9fs_flush(self, tag, id, flush_tag):
26ba25
-                print "TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")"
26ba25
+                print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")
26ba25
 
26ba25
         def v9fs_link(self, tag, id, dfid, oldfid, name):
26ba25
-                print "TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")"
26ba25
+                print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")
26ba25
 
26ba25
         def v9fs_remove(self, tag, id, fid):
26ba25
-                print "TREMOVE (tag =", tag, ", fid =", fid, ")"
26ba25
+                print("TREMOVE (tag =", tag, ", fid =", fid, ")")
26ba25
 
26ba25
         def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
26ba25
-                print "TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")"
26ba25
+                print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")
26ba25
 
26ba25
         def v9fs_mknod(self, tag, id, fid, mode, major, minor):
26ba25
-                print "TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")"
26ba25
+                print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")
26ba25
 
26ba25
         def v9fs_lock(self, tag, id, fid, type, start, length):
26ba25
-                print "TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
26ba25
+                print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
26ba25
 
26ba25
         def v9fs_lock_return(self, tag, id, status):
26ba25
-                print "RLOCK (tag =", tag, ", status =", status, ")"
26ba25
+                print("RLOCK (tag =", tag, ", status =", status, ")")
26ba25
 
26ba25
         def v9fs_getlock(self, tag, id, fid, type, start, length):
26ba25
-                print "TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
26ba25
+                print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
26ba25
 
26ba25
         def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
26ba25
-                print "RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id,  ")"
26ba25
+                print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id,  ")")
26ba25
 
26ba25
         def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
26ba25
-                print "TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")"
26ba25
+                print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")
26ba25
 
26ba25
         def v9fs_mkdir_return(self, tag, id, type, version, path, err):
26ba25
-                print "RMKDIR (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")"
26ba25
+                print("RMKDIR (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")
26ba25
 
26ba25
         def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
26ba25
-                print "TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")"
26ba25
+                print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")
26ba25
 
26ba25
         def v9fs_xattrwalk_return(self, tag, id, size):
26ba25
-                print "RXATTRWALK (tag =", tag, ", xattrsize  =", size, ")"
26ba25
+                print("RXATTRWALK (tag =", tag, ", xattrsize  =", size, ")")
26ba25
 
26ba25
         def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
26ba25
-                print "TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")"
26ba25
+                print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")
26ba25
 
26ba25
         def v9fs_readlink(self, tag, id, fid):
26ba25
-                print "TREADLINK (tag =", tag, ", fid =", fid, ")"
26ba25
+                print("TREADLINK (tag =", tag, ", fid =", fid, ")")
26ba25
 
26ba25
         def v9fs_readlink_return(self, tag, id, target):
26ba25
-                print "RREADLINK (tag =", tag, ", target =", target, ")"
26ba25
+                print("RREADLINK (tag =", tag, ", target =", target, ")")
26ba25
 
26ba25
 simpletrace.run(VirtFSRequestTracker())
26ba25
diff --git a/scripts/analyse-locks-simpletrace.py b/scripts/analyse-locks-simpletrace.py
26ba25
index 101e84d..352bc9c 100755
26ba25
--- a/scripts/analyse-locks-simpletrace.py
26ba25
+++ b/scripts/analyse-locks-simpletrace.py
26ba25
@@ -6,6 +6,7 @@
26ba25
 # Author: Alex Bennée <alex.bennee@linaro.org>
26ba25
 #
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import os
26ba25
 import simpletrace
26ba25
 import argparse
26ba25
diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
26ba25
index 88ff4ad..5c2010c 100755
26ba25
--- a/scripts/analyze-migration.py
26ba25
+++ b/scripts/analyze-migration.py
26ba25
@@ -17,6 +17,7 @@
26ba25
 # You should have received a copy of the GNU Lesser General Public
26ba25
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import numpy as np
26ba25
 import json
26ba25
 import os
26ba25
@@ -162,7 +163,7 @@ class RamSection(object):
26ba25
                     len = self.file.read64()
26ba25
                     self.sizeinfo[self.name] = '0x%016x' % len
26ba25
                     if self.write_memory:
26ba25
-                        print self.name
26ba25
+                        print(self.name)
26ba25
                         mkdir_p('./' + os.path.dirname(self.name))
26ba25
                         f = open('./' + self.name, "wb")
26ba25
                         f.truncate(0)
26ba25
@@ -588,7 +589,7 @@ if args.extract:
26ba25
     dump = MigrationDump(args.file)
26ba25
 
26ba25
     dump.read(desc_only = True)
26ba25
-    print "desc.json"
26ba25
+    print("desc.json")
26ba25
     f = open("desc.json", "wb")
26ba25
     f.truncate()
26ba25
     f.write(jsonenc.encode(dump.vmsd_desc))
26ba25
@@ -596,7 +597,7 @@ if args.extract:
26ba25
 
26ba25
     dump.read(write_memory = True)
26ba25
     dict = dump.getDict()
26ba25
-    print "state.json"
26ba25
+    print("state.json")
26ba25
     f = open("state.json", "wb")
26ba25
     f.truncate()
26ba25
     f.write(jsonenc.encode(dict))
26ba25
@@ -605,10 +606,10 @@ elif args.dump == "state":
26ba25
     dump = MigrationDump(args.file)
26ba25
     dump.read(dump_memory = args.memory)
26ba25
     dict = dump.getDict()
26ba25
-    print jsonenc.encode(dict)
26ba25
+    print(jsonenc.encode(dict))
26ba25
 elif args.dump == "desc":
26ba25
     dump = MigrationDump(args.file)
26ba25
     dump.read(desc_only = True)
26ba25
-    print jsonenc.encode(dump.vmsd_desc)
26ba25
+    print(jsonenc.encode(dump.vmsd_desc))
26ba25
 else:
26ba25
     raise Exception("Please specify either -x, -d state or -d dump")
26ba25
diff --git a/scripts/device-crash-test b/scripts/device-crash-test
26ba25
index 5d17dc6..6a85c15 100755
26ba25
--- a/scripts/device-crash-test
26ba25
+++ b/scripts/device-crash-test
26ba25
@@ -23,6 +23,7 @@
26ba25
 Run QEMU with all combinations of -machine and -device types,
26ba25
 check for crashes and unexpected errors.
26ba25
 """
26ba25
+from __future__ import print_function
26ba25
 
26ba25
 import sys
26ba25
 import os
26ba25
@@ -557,7 +558,7 @@ def main():
26ba25
                 tc[k] = v
26ba25
 
26ba25
     if len(binariesToTest(args, tc)) == 0:
26ba25
-        print >>sys.stderr, "No QEMU binary found"
26ba25
+        print("No QEMU binary found", file=sys.stderr)
26ba25
         parser.print_usage(sys.stderr)
26ba25
         return 1
26ba25
 
26ba25
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
26ba25
index 276eebf..5a857ce 100644
26ba25
--- a/scripts/dump-guest-memory.py
26ba25
+++ b/scripts/dump-guest-memory.py
26ba25
@@ -12,6 +12,7 @@ Authors:
26ba25
 This work is licensed under the terms of the GNU GPL, version 2 or later. See
26ba25
 the COPYING file in the top-level directory.
26ba25
 """
26ba25
+from __future__ import print_function
26ba25
 
26ba25
 import ctypes
26ba25
 import struct
26ba25
diff --git a/scripts/kvm/kvm_flightrecorder b/scripts/kvm/kvm_flightrecorder
26ba25
index 7fb1c2d..54a5674 100755
26ba25
--- a/scripts/kvm/kvm_flightrecorder
26ba25
+++ b/scripts/kvm/kvm_flightrecorder
26ba25
@@ -32,6 +32,7 @@
26ba25
 # consuming CPU cycles.  No disk I/O is performed since the ring buffer holds a
26ba25
 # fixed-size in-memory trace.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 
26ba25
@@ -77,8 +78,8 @@ def tail_trace():
26ba25
         pass
26ba25
 
26ba25
 def usage():
26ba25
-    print 'Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0]
26ba25
-    print 'Control the KVM flight recorder tracing.'
26ba25
+    print('Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0])
26ba25
+    print('Control the KVM flight recorder tracing.')
26ba25
     sys.exit(0)
26ba25
 
26ba25
 def main():
26ba25
@@ -87,15 +88,15 @@ def main():
26ba25
 
26ba25
     cmd = sys.argv[1]
26ba25
     if cmd == '--version':
26ba25
-        print 'kvm_flightrecorder version 1.0'
26ba25
+        print('kvm_flightrecorder version 1.0')
26ba25
         sys.exit(0)
26ba25
 
26ba25
     if not os.path.isdir(tracing_dir):
26ba25
-        print 'Unable to tracing debugfs directory, try:'
26ba25
-        print 'mount -t debugfs none /sys/kernel/debug'
26ba25
+        print('Unable to tracing debugfs directory, try:')
26ba25
+        print('mount -t debugfs none /sys/kernel/debug')
26ba25
         sys.exit(1)
26ba25
     if not os.access(tracing_dir, os.W_OK):
26ba25
-        print 'Unable to write to tracing debugfs directory, please run as root'
26ba25
+        print('Unable to write to tracing debugfs directory, please run as root')
26ba25
         sys.exit(1)
26ba25
 
26ba25
     if cmd == 'start':
26ba25
@@ -105,16 +106,16 @@ def main():
26ba25
             try:
26ba25
                 buffer_size_kb = int(sys.argv[2])
26ba25
             except ValueError:
26ba25
-                print 'Invalid per-cpu trace buffer size in KB'
26ba25
+                print('Invalid per-cpu trace buffer size in KB')
26ba25
                 sys.exit(1)
26ba25
             write_file(trace_path('buffer_size_kb'), str(buffer_size_kb))
26ba25
-            print 'Per-CPU ring buffer size set to %d KB' % buffer_size_kb
26ba25
+            print('Per-CPU ring buffer size set to %d KB' % buffer_size_kb)
26ba25
 
26ba25
         start_tracing()
26ba25
-        print 'KVM flight recorder enabled'
26ba25
+        print('KVM flight recorder enabled')
26ba25
     elif cmd == 'stop':
26ba25
         stop_tracing()
26ba25
-        print 'KVM flight recorder disabled'
26ba25
+        print('KVM flight recorder disabled')
26ba25
     elif cmd == 'dump':
26ba25
         dump_trace()
26ba25
     elif cmd == 'tail':
26ba25
diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
26ba25
index d9a6db0..99a8146 100755
26ba25
--- a/scripts/kvm/vmxcap
26ba25
+++ b/scripts/kvm/vmxcap
26ba25
@@ -10,6 +10,7 @@
26ba25
 # This work is licensed under the terms of the GNU GPL, version 2.  See
26ba25
 # the COPYING file in the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 MSR_IA32_VMX_BASIC = 0x480
26ba25
 MSR_IA32_VMX_PINBASED_CTLS = 0x481
26ba25
 MSR_IA32_VMX_PROCBASED_CTLS = 0x482
26ba25
diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client
26ba25
index 7d2a472..8510814 100755
26ba25
--- a/scripts/qmp/qemu-ga-client
26ba25
+++ b/scripts/qmp/qemu-ga-client
26ba25
@@ -36,6 +36,7 @@
26ba25
 # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent
26ba25
 #
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import base64
26ba25
 import random
26ba25
 
26ba25
diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp
26ba25
index 514b539..16d3bdb 100755
26ba25
--- a/scripts/qmp/qmp
26ba25
+++ b/scripts/qmp/qmp
26ba25
@@ -10,6 +10,7 @@
26ba25
 # This work is licensed under the terms of the GNU GPLv2 or later.
26ba25
 # See the COPYING file in the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys, os
26ba25
 from qmp import QEMUMonitorProtocol
26ba25
 
26ba25
@@ -26,9 +27,9 @@ def print_response(rsp, prefix=[]):
26ba25
             print_response(rsp[key], prefix + [key])
26ba25
     else:
26ba25
         if len(prefix):
26ba25
-            print '%s: %s' % ('.'.join(prefix), rsp)
26ba25
+            print('%s: %s' % ('.'.join(prefix), rsp))
26ba25
         else:
26ba25
-            print '%s' % (rsp)
26ba25
+            print('%s' % (rsp))
26ba25
 
26ba25
 def main(args):
26ba25
     path = None
26ba25
@@ -53,21 +54,21 @@ def main(args):
26ba25
             elif arg in ['help']:
26ba25
                 os.execlp('man', 'man', 'qmp')
26ba25
             else:
26ba25
-                print 'Unknown argument "%s"' % arg
26ba25
+                print('Unknown argument "%s"' % arg)
26ba25
 
26ba25
             args = args[1:]
26ba25
         else:
26ba25
             break
26ba25
 
26ba25
     if not path:
26ba25
-        print "QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH"
26ba25
+        print("QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH")
26ba25
         return 1
26ba25
 
26ba25
     if len(args):
26ba25
         command, args = args[0], args[1:]
26ba25
     else:
26ba25
-        print 'No command found'
26ba25
-        print 'Usage: "qmp [--path=qmp-monitor-address] qmp-cmd arguments"'
26ba25
+        print('No command found')
26ba25
+        print('Usage: "qmp [--path=qmp-monitor-address] qmp-cmd arguments"')
26ba25
         return 1
26ba25
 
26ba25
     if command in ['help']:
26ba25
@@ -93,7 +94,7 @@ def main(args):
26ba25
             os.execvp(fullcmd, [fullcmd] + args)
26ba25
         except OSError as exc:
26ba25
             if exc.errno == 2:
26ba25
-                print 'Command "%s" not found.' % (fullcmd)
26ba25
+                print('Command "%s" not found.' % (fullcmd))
26ba25
                 return 1
26ba25
             raise
26ba25
         return 0
26ba25
@@ -104,7 +105,7 @@ def main(args):
26ba25
     arguments = {}
26ba25
     for arg in args:
26ba25
         if not arg.startswith('--'):
26ba25
-            print 'Unknown argument "%s"' % arg
26ba25
+            print('Unknown argument "%s"' % arg)
26ba25
             return 1
26ba25
 
26ba25
         arg = arg[2:]
26ba25
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
26ba25
index be449de..b1cc7e2 100755
26ba25
--- a/scripts/qmp/qmp-shell
26ba25
+++ b/scripts/qmp/qmp-shell
26ba25
@@ -65,6 +65,7 @@
26ba25
 # which will echo back the properly formatted JSON-compliant QMP that is being
26ba25
 # sent to QEMU, which is useful for debugging and documentation generation.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import qmp
26ba25
 import json
26ba25
 import ast
26ba25
@@ -153,14 +154,14 @@ class QMPShell(qmp.QEMUMonitorProtocol):
26ba25
                 # File not found. No problem.
26ba25
                 pass
26ba25
             else:
26ba25
-                print "Failed to read history '%s'; %s" % (self._histfile, e)
26ba25
+                print("Failed to read history '%s'; %s" % (self._histfile, e))
26ba25
         atexit.register(self.__save_history)
26ba25
 
26ba25
     def __save_history(self):
26ba25
         try:
26ba25
             readline.write_history_file(self._histfile)
26ba25
         except Exception as e:
26ba25
-            print "Failed to save history file '%s'; %s" % (self._histfile, e)
26ba25
+            print("Failed to save history file '%s'; %s" % (self._histfile, e))
26ba25
 
26ba25
     def __parse_value(self, val):
26ba25
         try:
26ba25
@@ -258,15 +259,15 @@ class QMPShell(qmp.QEMUMonitorProtocol):
26ba25
         if self._pretty:
26ba25
             indent = 4
26ba25
         jsobj = json.dumps(qmp, indent=indent)
26ba25
-        print str(jsobj)
26ba25
+        print(str(jsobj))
26ba25
 
26ba25
     def _execute_cmd(self, cmdline):
26ba25
         try:
26ba25
             qmpcmd = self.__build_cmd(cmdline)
26ba25
         except Exception as e:
26ba25
-            print 'Error while parsing command line: %s' % e
26ba25
-            print 'command format: <command-name> ',
26ba25
-            print '[arg-name1=arg1] ... [arg-nameN=argN]'
26ba25
+            print('Error while parsing command line: %s' % e)
26ba25
+            print('command format: <command-name> ', end=' ')
26ba25
+            print('[arg-name1=arg1] ... [arg-nameN=argN]')
26ba25
             return True
26ba25
         # For transaction mode, we may have just cached the action:
26ba25
         if qmpcmd is None:
26ba25
@@ -275,7 +276,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
26ba25
             self._print(qmpcmd)
26ba25
         resp = self.cmd_obj(qmpcmd)
26ba25
         if resp is None:
26ba25
-            print 'Disconnected'
26ba25
+            print('Disconnected')
26ba25
             return False
26ba25
         self._print(resp)
26ba25
         return True
26ba25
@@ -285,12 +286,12 @@ class QMPShell(qmp.QEMUMonitorProtocol):
26ba25
         self.__completer_setup()
26ba25
 
26ba25
     def show_banner(self, msg='Welcome to the QMP low-level shell!'):
26ba25
-        print msg
26ba25
+        print(msg)
26ba25
         if not self._greeting:
26ba25
-            print 'Connected'
26ba25
+            print('Connected')
26ba25
             return
26ba25
         version = self._greeting['QMP']['version']['qemu']
26ba25
-        print 'Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])
26ba25
+        print('Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro']))
26ba25
 
26ba25
     def get_prompt(self):
26ba25
         if self._transmode:
26ba25
@@ -306,11 +307,11 @@ class QMPShell(qmp.QEMUMonitorProtocol):
26ba25
         try:
26ba25
             cmdline = raw_input(prompt)
26ba25
         except EOFError:
26ba25
-            print
26ba25
+            print()
26ba25
             return False
26ba25
         if cmdline == '':
26ba25
             for ev in self.get_events():
26ba25
-                print ev
26ba25
+                print(ev)
26ba25
             self.clear_events()
26ba25
             return True
26ba25
         else:
26ba25
@@ -366,24 +367,24 @@ class HMPShell(QMPShell):
26ba25
             try:
26ba25
                 idx = int(cmdline.split()[1])
26ba25
                 if not 'return' in self.__cmd_passthrough('info version', idx):
26ba25
-                    print 'bad CPU index'
26ba25
+                    print('bad CPU index')
26ba25
                     return True
26ba25
                 self.__cpu_index = idx
26ba25
             except ValueError:
26ba25
-                print 'cpu command takes an integer argument'
26ba25
+                print('cpu command takes an integer argument')
26ba25
                 return True
26ba25
         resp = self.__cmd_passthrough(cmdline, self.__cpu_index)
26ba25
         if resp is None:
26ba25
-            print 'Disconnected'
26ba25
+            print('Disconnected')
26ba25
             return False
26ba25
         assert 'return' in resp or 'error' in resp
26ba25
         if 'return' in resp:
26ba25
             # Success
26ba25
             if len(resp['return']) > 0:
26ba25
-                print resp['return'],
26ba25
+                print(resp['return'], end=' ')
26ba25
         else:
26ba25
             # Error
26ba25
-            print '%s: %s' % (resp['error']['class'], resp['error']['desc'])
26ba25
+            print('%s: %s' % (resp['error']['class'], resp['error']['desc']))
26ba25
         return True
26ba25
 
26ba25
     def show_banner(self):
26ba25
diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
26ba25
index 0172c69..291c8bf 100755
26ba25
--- a/scripts/qmp/qom-get
26ba25
+++ b/scripts/qmp/qom-get
26ba25
@@ -11,6 +11,7 @@
26ba25
 # the COPYING file in the top-level directory.
26ba25
 ##
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 from qmp import QEMUMonitorProtocol
26ba25
@@ -33,7 +34,7 @@ def usage_error(error_msg = "unspecified error"):
26ba25
 
26ba25
 if len(args) > 0:
26ba25
     if args[0] == "-h":
26ba25
-        print usage()
26ba25
+        print(usage())
26ba25
         exit(0);
26ba25
     elif args[0] == "-s":
26ba25
         try:
26ba25
@@ -62,6 +63,6 @@ srv.connect()
26ba25
 rsp = srv.command('qom-get', path=path, property=prop)
26ba25
 if type(rsp) == dict:
26ba25
     for i in rsp.keys():
26ba25
-        print '%s: %s' % (i, rsp[i])
26ba25
+        print('%s: %s' % (i, rsp[i]))
26ba25
 else:
26ba25
-    print rsp
26ba25
+    print(rsp)
26ba25
diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
26ba25
index 1e7cc6c..cd907bb 100755
26ba25
--- a/scripts/qmp/qom-list
26ba25
+++ b/scripts/qmp/qom-list
26ba25
@@ -11,6 +11,7 @@
26ba25
 # the COPYING file in the top-level directory.
26ba25
 ##
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 from qmp import QEMUMonitorProtocol
26ba25
@@ -33,7 +34,7 @@ def usage_error(error_msg = "unspecified error"):
26ba25
 
26ba25
 if len(args) > 0:
26ba25
     if args[0] == "-h":
26ba25
-        print usage()
26ba25
+        print(usage())
26ba25
         exit(0);
26ba25
     elif args[0] == "-s":
26ba25
         try:
26ba25
@@ -52,13 +53,13 @@ srv = QEMUMonitorProtocol(socket_path)
26ba25
 srv.connect()
26ba25
 
26ba25
 if len(args) == 0:
26ba25
-    print '/'
26ba25
+    print('/')
26ba25
     sys.exit(0)
26ba25
 
26ba25
 for item in srv.command('qom-list', path=args[0]):
26ba25
     if item['type'].startswith('child<'):
26ba25
-        print '%s/' % item['name']
26ba25
+        print('%s/' % item['name'])
26ba25
     elif item['type'].startswith('link<'):
26ba25
-        print '@%s/' % item['name']
26ba25
+        print('@%s/' % item['name'])
26ba25
     else:
26ba25
-        print '%s' % item['name']
26ba25
+        print('%s' % item['name'])
26ba25
diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
26ba25
index 94e2778..fbe4b3e 100755
26ba25
--- a/scripts/qmp/qom-set
26ba25
+++ b/scripts/qmp/qom-set
26ba25
@@ -11,6 +11,7 @@
26ba25
 # the COPYING file in the top-level directory.
26ba25
 ##
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 from qmp import QEMUMonitorProtocol
26ba25
@@ -34,7 +35,7 @@ def usage_error(error_msg = "unspecified error"):
26ba25
 
26ba25
 if len(args) > 0:
26ba25
     if args[0] == "-h":
26ba25
-        print usage()
26ba25
+        print(usage())
26ba25
         exit(0);
26ba25
     elif args[0] == "-s":
26ba25
         try:
26ba25
@@ -61,4 +62,4 @@ else:
26ba25
 srv = QEMUMonitorProtocol(socket_path)
26ba25
 srv.connect()
26ba25
 
26ba25
-print srv.command('qom-set', path=path, property=prop, value=value)
26ba25
+print(srv.command('qom-set', path=path, property=prop, value=value))
26ba25
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
26ba25
index 906fcd2..0ffd1ff 100755
26ba25
--- a/scripts/qmp/qom-tree
26ba25
+++ b/scripts/qmp/qom-tree
26ba25
@@ -13,6 +13,7 @@
26ba25
 # the COPYING file in the top-level directory.
26ba25
 ##
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 from qmp import QEMUMonitorProtocol
26ba25
@@ -35,7 +36,7 @@ def usage_error(error_msg = "unspecified error"):
26ba25
 
26ba25
 if len(args) > 0:
26ba25
     if args[0] == "-h":
26ba25
-        print usage()
26ba25
+        print(usage())
26ba25
         exit(0);
26ba25
     elif args[0] == "-s":
26ba25
         try:
26ba25
@@ -54,15 +55,15 @@ srv = QEMUMonitorProtocol(socket_path)
26ba25
 srv.connect()
26ba25
 
26ba25
 def list_node(path):
26ba25
-    print '%s' % path
26ba25
+    print('%s' % path)
26ba25
     items = srv.command('qom-list', path=path)
26ba25
     for item in items:
26ba25
         if not item['type'].startswith('child<'):
26ba25
             try:
26ba25
-                print '  %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type'])
26ba25
+                print('  %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type']))
26ba25
             except:
26ba25
-                print '  %s: <EXCEPTION> (%s)' % (item['name'], item['type'])
26ba25
-    print ''
26ba25
+                print('  %s: <EXCEPTION> (%s)' % (item['name'], item['type']))
26ba25
+    print('')
26ba25
     for item in items:
26ba25
         if item['type'].startswith('child<'):
26ba25
             list_node((path if (path != '/') else '')  + '/' + item['name'])
26ba25
diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py
26ba25
index e274086..5ae77c8 100755
26ba25
--- a/scripts/replay-dump.py
26ba25
+++ b/scripts/replay-dump.py
26ba25
@@ -18,6 +18,7 @@
26ba25
 # You should have received a copy of the GNU Lesser General Public
26ba25
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import argparse
26ba25
 import struct
26ba25
 from collections import namedtuple
26ba25
@@ -89,9 +90,9 @@ def call_decode(table, index, dumpfile):
26ba25
     "Search decode table for next step"
26ba25
     decoder = next((d for d in table if d.eid == index), None)
26ba25
     if not decoder:
26ba25
-        print "Could not decode index: %d" % (index)
26ba25
-        print "Entry is: %s" % (decoder)
26ba25
-        print "Decode Table is:\n%s" % (table)
26ba25
+        print("Could not decode index: %d" % (index))
26ba25
+        print("Entry is: %s" % (decoder))
26ba25
+        print("Decode Table is:\n%s" % (table))
26ba25
         return False
26ba25
     else:
26ba25
         return decoder.fn(decoder.eid, decoder.name, dumpfile)
26ba25
@@ -103,23 +104,23 @@ def print_event(eid, name, string=None, event_count=None):
26ba25
         event_count = replay_state.event_count
26ba25
 
26ba25
     if string:
26ba25
-        print "%d:%s(%d) %s" % (event_count, name, eid, string)
26ba25
+        print("%d:%s(%d) %s" % (event_count, name, eid, string))
26ba25
     else:
26ba25
-        print "%d:%s(%d)" % (event_count, name, eid)
26ba25
+        print("%d:%s(%d)" % (event_count, name, eid))
26ba25
 
26ba25
 
26ba25
 # Decoders for each event type
26ba25
 
26ba25
 def decode_unimp(eid, name, _unused_dumpfile):
26ba25
     "Unimplimented decoder, will trigger exit"
26ba25
-    print "%s not handled - will now stop" % (name)
26ba25
+    print("%s not handled - will now stop" % (name))
26ba25
     return False
26ba25
 
26ba25
 # Checkpoint decoder
26ba25
 def swallow_async_qword(eid, name, dumpfile):
26ba25
     "Swallow a qword of data without looking at it"
26ba25
     step_id = read_qword(dumpfile)
26ba25
-    print "  %s(%d) @ %d" % (name, eid, step_id)
26ba25
+    print("  %s(%d) @ %d" % (name, eid, step_id))
26ba25
     return True
26ba25
 
26ba25
 async_decode_table = [ Decoder(0, "REPLAY_ASYNC_EVENT_BH", swallow_async_qword),
26ba25
@@ -139,8 +140,8 @@ def decode_async(eid, name, dumpfile):
26ba25
     async_event_checkpoint = read_byte(dumpfile)
26ba25
 
26ba25
     if async_event_checkpoint != replay_state.current_checkpoint:
26ba25
-        print "  mismatch between checkpoint %d and async data %d" % (
26ba25
-            replay_state.current_checkpoint, async_event_checkpoint)
26ba25
+        print("  mismatch between checkpoint %d and async data %d" % (
26ba25
+            replay_state.current_checkpoint, async_event_checkpoint))
26ba25
         return True
26ba25
 
26ba25
     return call_decode(async_decode_table, async_event_kind, dumpfile)
26ba25
@@ -283,7 +284,7 @@ def decode_file(filename):
26ba25
     version = read_dword(dumpfile)
26ba25
     junk = read_qword(dumpfile)
26ba25
 
26ba25
-    print "HEADER: version 0x%x" % (version)
26ba25
+    print("HEADER: version 0x%x" % (version))
26ba25
 
26ba25
     if version == 0xe02007:
26ba25
         event_decode_table = v7_event_table
26ba25
diff --git a/scripts/signrom.py b/scripts/signrom.py
26ba25
index 0497a1c..313ee28 100644
26ba25
--- a/scripts/signrom.py
26ba25
+++ b/scripts/signrom.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 #
26ba25
 # Option ROM signing utility
26ba25
 #
26ba25
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py
26ba25
index 46a5fd7..54e761f 100755
26ba25
--- a/scripts/simpletrace.py
26ba25
+++ b/scripts/simpletrace.py
26ba25
@@ -9,6 +9,7 @@
26ba25
 #
26ba25
 # For help see docs/devel/tracing.txt
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import struct
26ba25
 import re
26ba25
 import inspect
26ba25
@@ -257,6 +258,6 @@ if __name__ == '__main__':
26ba25
                 else:
26ba25
                     fields.append('%s=0x%x' % (name, rec[i]))
26ba25
                 i += 1
26ba25
-            print ' '.join(fields)
26ba25
+            print(' '.join(fields))
26ba25
 
26ba25
     run(Formatter())
26ba25
diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
26ba25
index ffb13d1..7c97db6 100755
26ba25
--- a/scripts/vmstate-static-checker.py
26ba25
+++ b/scripts/vmstate-static-checker.py
26ba25
@@ -19,6 +19,7 @@
26ba25
 # You should have received a copy of the GNU General Public License along
26ba25
 # with this program; if not, see <http://www.gnu.org/licenses/>.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import argparse
26ba25
 import json
26ba25
 import sys
26ba25
@@ -175,10 +176,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
26ba25
             except StopIteration:
26ba25
                 if d_iter_list == []:
26ba25
                     # We were not in a substruct
26ba25
-                    print "Section \"" + sec + "\",",
26ba25
-                    print "Description " + "\"" + desc + "\":",
26ba25
-                    print "expected field \"" + s_item["field"] + "\",",
26ba25
-                    print "while dest has no further fields"
26ba25
+                    print("Section \"" + sec + "\",", end=' ')
26ba25
+                    print("Description " + "\"" + desc + "\":", end=' ')
26ba25
+                    print("expected field \"" + s_item["field"] + "\",", end=' ')
26ba25
+                    print("while dest has no further fields")
26ba25
                     bump_taint()
26ba25
                     break
26ba25
 
26ba25
@@ -196,10 +197,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
26ba25
                     advance_dest = True
26ba25
                     continue
26ba25
                 if unused_count < 0:
26ba25
-                    print "Section \"" + sec + "\",",
26ba25
-                    print "Description \"" + desc + "\":",
26ba25
-                    print "unused size mismatch near \"",
26ba25
-                    print s_item["field"] + "\""
26ba25
+                    print("Section \"" + sec + "\",", end=' ')
26ba25
+                    print("Description \"" + desc + "\":", end=' ')
26ba25
+                    print("unused size mismatch near \"", end=' ')
26ba25
+                    print(s_item["field"] + "\"")
26ba25
                     bump_taint()
26ba25
                     break
26ba25
                 continue
26ba25
@@ -210,10 +211,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
26ba25
                     advance_src = True
26ba25
                     continue
26ba25
                 if unused_count < 0:
26ba25
-                    print "Section \"" + sec + "\",",
26ba25
-                    print "Description \"" + desc + "\":",
26ba25
-                    print "unused size mismatch near \"",
26ba25
-                    print d_item["field"] + "\""
26ba25
+                    print("Section \"" + sec + "\",", end=' ')
26ba25
+                    print("Description \"" + desc + "\":", end=' ')
26ba25
+                    print("unused size mismatch near \"", end=' ')
26ba25
+                    print(d_item["field"] + "\"")
26ba25
                     bump_taint()
26ba25
                     break
26ba25
                 continue
26ba25
@@ -261,10 +262,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
26ba25
                     unused_count = s_item["size"] - d_item["size"]
26ba25
                     continue
26ba25
 
26ba25
-            print "Section \"" + sec + "\",",
26ba25
-            print "Description \"" + desc + "\":",
26ba25
-            print "expected field \"" + s_item["field"] + "\",",
26ba25
-            print "got \"" + d_item["field"] + "\"; skipping rest"
26ba25
+            print("Section \"" + sec + "\",", end=' ')
26ba25
+            print("Description \"" + desc + "\":", end=' ')
26ba25
+            print("expected field \"" + s_item["field"] + "\",", end=' ')
26ba25
+            print("got \"" + d_item["field"] + "\"; skipping rest")
26ba25
             bump_taint()
26ba25
             break
26ba25
 
26ba25
@@ -288,8 +289,8 @@ def check_subsections(src_sub, dest_sub, desc, sec):
26ba25
             check_descriptions(s_item, d_item, sec)
26ba25
 
26ba25
         if not found:
26ba25
-            print "Section \"" + sec + "\", Description \"" + desc + "\":",
26ba25
-            print "Subsection \"" + s_item["name"] + "\" not found"
26ba25
+            print("Section \"" + sec + "\", Description \"" + desc + "\":", end=' ')
26ba25
+            print("Subsection \"" + s_item["name"] + "\" not found")
26ba25
             bump_taint()
26ba25
 
26ba25
 
26ba25
@@ -298,8 +299,8 @@ def check_description_in_list(s_item, d_item, sec, desc):
26ba25
         return
26ba25
 
26ba25
     if not "Description" in d_item:
26ba25
-        print "Section \"" + sec + "\", Description \"" + desc + "\",",
26ba25
-        print "Field \"" + s_item["field"] + "\": missing description"
26ba25
+        print("Section \"" + sec + "\", Description \"" + desc + "\",", end=' ')
26ba25
+        print("Field \"" + s_item["field"] + "\": missing description")
26ba25
         bump_taint()
26ba25
         return
26ba25
 
26ba25
@@ -310,17 +311,17 @@ def check_descriptions(src_desc, dest_desc, sec):
26ba25
     check_version(src_desc, dest_desc, sec, src_desc["name"])
26ba25
 
26ba25
     if not check_fields_match(sec, src_desc["name"], dest_desc["name"]):
26ba25
-        print "Section \"" + sec + "\":",
26ba25
-        print "Description \"" + src_desc["name"] + "\"",
26ba25
-        print "missing, got \"" + dest_desc["name"] + "\" instead; skipping"
26ba25
+        print("Section \"" + sec + "\":", end=' ')
26ba25
+        print("Description \"" + src_desc["name"] + "\"", end=' ')
26ba25
+        print("missing, got \"" + dest_desc["name"] + "\" instead; skipping")
26ba25
         bump_taint()
26ba25
         return
26ba25
 
26ba25
     for f in src_desc:
26ba25
         if not f in dest_desc:
26ba25
-            print "Section \"" + sec + "\"",
26ba25
-            print "Description \"" + src_desc["name"] + "\":",
26ba25
-            print "Entry \"" + f + "\" missing"
26ba25
+            print("Section \"" + sec + "\"", end=' ')
26ba25
+            print("Description \"" + src_desc["name"] + "\":", end=' ')
26ba25
+            print("Entry \"" + f + "\" missing")
26ba25
             bump_taint()
26ba25
             continue
26ba25
 
26ba25
@@ -333,39 +334,39 @@ def check_descriptions(src_desc, dest_desc, sec):
26ba25
 
26ba25
 def check_version(s, d, sec, desc=None):
26ba25
     if s["version_id"] > d["version_id"]:
26ba25
-        print "Section \"" + sec + "\"",
26ba25
+        print("Section \"" + sec + "\"", end=' ')
26ba25
         if desc:
26ba25
-            print "Description \"" + desc + "\":",
26ba25
-        print "version error:", s["version_id"], ">", d["version_id"]
26ba25
+            print("Description \"" + desc + "\":", end=' ')
26ba25
+        print("version error:", s["version_id"], ">", d["version_id"])
26ba25
         bump_taint()
26ba25
 
26ba25
     if not "minimum_version_id" in d:
26ba25
         return
26ba25
 
26ba25
     if s["version_id"] < d["minimum_version_id"]:
26ba25
-        print "Section \"" + sec + "\"",
26ba25
+        print("Section \"" + sec + "\"", end=' ')
26ba25
         if desc:
26ba25
-            print "Description \"" + desc + "\":",
26ba25
-            print "minimum version error:", s["version_id"], "<",
26ba25
-            print d["minimum_version_id"]
26ba25
+            print("Description \"" + desc + "\":", end=' ')
26ba25
+            print("minimum version error:", s["version_id"], "<", end=' ')
26ba25
+            print(d["minimum_version_id"])
26ba25
             bump_taint()
26ba25
 
26ba25
 
26ba25
 def check_size(s, d, sec, desc=None, field=None):
26ba25
     if s["size"] != d["size"]:
26ba25
-        print "Section \"" + sec + "\"",
26ba25
+        print("Section \"" + sec + "\"", end=' ')
26ba25
         if desc:
26ba25
-            print "Description \"" + desc + "\"",
26ba25
+            print("Description \"" + desc + "\"", end=' ')
26ba25
         if field:
26ba25
-            print "Field \"" + field + "\"",
26ba25
-        print "size mismatch:", s["size"], ",", d["size"]
26ba25
+            print("Field \"" + field + "\"", end=' ')
26ba25
+        print("size mismatch:", s["size"], ",", d["size"])
26ba25
         bump_taint()
26ba25
 
26ba25
 
26ba25
 def check_machine_type(s, d):
26ba25
     if s["Name"] != d["Name"]:
26ba25
-        print "Warning: checking incompatible machine types:",
26ba25
-        print "\"" + s["Name"] + "\", \"" + d["Name"] + "\""
26ba25
+        print("Warning: checking incompatible machine types:", end=' ')
26ba25
+        print("\"" + s["Name"] + "\", \"" + d["Name"] + "\"")
26ba25
     return
26ba25
 
26ba25
 
26ba25
@@ -399,7 +400,7 @@ def main():
26ba25
             # doesn't exist in dest.
26ba25
             dest_sec = get_changed_sec_name(sec)
26ba25
             if not dest_sec in dest_data:
26ba25
-                print "Section \"" + sec + "\" does not exist in dest"
26ba25
+                print("Section \"" + sec + "\" does not exist in dest")
26ba25
                 bump_taint()
26ba25
                 continue
26ba25
 
26ba25
@@ -414,8 +415,8 @@ def main():
26ba25
 
26ba25
         for entry in s:
26ba25
             if not entry in d:
26ba25
-                print "Section \"" + sec + "\": Entry \"" + entry + "\"",
26ba25
-                print "missing"
26ba25
+                print("Section \"" + sec + "\": Entry \"" + entry + "\"", end=' ')
26ba25
+                print("missing")
26ba25
                 bump_taint()
26ba25
                 continue
26ba25
 
26ba25
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
26ba25
index 1246ba9..b43f02e 100755
26ba25
--- a/tests/docker/docker.py
26ba25
+++ b/tests/docker/docker.py
26ba25
@@ -11,6 +11,7 @@
26ba25
 # or (at your option) any later version. See the COPYING file in
26ba25
 # the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import os
26ba25
 import sys
26ba25
 sys.path.append(os.path.join(os.path.dirname(__file__),
26ba25
@@ -87,7 +88,7 @@ def _get_so_libs(executable):
26ba25
                 so_lib = search.groups()[1]
26ba25
                 libs.append("%s/%s" % (so_path, so_lib))
26ba25
     except subprocess.CalledProcessError:
26ba25
-        print "%s had no associated libraries (static build?)" % (executable)
26ba25
+        print("%s had no associated libraries (static build?)" % (executable))
26ba25
 
26ba25
     return libs
26ba25
 
26ba25
@@ -161,7 +162,7 @@ class Docker(object):
26ba25
                 continue
26ba25
             if only_known and instance_uuid not in self._instances:
26ba25
                 continue
26ba25
-            print "Terminating", i
26ba25
+            print("Terminating", i)
26ba25
             if active:
26ba25
                 self._do(["kill", i])
26ba25
             self._do(["rm", i])
26ba25
@@ -288,7 +289,7 @@ class BuildCommand(SubCommand):
26ba25
         if "--no-cache" not in argv and \
26ba25
            dkr.image_matches_dockerfile(tag, dockerfile):
26ba25
             if not args.quiet:
26ba25
-                print "Image is up to date."
26ba25
+                print("Image is up to date.")
26ba25
         else:
26ba25
             # Create a docker context directory for the build
26ba25
             docker_dir = tempfile.mkdtemp(prefix="docker_build")
26ba25
@@ -300,10 +301,10 @@ class BuildCommand(SubCommand):
26ba25
                 rc = subprocess.call(os.path.realpath(docker_pre),
26ba25
                                      cwd=docker_dir, stdout=stdout)
26ba25
                 if rc == 3:
26ba25
-                    print "Skip"
26ba25
+                    print("Skip")
26ba25
                     return 0
26ba25
                 elif rc != 0:
26ba25
-                    print "%s exited with code %d" % (docker_pre, rc)
26ba25
+                    print("%s exited with code %d" % (docker_pre, rc))
26ba25
                     return 1
26ba25
 
26ba25
             # Copy any extra files into the Docker context. These can be
26ba25
diff --git a/tests/docker/travis.py b/tests/docker/travis.py
26ba25
index 703a7fd..ea1ef16 100755
26ba25
--- a/tests/docker/travis.py
26ba25
+++ b/tests/docker/travis.py
26ba25
@@ -11,6 +11,7 @@
26ba25
 # or (at your option) any later version. See the COPYING file in
26ba25
 # the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import yaml
26ba25
 import itertools
26ba25
@@ -34,14 +35,14 @@ def main():
26ba25
         sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0])
26ba25
         return 1
26ba25
     conf = load_yaml(sys.argv[1])
26ba25
-    print "\n".join((": ${%s}" % var for var in conf["env"]["global"]))
26ba25
+    print("\n".join((": ${%s}" % var for var in conf["env"]["global"])))
26ba25
     for config in conf_iter(conf):
26ba25
-        print "("
26ba25
-        print "\n".join(config["env"])
26ba25
-        print "alias cc=" + config["compiler"]
26ba25
-        print "\n".join(conf["before_script"])
26ba25
-        print "\n".join(conf["script"])
26ba25
-        print ")"
26ba25
+        print("(")
26ba25
+        print("\n".join(config["env"]))
26ba25
+        print("alias cc=" + config["compiler"])
26ba25
+        print("\n".join(conf["before_script"]))
26ba25
+        print("\n".join(conf["script"]))
26ba25
+        print(")")
26ba25
     return 0
26ba25
 
26ba25
 if __name__ == "__main__":
26ba25
diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
26ba25
index 31ba6c9..474d2c5 100644
26ba25
--- a/tests/guest-debug/test-gdbstub.py
26ba25
+++ b/tests/guest-debug/test-gdbstub.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 #
26ba25
 # This script needs to be run on startup
26ba25
 # qemu -kernel ${KERNEL} -s -S
26ba25
diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py
26ba25
index 96a1c11..8de6569 100755
26ba25
--- a/tests/image-fuzzer/runner.py
26ba25
+++ b/tests/image-fuzzer/runner.py
26ba25
@@ -18,6 +18,7 @@
26ba25
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26ba25
 #
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import os
26ba25
 import signal
26ba25
@@ -36,9 +37,8 @@ except ImportError:
26ba25
     try:
26ba25
         import simplejson as json
26ba25
     except ImportError:
26ba25
-        print >>sys.stderr, \
26ba25
-            "Warning: Module for JSON processing is not found.\n" \
26ba25
-            "'--config' and '--command' options are not supported."
26ba25
+        print("Warning: Module for JSON processing is not found.\n" \
26ba25
+            "'--config' and '--command' options are not supported.", file=sys.stderr)
26ba25
 
26ba25
 # Backing file sizes in MB
26ba25
 MAX_BACKING_FILE_SIZE = 10
26ba25
@@ -158,9 +158,8 @@ class TestEnv(object):
26ba25
         try:
26ba25
             os.makedirs(self.current_dir)
26ba25
         except OSError as e:
26ba25
-            print >>sys.stderr, \
26ba25
-                "Error: The working directory '%s' cannot be used. Reason: %s"\
26ba25
-                % (self.work_dir, e[1])
26ba25
+            print("Error: The working directory '%s' cannot be used. Reason: %s"\
26ba25
+                % (self.work_dir, e[1]), file=sys.stderr)
26ba25
             raise TestException
26ba25
         self.log = open(os.path.join(self.current_dir, "test.log"), "w")
26ba25
         self.parent_log = open(run_log, "a")
26ba25
@@ -277,7 +276,7 @@ class TestEnv(object):
26ba25
 if __name__ == '__main__':
26ba25
 
26ba25
     def usage():
26ba25
-        print """
26ba25
+        print("""
26ba25
         Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR
26ba25
 
26ba25
         Set up test environment in TEST_DIR and run a test in it. A module for
26ba25
@@ -326,7 +325,7 @@ if __name__ == '__main__':
26ba25
 
26ba25
         If '--config' argument is specified, fields not listed in
26ba25
         the configuration array will not be fuzzed.
26ba25
-        """
26ba25
+        """)
26ba25
 
26ba25
     def run_test(test_id, seed, work_dir, run_log, cleanup, log_all,
26ba25
                  command, fuzz_config):
26ba25
@@ -357,8 +356,7 @@ if __name__ == '__main__':
26ba25
                                        ['command=', 'help', 'seed=', 'config=',
26ba25
                                         'keep_passed', 'verbose', 'duration='])
26ba25
     except getopt.error as e:
26ba25
-        print >>sys.stderr, \
26ba25
-            "Error: %s\n\nTry 'runner.py --help' for more information" % e
26ba25
+        print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     command = None
26ba25
@@ -375,9 +373,8 @@ if __name__ == '__main__':
26ba25
             try:
26ba25
                 command = json.loads(arg)
26ba25
             except (TypeError, ValueError, NameError) as e:
26ba25
-                print >>sys.stderr, \
26ba25
-                    "Error: JSON array of test commands cannot be loaded.\n" \
26ba25
-                    "Reason: %s" % e
26ba25
+                print("Error: JSON array of test commands cannot be loaded.\n" \
26ba25
+                    "Reason: %s" % e, file=sys.stderr)
26ba25
                 sys.exit(1)
26ba25
         elif opt in ('-k', '--keep_passed'):
26ba25
             cleanup = False
26ba25
@@ -391,15 +388,13 @@ if __name__ == '__main__':
26ba25
             try:
26ba25
                 config = json.loads(arg)
26ba25
             except (TypeError, ValueError, NameError) as e:
26ba25
-                print >>sys.stderr, \
26ba25
-                    "Error: JSON array with the fuzzer configuration cannot" \
26ba25
-                    " be loaded\nReason: %s" % e
26ba25
+                print("Error: JSON array with the fuzzer configuration cannot" \
26ba25
+                    " be loaded\nReason: %s" % e, file=sys.stderr)
26ba25
                 sys.exit(1)
26ba25
 
26ba25
     if not len(args) == 2:
26ba25
-        print >>sys.stderr, \
26ba25
-            "Expected two parameters\nTry 'runner.py --help'" \
26ba25
-            " for more information."
26ba25
+        print("Expected two parameters\nTry 'runner.py --help'" \
26ba25
+            " for more information.", file=sys.stderr)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     work_dir = os.path.realpath(args[0])
26ba25
@@ -415,9 +410,8 @@ if __name__ == '__main__':
26ba25
     try:
26ba25
         image_generator = __import__(generator_name)
26ba25
     except ImportError as e:
26ba25
-        print >>sys.stderr, \
26ba25
-            "Error: The image generator '%s' cannot be imported.\n" \
26ba25
-            "Reason: %s" % (generator_name, e)
26ba25
+        print("Error: The image generator '%s' cannot be imported.\n" \
26ba25
+            "Reason: %s" % (generator_name, e), file=sys.stderr)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     # Enable core dumps
26ba25
diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestperf/engine.py
26ba25
index e14d432..398e3f2 100644
26ba25
--- a/tests/migration/guestperf/engine.py
26ba25
+++ b/tests/migration/guestperf/engine.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 #
26ba25
 # Migration test main engine
26ba25
 #
26ba25
@@ -117,7 +118,7 @@ class Engine(object):
26ba25
         # XXX how to get dst timings on remote host ?
26ba25
 
26ba25
         if self._verbose:
26ba25
-            print "Sleeping %d seconds for initial guest workload run" % self._sleep
26ba25
+            print("Sleeping %d seconds for initial guest workload run" % self._sleep)
26ba25
         sleep_secs = self._sleep
26ba25
         while sleep_secs > 1:
26ba25
             src_qemu_time.append(self._cpu_timing(src_pid))
26ba25
@@ -126,7 +127,7 @@ class Engine(object):
26ba25
             sleep_secs -= 1
26ba25
 
26ba25
         if self._verbose:
26ba25
-            print "Starting migration"
26ba25
+            print("Starting migration")
26ba25
         if scenario._auto_converge:
26ba25
             resp = src.command("migrate-set-capabilities",
26ba25
                                capabilities = [
26ba25
@@ -216,7 +217,7 @@ class Engine(object):
26ba25
 
26ba25
                 if progress._status == "completed":
26ba25
                     if self._verbose:
26ba25
-                        print "Sleeping %d seconds for final guest workload run" % self._sleep
26ba25
+                        print("Sleeping %d seconds for final guest workload run" % self._sleep)
26ba25
                     sleep_secs = self._sleep
26ba25
                     while sleep_secs > 1:
26ba25
                         time.sleep(1)
26ba25
@@ -227,23 +228,23 @@ class Engine(object):
26ba25
                 return [progress_history, src_qemu_time, src_vcpu_time]
26ba25
 
26ba25
             if self._verbose and (loop % 20) == 0:
26ba25
-                print "Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % (
26ba25
+                print("Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % (
26ba25
                     progress._ram._iterations,
26ba25
                     progress._ram._remaining_bytes / (1024 * 1024),
26ba25
                     progress._ram._total_bytes / (1024 * 1024),
26ba25
                     progress._ram._transferred_bytes / (1024 * 1024),
26ba25
                     progress._ram._transfer_rate_mbs,
26ba25
-                )
26ba25
+                ))
26ba25
 
26ba25
             if progress._ram._iterations > scenario._max_iters:
26ba25
                 if self._verbose:
26ba25
-                    print "No completion after %d iterations over RAM" % scenario._max_iters
26ba25
+                    print("No completion after %d iterations over RAM" % scenario._max_iters)
26ba25
                 src.command("migrate_cancel")
26ba25
                 continue
26ba25
 
26ba25
             if time.time() > (start + scenario._max_time):
26ba25
                 if self._verbose:
26ba25
-                    print "No completion after %d seconds" % scenario._max_time
26ba25
+                    print("No completion after %d seconds" % scenario._max_time)
26ba25
                 src.command("migrate_cancel")
26ba25
                 continue
26ba25
 
26ba25
@@ -251,7 +252,7 @@ class Engine(object):
26ba25
                 progress._ram._iterations >= scenario._post_copy_iters and
26ba25
                 not post_copy):
26ba25
                 if self._verbose:
26ba25
-                    print "Switching to post-copy after %d iterations" % scenario._post_copy_iters
26ba25
+                    print("Switching to post-copy after %d iterations" % scenario._post_copy_iters)
26ba25
                 resp = src.command("migrate-start-postcopy")
26ba25
                 post_copy = True
26ba25
 
26ba25
@@ -259,7 +260,7 @@ class Engine(object):
26ba25
                 progress._ram._iterations >= scenario._pause_iters and
26ba25
                 not paused):
26ba25
                 if self._verbose:
26ba25
-                    print "Pausing VM after %d iterations" % scenario._pause_iters
26ba25
+                    print("Pausing VM after %d iterations" % scenario._pause_iters)
26ba25
                 resp = src.command("stop")
26ba25
                 paused = True
26ba25
 
26ba25
@@ -348,7 +349,7 @@ class Engine(object):
26ba25
         if not log:
26ba25
             return []
26ba25
         if self._debug:
26ba25
-            print log
26ba25
+            print(log)
26ba25
 
26ba25
         regex = r"[^\s]+\s\((\d+)\):\sINFO:\s(\d+)ms\scopied\s\d+\sGB\sin\s(\d+)ms"
26ba25
         matcher = re.compile(regex)
26ba25
@@ -407,7 +408,7 @@ class Engine(object):
26ba25
             if uri[0:5] == "unix:":
26ba25
                 os.remove(uri[5:])
26ba25
             if self._verbose:
26ba25
-                print "Finished migration"
26ba25
+                print("Finished migration")
26ba25
 
26ba25
             src.shutdown()
26ba25
             dst.shutdown()
26ba25
@@ -420,7 +421,7 @@ class Engine(object):
26ba25
                           self._initrd, self._transport, self._sleep)
26ba25
         except Exception as e:
26ba25
             if self._debug:
26ba25
-                print "Failed: %s" % str(e)
26ba25
+                print("Failed: %s" % str(e))
26ba25
             try:
26ba25
                 src.shutdown()
26ba25
             except:
26ba25
@@ -431,7 +432,7 @@ class Engine(object):
26ba25
                 pass
26ba25
 
26ba25
             if self._debug:
26ba25
-                print src.get_log()
26ba25
-                print dst.get_log()
26ba25
+                print(src.get_log())
26ba25
+                print(dst.get_log())
26ba25
             raise
26ba25
 
26ba25
diff --git a/tests/migration/guestperf/plot.py b/tests/migration/guestperf/plot.py
26ba25
index bc42249..aa98912 100644
26ba25
--- a/tests/migration/guestperf/plot.py
26ba25
+++ b/tests/migration/guestperf/plot.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 #
26ba25
 # Migration test graph plotting
26ba25
 #
26ba25
@@ -588,7 +589,7 @@ class Plot(object):
26ba25
 """
26ba25
 
26ba25
     def generate_html(self, fh):
26ba25
-        print >>fh, """<html>
26ba25
+        print("""<html>
26ba25
   <head>
26ba25
     <script type="text/javascript" src="plotly.min.js">
26ba25
     </script>
26ba25
@@ -601,19 +602,19 @@ class Plot(object):
26ba25
     

Migration report

26ba25
     

Chart summary

26ba25
     
26ba25
-""" % self._generate_style()
26ba25
-        print >>fh, self._generate_chart()
26ba25
-        print >>fh, """
26ba25
+""" % self._generate_style(), file=fh)
26ba25
+        print(self._generate_chart(), file=fh)
26ba25
+        print("""
26ba25
     
26ba25
     

Report details

26ba25
     
26ba25
-"""
26ba25
-        print >>fh, self._generate_report()
26ba25
-        print >>fh, """
26ba25
+""", file=fh)
26ba25
+        print(self._generate_report(), file=fh)
26ba25
+        print("""
26ba25
     
26ba25
   </body>
26ba25
 </html>
26ba25
-"""
26ba25
+""", file=fh)
26ba25
 
26ba25
     def generate(self, filename):
26ba25
         if filename is None:
26ba25
diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py
26ba25
index b272978..a6b8cec 100644
26ba25
--- a/tests/migration/guestperf/shell.py
26ba25
+++ b/tests/migration/guestperf/shell.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 #
26ba25
 # Migration test command line shell integration
26ba25
 #
26ba25
@@ -160,13 +161,13 @@ class Shell(BaseShell):
26ba25
         try:
26ba25
             report = engine.run(hardware, scenario)
26ba25
             if args.output is None:
26ba25
-                print report.to_json()
26ba25
+                print(report.to_json())
26ba25
             else:
26ba25
                 with open(args.output, "w") as fh:
26ba25
-                    print >>fh, report.to_json()
26ba25
+                    print(report.to_json(), file=fh)
26ba25
             return 0
26ba25
         except Exception as e:
26ba25
-            print >>sys.stderr, "Error: %s" % str(e)
26ba25
+            print("Error: %s" % str(e), file=sys.stderr)
26ba25
             if args.debug:
26ba25
                 raise
26ba25
             return 1
26ba25
@@ -199,11 +200,11 @@ class BatchShell(BaseShell):
26ba25
                     name = os.path.join(comparison._name, scenario._name)
26ba25
                     if not fnmatch.fnmatch(name, args.filter):
26ba25
                         if args.verbose:
26ba25
-                            print "Skipping %s" % name
26ba25
+                            print("Skipping %s" % name)
26ba25
                         continue
26ba25
 
26ba25
                     if args.verbose:
26ba25
-                        print "Running %s" % name
26ba25
+                        print("Running %s" % name)
26ba25
 
26ba25
                     dirname = os.path.join(args.output, comparison._name)
26ba25
                     filename = os.path.join(dirname, scenario._name + ".json")
26ba25
@@ -211,9 +212,9 @@ class BatchShell(BaseShell):
26ba25
                         os.makedirs(dirname)
26ba25
                     report = engine.run(hardware, scenario)
26ba25
                     with open(filename, "w") as fh:
26ba25
-                        print >>fh, report.to_json()
26ba25
+                        print(report.to_json(), file=fh)
26ba25
         except Exception as e:
26ba25
-            print >>sys.stderr, "Error: %s" % str(e)
26ba25
+            print("Error: %s" % str(e), file=sys.stderr)
26ba25
             if args.debug:
26ba25
                 raise
26ba25
 
26ba25
@@ -246,14 +247,14 @@ class PlotShell(object):
26ba25
 
26ba25
 
26ba25
         if len(args.reports) == 0:
26ba25
-            print >>sys.stderr, "At least one report required"
26ba25
+            print("At least one report required", file=sys.stderr)
26ba25
             return 1
26ba25
 
26ba25
         if not (args.qemu_cpu or
26ba25
                 args.vcpu_cpu or
26ba25
                 args.total_guest_cpu or
26ba25
                 args.split_guest_cpu):
26ba25
-            print >>sys.stderr, "At least one chart type is required"
26ba25
+            print("At least one chart type is required", file=sys.stderr)
26ba25
             return 1
26ba25
 
26ba25
         reports = []
26ba25
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
26ba25
index 223cd68..d3ffa25 100755
26ba25
--- a/tests/qemu-iotests/149
26ba25
+++ b/tests/qemu-iotests/149
26ba25
@@ -20,6 +20,7 @@
26ba25
 # Exercise the QEMU 'luks' block driver to validate interoperability
26ba25
 # with the Linux dm-crypt + cryptsetup implementation
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import subprocess
26ba25
 import os
26ba25
 import os.path
26ba25
@@ -376,7 +377,7 @@ def test_once(config, qemu_img=False):
26ba25
     finally:
26ba25
         iotests.log("# Delete image")
26ba25
         delete_image(config)
26ba25
-        print
26ba25
+        print()
26ba25
 
26ba25
 
26ba25
 # Obviously we only work with the luks image format
26ba25
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
26ba25
index 2936929..88f62d3 100755
26ba25
--- a/tests/qemu-iotests/165
26ba25
+++ b/tests/qemu-iotests/165
26ba25
@@ -18,6 +18,7 @@
26ba25
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26ba25
 #
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import os
26ba25
 import re
26ba25
 import iotests
26ba25
@@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
26ba25
         log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
26ba25
         log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
26ba25
         if log:
26ba25
-            print log
26ba25
+            print(log)
26ba25
 
26ba25
         self.vm = self.mkVm()
26ba25
         self.vm.launch()
26ba25
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
26ba25
index b25d48a..26e6046 100644
26ba25
--- a/tests/qemu-iotests/iotests.py
26ba25
+++ b/tests/qemu-iotests/iotests.py
26ba25
@@ -1,3 +1,4 @@
26ba25
+from __future__ import print_function
26ba25
 # Common utilities and Python wrappers for qemu-iotests
26ba25
 #
26ba25
 # Copyright (C) 2012 IBM Corp.
26ba25
@@ -209,7 +210,7 @@ def filter_qmp_event(event):
26ba25
 def log(msg, filters=[]):
26ba25
     for flt in filters:
26ba25
         msg = flt(msg)
26ba25
-    print msg
26ba25
+    print(msg)
26ba25
 
26ba25
 class Timeout:
26ba25
     def __init__(self, seconds, errmsg = "Timeout"):
26ba25
@@ -525,7 +526,7 @@ def notrun(reason):
26ba25
     seq = os.path.basename(sys.argv[0])
26ba25
 
26ba25
     open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
26ba25
-    print '%s not run: %s' % (seq, reason)
26ba25
+    print('%s not run: %s' % (seq, reason))
26ba25
     sys.exit(0)
26ba25
 
26ba25
 def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
26ba25
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
26ba25
index 8a04d97..f9193c0 100755
26ba25
--- a/tests/qemu-iotests/nbd-fault-injector.py
26ba25
+++ b/tests/qemu-iotests/nbd-fault-injector.py
26ba25
@@ -43,6 +43,7 @@
26ba25
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
26ba25
 # See the COPYING file in the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import socket
26ba25
 import struct
26ba25
@@ -110,7 +111,7 @@ class FaultInjectionSocket(object):
26ba25
         for rule in self.rules:
26ba25
             if rule.match(event, io):
26ba25
                 if rule.when == 0 or bufsize is None:
26ba25
-                    print 'Closing connection on rule match %s' % rule.name
26ba25
+                    print('Closing connection on rule match %s' % rule.name)
26ba25
                     sys.exit(0)
26ba25
                 if rule.when != -1:
26ba25
                     return rule.when
26ba25
@@ -182,7 +183,7 @@ def handle_connection(conn, use_export):
26ba25
         elif req.type == NBD_CMD_DISC:
26ba25
             break
26ba25
         else:
26ba25
-            print 'unrecognized command type %#02x' % req.type
26ba25
+            print('unrecognized command type %#02x' % req.type)
26ba25
             break
26ba25
     conn.close()
26ba25
 
26ba25
@@ -242,7 +243,7 @@ def open_socket(path):
26ba25
         sock = socket.socket(socket.AF_UNIX)
26ba25
         sock.bind(path)
26ba25
     sock.listen(0)
26ba25
-    print 'Listening on %s' % path
26ba25
+    print('Listening on %s' % path)
26ba25
     sys.stdout.flush() # another process may be waiting, show message now
26ba25
     return sock
26ba25
 
26ba25
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
26ba25
index 9cc4cf7..b95a837 100755
26ba25
--- a/tests/qemu-iotests/qcow2.py
26ba25
+++ b/tests/qemu-iotests/qcow2.py
26ba25
@@ -1,5 +1,6 @@
26ba25
 #!/usr/bin/env python
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import struct
26ba25
 import string
26ba25
@@ -129,8 +130,8 @@ class QcowHeader:
26ba25
 
26ba25
     def dump(self):
26ba25
         for f in QcowHeader.fields:
26ba25
-            print "%-25s" % f[2], f[1] % self.__dict__[f[2]]
26ba25
-        print ""
26ba25
+            print("%-25s" % f[2], f[1] % self.__dict__[f[2]])
26ba25
+        print("")
26ba25
 
26ba25
     def dump_extensions(self):
26ba25
         for ex in self.extensions:
26ba25
@@ -141,11 +142,11 @@ class QcowHeader:
26ba25
             else:
26ba25
                 data = "<binary>"
26ba25
 
26ba25
-            print "Header extension:"
26ba25
-            print "%-25s %#x" % ("magic", ex.magic)
26ba25
-            print "%-25s %d" % ("length", ex.length)
26ba25
-            print "%-25s %s" % ("data", data)
26ba25
-            print ""
26ba25
+            print("Header extension:")
26ba25
+            print("%-25s %#x" % ("magic", ex.magic))
26ba25
+            print("%-25s %d" % ("length", ex.length))
26ba25
+            print("%-25s %s" % ("data", data))
26ba25
+            print("")
26ba25
 
26ba25
 
26ba25
 def cmd_dump_header(fd):
26ba25
@@ -157,12 +158,12 @@ def cmd_set_header(fd, name, value):
26ba25
     try:
26ba25
         value = int(value, 0)
26ba25
     except:
26ba25
-        print "'%s' is not a valid number" % value
26ba25
+        print("'%s' is not a valid number" % value)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     fields = (field[2] for field in QcowHeader.fields)
26ba25
     if not name in fields:
26ba25
-        print "'%s' is not a known header field" % name
26ba25
+        print("'%s' is not a known header field" % name)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     h = QcowHeader(fd)
26ba25
@@ -173,7 +174,7 @@ def cmd_add_header_ext(fd, magic, data):
26ba25
     try:
26ba25
         magic = int(magic, 0)
26ba25
     except:
26ba25
-        print "'%s' is not a valid magic number" % magic
26ba25
+        print("'%s' is not a valid magic number" % magic)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     h = QcowHeader(fd)
26ba25
@@ -188,7 +189,7 @@ def cmd_del_header_ext(fd, magic):
26ba25
     try:
26ba25
         magic = int(magic, 0)
26ba25
     except:
26ba25
-        print "'%s' is not a valid magic number" % magic
26ba25
+        print("'%s' is not a valid magic number" % magic)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     h = QcowHeader(fd)
26ba25
@@ -200,7 +201,7 @@ def cmd_del_header_ext(fd, magic):
26ba25
             h.extensions.remove(ex)
26ba25
 
26ba25
     if not found:
26ba25
-        print "No such header extension"
26ba25
+        print("No such header extension")
26ba25
         return
26ba25
 
26ba25
     h.update(fd)
26ba25
@@ -211,7 +212,7 @@ def cmd_set_feature_bit(fd, group, bit):
26ba25
         if bit < 0 or bit >= 64:
26ba25
             raise ValueError
26ba25
     except:
26ba25
-        print "'%s' is not a valid bit number in range [0, 64)" % bit
26ba25
+        print("'%s' is not a valid bit number in range [0, 64)" % bit)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     h = QcowHeader(fd)
26ba25
@@ -222,7 +223,7 @@ def cmd_set_feature_bit(fd, group, bit):
26ba25
     elif group == 'autoclear':
26ba25
         h.autoclear_features |= 1 << bit
26ba25
     else:
26ba25
-        print "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group
26ba25
+        print("'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group)
26ba25
         sys.exit(1)
26ba25
 
26ba25
     h.update(fd)
26ba25
@@ -248,16 +249,16 @@ def main(filename, cmd, args):
26ba25
             else:
26ba25
                 handler(fd, *args)
26ba25
                 return
26ba25
-        print "Unknown command '%s'" % cmd
26ba25
+        print("Unknown command '%s'" % cmd)
26ba25
     finally:
26ba25
         fd.close()
26ba25
 
26ba25
 def usage():
26ba25
-    print "Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0]
26ba25
-    print ""
26ba25
-    print "Supported commands:"
26ba25
+    print("Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0])
26ba25
+    print("")
26ba25
+    print("Supported commands:")
26ba25
     for name, handler, num_args, desc in cmds:
26ba25
-        print "    %-20s - %s" % (name, desc)
26ba25
+        print("    %-20s - %s" % (name, desc))
26ba25
 
26ba25
 if __name__ == '__main__':
26ba25
     if len(sys.argv) < 3:
26ba25
diff --git a/tests/qemu-iotests/qed.py b/tests/qemu-iotests/qed.py
26ba25
index 748068d..ea469b9 100755
26ba25
--- a/tests/qemu-iotests/qed.py
26ba25
+++ b/tests/qemu-iotests/qed.py
26ba25
@@ -10,6 +10,7 @@
26ba25
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
26ba25
 # See the COPYING file in the top-level directory.
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import sys
26ba25
 import struct
26ba25
 import random
26ba25
@@ -108,12 +109,12 @@ def corrupt_table_invalidate(qed, table):
26ba25
 def cmd_show(qed, *args):
26ba25
     '''show [header|l1|l2 <offset>]- Show header or l1/l2 tables'''
26ba25
     if not args or args[0] == 'header':
26ba25
-        print qed.header
26ba25
+        print(qed.header)
26ba25
     elif args[0] == 'l1':
26ba25
-        print qed.l1_table
26ba25
+        print(qed.l1_table)
26ba25
     elif len(args) == 2 and args[0] == 'l2':
26ba25
         offset = int(args[1])
26ba25
-        print qed.read_table(offset)
26ba25
+        print(qed.read_table(offset))
26ba25
     else:
26ba25
         err('unrecognized sub-command')
26ba25
 
26ba25
@@ -146,7 +147,7 @@ def cmd_invalidate(qed, table_level):
26ba25
 def cmd_need_check(qed, *args):
26ba25
     '''need-check [on|off] - Test, set, or clear the QED_F_NEED_CHECK header bit'''
26ba25
     if not args:
26ba25
-        print bool(qed.header['features'] & QED_F_NEED_CHECK)
26ba25
+        print(bool(qed.header['features'] & QED_F_NEED_CHECK))
26ba25
         return
26ba25
 
26ba25
     if args[0] == 'on':
26ba25
@@ -208,11 +209,11 @@ def cmd_copy_metadata(qed, outfile):
26ba25
     out.close()
26ba25
 
26ba25
 def usage():
26ba25
-    print 'Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0]
26ba25
-    print
26ba25
-    print 'Supported commands:'
26ba25
+    print('Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0])
26ba25
+    print()
26ba25
+    print('Supported commands:')
26ba25
     for cmd in sorted(x for x in globals() if x.startswith('cmd_')):
26ba25
-        print globals()[cmd].__doc__
26ba25
+        print(globals()[cmd].__doc__)
26ba25
     sys.exit(1)
26ba25
 
26ba25
 def main():
26ba25
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
26ba25
index 3a2d508..3643117 100755
26ba25
--- a/tests/vm/basevm.py
26ba25
+++ b/tests/vm/basevm.py
26ba25
@@ -11,6 +11,7 @@
26ba25
 # the COPYING file in the top-level directory.
26ba25
 #
26ba25
 
26ba25
+from __future__ import print_function
26ba25
 import os
26ba25
 import sys
26ba25
 import logging
26ba25
@@ -222,7 +223,7 @@ def main(vmcls):
26ba25
     try:
26ba25
         args, argv = parse_args(vmcls.name)
26ba25
         if not argv and not args.build_qemu and not args.build_image:
26ba25
-            print "Nothing to do?"
26ba25
+            print("Nothing to do?")
26ba25
             return 1
26ba25
         logging.basicConfig(level=(logging.DEBUG if args.debug
26ba25
                                    else logging.WARN))
26ba25
-- 
26ba25
1.8.3.1
26ba25