summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2020-02-10 13:07:26 +0100
committerPeter Maydell2020-02-10 13:07:26 +0100
commit73d336510cf118fcc2ee7e98e774a193cf661614 (patch)
treef2f147fd31878ca2c21a16b9b5d2723ae4db7b6d
parentMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200207'... (diff)
parent.readthedocs.yml: specify some minimum python requirements (diff)
downloadqemu-73d336510cf118fcc2ee7e98e774a193cf661614.tar.gz
qemu-73d336510cf118fcc2ee7e98e774a193cf661614.tar.xz
qemu-73d336510cf118fcc2ee7e98e774a193cf661614.zip
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/python-next-20200207' into staging
- Python 3 cleanups: . Remove text about Python 2 in qemu-deprecated (Thomas) . Remove shebang header (Paolo, Philippe) . scripts/checkpatch.pl now allows Python 3 interpreter (Philippe) . Explicit usage of Python 3 interpreter in scripts (Philippe) . Fix Python scripts permissions (Paolo, Philippe) . Drop 'from __future__ import print_function' (Paolo) . Specify minimum python requirements in ReadTheDocs configuration (Alex) - Test UNIX/EXEC transports with migration (Oksana) - Added extract_from_rpm helper, improved extract_from_deb (Liam) - Allow to use other serial consoles than default one (Philippe) - Various improvements in QEMUMonitorProtocol (Wainer) - Fix kvm_available() on ppc64le (Wainer) # gpg: Signature made Fri 07 Feb 2020 15:01:56 GMT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * remotes/philmd-gitlab/tags/python-next-20200207: (46 commits) .readthedocs.yml: specify some minimum python requirements drop "from __future__ import print_function" make all Python scripts executable scripts/signrom: remove Python 2 support, add shebang tests/qemu-iotests/check: Only check for Python 3 interpreter scripts: Explicit usage of Python 3 (scripts without __main__) tests/qemu-iotests: Explicit usage of Python3 (scripts without __main__) tests/vm: Remove shebang header tests/acceptance: Remove shebang header scripts/tracetool: Remove shebang header scripts/minikconf: Explicit usage of Python 3 scripts: Explicit usage of Python 3 (scripts with __main__) tests: Explicit usage of Python 3 tests/qemu-iotests: Explicit usage of Python 3 (scripts with __main__) tests/qemu-iotests/check: Allow use of python3 interpreter scripts/checkpatch.pl: Only allow Python 3 interpreter tests/acceptance/migration: Default to -nodefaults tests/acceptance/migration: Add the 'migration' tag tests/acceptance/migration: Test EXEC transport when migrating tests/acceptance/migration: Test UNIX transport when migrating ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--.readthedocs.yml20
-rw-r--r--.travis.yml3
-rw-r--r--python/qemu/accel.py3
-rw-r--r--python/qemu/machine.py10
-rw-r--r--python/qemu/qmp.py99
-rw-r--r--qemu-deprecated.texi8
-rwxr-xr-xscripts/analyse-9p-simpletrace.py3
-rwxr-xr-xscripts/analyse-locks-simpletrace.py3
-rwxr-xr-xscripts/checkpatch.pl6
-rwxr-xr-xscripts/decodetree.py2
-rwxr-xr-xscripts/device-crash-test3
-rw-r--r--scripts/dump-guest-memory.py1
-rwxr-xr-xscripts/kvm/kvm_flightrecorder3
-rwxr-xr-xscripts/kvm/vmxcap1
-rwxr-xr-x[-rw-r--r--]scripts/minikconf.py2
-rw-r--r--scripts/modules/module_block.py1
-rwxr-xr-xscripts/qapi-gen.py3
-rw-r--r--scripts/qapi/doc.py1
-rwxr-xr-xscripts/qmp/qemu-ga-client3
-rwxr-xr-xscripts/qmp/qmp3
-rwxr-xr-xscripts/qmp/qmp-shell3
-rwxr-xr-xscripts/qmp/qom-fuse2
-rwxr-xr-xscripts/qmp/qom-get1
-rwxr-xr-xscripts/qmp/qom-list1
-rwxr-xr-xscripts/qmp/qom-set1
-rwxr-xr-xscripts/qmp/qom-tree1
-rwxr-xr-xscripts/render_block_graph.py2
-rwxr-xr-xscripts/replay-dump.py3
-rwxr-xr-x[-rw-r--r--]scripts/signrom.py13
-rwxr-xr-xscripts/simpletrace.py3
-rwxr-xr-xscripts/tracetool.py2
-rw-r--r--scripts/tracetool/__init__.py1
-rw-r--r--scripts/tracetool/backend/__init__.py1
-rw-r--r--scripts/tracetool/backend/dtrace.py1
-rw-r--r--scripts/tracetool/backend/ftrace.py1
-rw-r--r--scripts/tracetool/backend/log.py1
-rw-r--r--scripts/tracetool/backend/simple.py1
-rw-r--r--scripts/tracetool/backend/syslog.py1
-rw-r--r--scripts/tracetool/backend/ust.py1
-rw-r--r--scripts/tracetool/format/__init__.py1
-rw-r--r--scripts/tracetool/format/c.py1
-rw-r--r--scripts/tracetool/format/d.py1
-rw-r--r--scripts/tracetool/format/h.py1
-rw-r--r--scripts/tracetool/format/log_stap.py1
-rw-r--r--scripts/tracetool/format/simpletrace_stap.py1
-rw-r--r--scripts/tracetool/format/stap.py1
-rw-r--r--scripts/tracetool/format/tcg_h.py1
-rw-r--r--scripts/tracetool/format/tcg_helper_c.py1
-rw-r--r--scripts/tracetool/format/tcg_helper_h.py1
-rw-r--r--scripts/tracetool/format/tcg_helper_wrapper_h.py1
-rw-r--r--scripts/tracetool/format/ust_events_c.py1
-rw-r--r--scripts/tracetool/format/ust_events_h.py1
-rw-r--r--scripts/tracetool/transform.py1
-rw-r--r--scripts/tracetool/vcpu.py1
-rwxr-xr-xscripts/vmstate-static-checker.py3
-rw-r--r--tests/acceptance/avocado_qemu/__init__.py59
-rw-r--r--tests/acceptance/boot_linux_console.py124
-rw-r--r--tests/acceptance/migration.py57
-rw-r--r--tests/acceptance/version.py1
-rw-r--r--[-rwxr-xr-x]tests/acceptance/virtio_check_params.py (renamed from tests/acceptance/virtio_seg_max_adjust.py)16
-rw-r--r--tests/acceptance/x86_cpu_model_versions.py1
-rwxr-xr-xtests/docker/travis.py3
-rw-r--r--tests/guest-debug/test-gdbstub.py1
-rw-r--r--tests/migration/guestperf/engine.py1
-rw-r--r--tests/migration/guestperf/plot.py1
-rw-r--r--tests/migration/guestperf/shell.py1
-rwxr-xr-xtests/qapi-schema/test-qapi.py3
-rwxr-xr-xtests/qemu-iotests/0302
-rwxr-xr-xtests/qemu-iotests/0402
-rwxr-xr-xtests/qemu-iotests/0412
-rwxr-xr-xtests/qemu-iotests/0442
-rwxr-xr-xtests/qemu-iotests/0452
-rwxr-xr-xtests/qemu-iotests/0552
-rwxr-xr-xtests/qemu-iotests/0562
-rwxr-xr-xtests/qemu-iotests/0572
-rwxr-xr-xtests/qemu-iotests/0652
-rwxr-xr-xtests/qemu-iotests/0932
-rwxr-xr-xtests/qemu-iotests/0962
-rwxr-xr-xtests/qemu-iotests/1182
-rwxr-xr-xtests/qemu-iotests/1242
-rwxr-xr-xtests/qemu-iotests/1292
-rwxr-xr-xtests/qemu-iotests/1322
-rwxr-xr-xtests/qemu-iotests/1362
-rwxr-xr-xtests/qemu-iotests/1392
-rwxr-xr-xtests/qemu-iotests/1472
-rwxr-xr-xtests/qemu-iotests/1482
-rwxr-xr-xtests/qemu-iotests/1493
-rwxr-xr-xtests/qemu-iotests/1512
-rwxr-xr-xtests/qemu-iotests/1522
-rwxr-xr-xtests/qemu-iotests/1552
-rwxr-xr-xtests/qemu-iotests/1632
-rwxr-xr-xtests/qemu-iotests/1653
-rwxr-xr-xtests/qemu-iotests/1692
-rwxr-xr-xtests/qemu-iotests/1942
-rwxr-xr-xtests/qemu-iotests/1962
-rwxr-xr-xtests/qemu-iotests/1992
-rwxr-xr-xtests/qemu-iotests/2022
-rwxr-xr-xtests/qemu-iotests/2032
-rwxr-xr-xtests/qemu-iotests/2052
-rwxr-xr-xtests/qemu-iotests/2062
-rwxr-xr-xtests/qemu-iotests/2072
-rwxr-xr-xtests/qemu-iotests/2082
-rwxr-xr-xtests/qemu-iotests/2092
-rwxr-xr-xtests/qemu-iotests/2102
-rwxr-xr-xtests/qemu-iotests/2112
-rwxr-xr-xtests/qemu-iotests/2122
-rwxr-xr-xtests/qemu-iotests/2132
-rwxr-xr-xtests/qemu-iotests/2162
-rwxr-xr-xtests/qemu-iotests/2182
-rwxr-xr-xtests/qemu-iotests/2192
-rwxr-xr-x[-rw-r--r--]tests/qemu-iotests/2222
-rwxr-xr-xtests/qemu-iotests/2242
-rwxr-xr-xtests/qemu-iotests/2282
-rwxr-xr-xtests/qemu-iotests/2342
-rwxr-xr-xtests/qemu-iotests/2352
-rwxr-xr-xtests/qemu-iotests/2362
-rwxr-xr-xtests/qemu-iotests/2372
-rwxr-xr-xtests/qemu-iotests/2382
-rwxr-xr-xtests/qemu-iotests/2422
-rwxr-xr-x[-rw-r--r--]tests/qemu-iotests/2452
-rwxr-xr-xtests/qemu-iotests/2462
-rwxr-xr-xtests/qemu-iotests/2482
-rwxr-xr-xtests/qemu-iotests/2542
-rwxr-xr-xtests/qemu-iotests/2552
-rwxr-xr-xtests/qemu-iotests/2562
-rwxr-xr-xtests/qemu-iotests/2572
-rwxr-xr-xtests/qemu-iotests/2582
-rwxr-xr-xtests/qemu-iotests/2602
-rwxr-xr-xtests/qemu-iotests/2622
-rwxr-xr-xtests/qemu-iotests/2642
-rwxr-xr-xtests/qemu-iotests/2662
-rwxr-xr-xtests/qemu-iotests/2772
-rwxr-xr-xtests/qemu-iotests/2802
-rwxr-xr-xtests/qemu-iotests/2812
-rw-r--r--tests/qemu-iotests/2832
-rwxr-xr-xtests/qemu-iotests/check2
-rw-r--r--tests/qemu-iotests/iotests.py1
-rwxr-xr-xtests/qemu-iotests/nbd-fault-injector.py3
-rwxr-xr-xtests/qemu-iotests/qcow2.py3
-rwxr-xr-xtests/qemu-iotests/qed.py3
-rw-r--r--[-rwxr-xr-x]tests/vm/basevm.py2
-rwxr-xr-xtests/vm/centos2
-rwxr-xr-xtests/vm/fedora2
-rwxr-xr-xtests/vm/freebsd2
-rwxr-xr-xtests/vm/netbsd2
-rwxr-xr-xtests/vm/openbsd2
-rwxr-xr-xtests/vm/ubuntu.i3862
147 files changed, 433 insertions, 235 deletions
diff --git a/.readthedocs.yml b/.readthedocs.yml
new file mode 100644
index 0000000000..8355dbc634
--- /dev/null
+++ b/.readthedocs.yml
@@ -0,0 +1,20 @@
+# .readthedocs.yml
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+# Build documentation in the docs/ directory with Sphinx
+sphinx:
+ configuration: docs/conf.py
+
+# We want all the document formats
+formats: all
+
+# For consistency, we require that QEMU's Sphinx extensions
+# run with at least the same minimum version of Python that
+# we require for other Python in our codebase (our conf.py
+# enforces this, and some code needs it.)
+python:
+ version: 3.5
diff --git a/.travis.yml b/.travis.yml
index 6c0ec6cf69..5887055951 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -313,7 +313,7 @@ matrix:
# Acceptance (Functional) tests
- name: "GCC check-acceptance"
env:
- - CONFIG="--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu"
+ - CONFIG="--target-list=aarch64-softmmu,alpha-softmmu,arm-softmmu,m68k-softmmu,microblaze-softmmu,mips-softmmu,mips64el-softmmu,nios2-softmmu,or1k-softmmu,ppc-softmmu,ppc64-softmmu,s390x-softmmu,sparc-softmmu,x86_64-softmmu,xtensa-softmmu"
- TEST_CMD="make check-acceptance"
after_script:
- python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP")]' | xargs cat
@@ -323,6 +323,7 @@ matrix:
- python3-pil
- python3-pip
- python3.5-venv
+ - rpm2cpio
- tesseract-ocr
- tesseract-ocr-eng
diff --git a/python/qemu/accel.py b/python/qemu/accel.py
index 0b38ddf0ab..36ae85791e 100644
--- a/python/qemu/accel.py
+++ b/python/qemu/accel.py
@@ -24,7 +24,8 @@ LOG = logging.getLogger(__name__)
# support which often includes its 32 bit cousin.
ADDITIONAL_ARCHES = {
"x86_64" : "i386",
- "aarch64" : "armhf"
+ "aarch64" : "armhf",
+ "ppc64le" : "ppc64",
}
def list_accel(qemu_bin):
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 734efd8536..183d8f3d38 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -112,6 +112,7 @@ class QEMUMachine(object):
self._sock_dir = sock_dir
self._launched = False
self._machine = None
+ self._console_index = 0
self._console_set = False
self._console_device_type = None
self._console_address = None
@@ -241,6 +242,8 @@ class QEMUMachine(object):
'chardev=mon,mode=control'])
if self._machine is not None:
args.extend(['-machine', self._machine])
+ for i in range(self._console_index):
+ args.extend(['-serial', 'null'])
if self._console_set:
self._console_address = os.path.join(self._sock_dir,
self._name + "-console.sock")
@@ -527,7 +530,7 @@ class QEMUMachine(object):
"""
self._machine = machine_type
- def set_console(self, device_type=None):
+ def set_console(self, device_type=None, console_index=0):
"""
Sets the device type for a console device
@@ -548,9 +551,14 @@ class QEMUMachine(object):
chardev:console" command line argument will
be used instead, resorting to the machine's
default device type.
+ @param console_index: the index of the console device to use.
+ If not zero, the command line will create
+ 'index - 1' consoles and connect them to
+ the 'null' backing character device.
"""
self._console_set = True
self._console_device_type = device_type
+ self._console_index = console_index
@property
def console_socket(self):
diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py
index 5c8cf6a056..f40586eedd 100644
--- a/python/qemu/qmp.py
+++ b/python/qemu/qmp.py
@@ -1,5 +1,4 @@
-# QEMU Monitor Protocol Python class
-#
+""" QEMU Monitor Protocol Python class """
# Copyright (C) 2009, 2010 Red Hat Inc.
#
# Authors:
@@ -15,29 +14,37 @@ import logging
class QMPError(Exception):
- pass
+ """
+ QMP base exception
+ """
class QMPConnectError(QMPError):
- pass
+ """
+ QMP connection exception
+ """
class QMPCapabilitiesError(QMPError):
- pass
+ """
+ QMP negotiate capabilities exception
+ """
class QMPTimeoutError(QMPError):
- pass
+ """
+ QMP timeout exception
+ """
-class QEMUMonitorProtocol(object):
+class QEMUMonitorProtocol:
+ """
+ Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and then
+ allow to handle commands and events.
+ """
#: Logger object for debugging messages
logger = logging.getLogger('QMP')
- #: Socket's error class
- error = socket.error
- #: Socket's timeout
- timeout = socket.timeout
def __init__(self, address, server=False):
"""
@@ -47,7 +54,7 @@ class QEMUMonitorProtocol(object):
or a tuple in the form ( address, port ) for a TCP
connection
@param server: server mode listens on the socket (bool)
- @raise socket.error on socket connection errors
+ @raise OSError on socket connection errors
@note No connection is established, this is done by the connect() or
accept() methods
"""
@@ -73,7 +80,7 @@ class QEMUMonitorProtocol(object):
raise QMPConnectError
# Greeting seems ok, negotiate capabilities
resp = self.cmd('qmp_capabilities')
- if "return" in resp:
+ if resp and "return" in resp:
return greeting
raise QMPCapabilitiesError
@@ -81,7 +88,7 @@ class QEMUMonitorProtocol(object):
while True:
data = self.__sockfile.readline()
if not data:
- return
+ return None
resp = json.loads(data)
if 'event' in resp:
self.logger.debug("<<< %s", resp)
@@ -107,8 +114,8 @@ class QEMUMonitorProtocol(object):
self.__sock.setblocking(0)
try:
self.__json_read()
- except socket.error as err:
- if err[0] == errno.EAGAIN:
+ except OSError as err:
+ if err.errno == errno.EAGAIN:
# No data available
pass
self.__sock.setblocking(1)
@@ -128,12 +135,21 @@ class QEMUMonitorProtocol(object):
raise QMPConnectError("Error while reading from socket")
self.__sock.settimeout(None)
+ def __enter__(self):
+ # Implement context manager enter function.
+ return self
+
+ def __exit__(self, exc_type, exc_value, exc_traceback):
+ # Implement context manager exit function.
+ self.close()
+ return False
+
def connect(self, negotiate=True):
"""
Connect to the QMP Monitor and perform capabilities negotiation.
- @return QMP greeting dict
- @raise socket.error on socket connection errors
+ @return QMP greeting dict, or None if negotiate is false
+ @raise OSError on socket connection errors
@raise QMPConnectError if the greeting is not received
@raise QMPCapabilitiesError if fails to negotiate capabilities
"""
@@ -141,17 +157,25 @@ class QEMUMonitorProtocol(object):
self.__sockfile = self.__sock.makefile()
if negotiate:
return self.__negotiate_capabilities()
+ return None
- def accept(self):
+ def accept(self, timeout=15.0):
"""
Await connection from QMP Monitor and perform capabilities negotiation.
+ @param timeout: timeout in seconds (nonnegative float number, or
+ None). The value passed will set the behavior of the
+ underneath QMP socket as described in [1]. Default value
+ is set to 15.0.
@return QMP greeting dict
- @raise socket.error on socket connection errors
+ @raise OSError on socket connection errors
@raise QMPConnectError if the greeting is not received
@raise QMPCapabilitiesError if fails to negotiate capabilities
+
+ [1]
+ https://docs.python.org/3/library/socket.html#socket.socket.settimeout
"""
- self.__sock.settimeout(15)
+ self.__sock.settimeout(timeout)
self.__sock, _ = self.__sock.accept()
self.__sockfile = self.__sock.makefile()
return self.__negotiate_capabilities()
@@ -167,10 +191,10 @@ class QEMUMonitorProtocol(object):
self.logger.debug(">>> %s", qmp_cmd)
try:
self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8'))
- except socket.error as err:
- if err[0] == errno.EPIPE:
- return
- raise socket.error(err)
+ except OSError as err:
+ if err.errno == errno.EPIPE:
+ return None
+ raise err
resp = self.__json_read()
self.logger.debug("<<< %s", resp)
return resp
@@ -243,14 +267,35 @@ class QEMUMonitorProtocol(object):
self.__events = []
def close(self):
- self.__sock.close()
- self.__sockfile.close()
+ """
+ Close the socket and socket file.
+ """
+ if self.__sock:
+ self.__sock.close()
+ if self.__sockfile:
+ self.__sockfile.close()
def settimeout(self, timeout):
+ """
+ Set the socket timeout.
+
+ @param timeout (float): timeout in seconds, or None.
+ @note This is a wrap around socket.settimeout
+ """
self.__sock.settimeout(timeout)
def get_sock_fd(self):
+ """
+ Get the socket file descriptor.
+
+ @return The file descriptor number.
+ """
return self.__sock.fileno()
def is_scm_available(self):
+ """
+ Check if the socket allows for SCM_RIGHTS.
+
+ @return True if SCM_RIGHTS is available, otherwise False.
+ """
return self.__sock.family == socket.AF_UNIX
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 2634e00ec8..017b750ca8 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -320,14 +320,6 @@ they have no effect when used with @option{-n} to skip image creation.
Silently ignored options can be confusing, so this combination of
options will be made an error in future versions.
-@section Build system
-
-@subsection Python 2 support (since 4.1.0)
-
-In the future, QEMU will require Python 3 to be available at
-build time. Support for Python 2 in scripts shipped with QEMU
-is deprecated.
-
@section Backwards compatibility
@subsection Runnability guarantee of CPU models (since 4.1.0)
diff --git a/scripts/analyse-9p-simpletrace.py b/scripts/analyse-9p-simpletrace.py
index 710e01adba..7dfcb6ba2f 100755
--- a/scripts/analyse-9p-simpletrace.py
+++ b/scripts/analyse-9p-simpletrace.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Pretty print 9p simpletrace log
# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
#
# Author: Harsh Prateek Bora
-from __future__ import print_function
import os
import simpletrace
diff --git a/scripts/analyse-locks-simpletrace.py b/scripts/analyse-locks-simpletrace.py
index 7d9b574300..63c11f4fce 100755
--- a/scripts/analyse-locks-simpletrace.py
+++ b/scripts/analyse-locks-simpletrace.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Analyse lock events and compute statistics
@@ -6,7 +6,6 @@
# Author: Alex Bennée <alex.bennee@linaro.org>
#
-from __future__ import print_function
import simpletrace
import argparse
import numpy as np
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3aef6e3dfe..ce43a306f8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1460,6 +1460,12 @@ sub process {
}
}
+# Only allow Python 3 interpreter
+ if ($realline == 1 &&
+ $line =~ /^\+#!\ *\/usr\/bin\/(?:env )?python$/) {
+ ERROR("please use python3 interpreter\n" . $herecurr);
+ }
+
# Accept git diff extended headers as valid patches
if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) {
$is_patch = 1;
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index d8c59cab60..2a8f2b6e06 100755
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (c) 2018 Linaro Limited
#
# This library is free software; you can redistribute it and/or
diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index 15f213a6cd..305d0427af 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (c) 2017 Red Hat Inc
#
@@ -23,7 +23,6 @@
Run QEMU with all combinations of -machine and -device types,
check for crashes and unexpected errors.
"""
-from __future__ import print_function
import os
import sys
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 9371e45813..4177261d33 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -12,7 +12,6 @@ Authors:
This work is licensed under the terms of the GNU GPL, version 2 or later. See
the COPYING file in the top-level directory.
"""
-from __future__ import print_function
import ctypes
import struct
diff --git a/scripts/kvm/kvm_flightrecorder b/scripts/kvm/kvm_flightrecorder
index 54a56745e4..78ca3af9c4 100755
--- a/scripts/kvm/kvm_flightrecorder
+++ b/scripts/kvm/kvm_flightrecorder
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# KVM Flight Recorder - ring buffer tracing script
#
@@ -32,7 +32,6 @@
# consuming CPU cycles. No disk I/O is performed since the ring buffer holds a
# fixed-size in-memory trace.
-from __future__ import print_function
import sys
import os
diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap
index 5dfeb2e03a..971ed0e721 100755
--- a/scripts/kvm/vmxcap
+++ b/scripts/kvm/vmxcap
@@ -10,7 +10,6 @@
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
-from __future__ import print_function
MSR_IA32_VMX_BASIC = 0x480
MSR_IA32_VMX_PINBASED_CTLS = 0x481
MSR_IA32_VMX_PROCBASED_CTLS = 0x482
diff --git a/scripts/minikconf.py b/scripts/minikconf.py
index 40ae1989e1..2f9647d0fa 100644..100755
--- a/scripts/minikconf.py
+++ b/scripts/minikconf.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Mini-Kconfig parser
#
@@ -10,7 +11,6 @@
# or, at your option, any later version. See the COPYING file in
# the top-level directory.
-from __future__ import print_function
import os
import sys
import re
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index 08646af92c..f23191fac1 100644
--- a/scripts/modules/module_block.py
+++ b/scripts/modules/module_block.py
@@ -10,7 +10,6 @@
# This work is licensed under the terms of the GNU GPL, version 2.
# See the COPYING file in the top-level directory.
-from __future__ import print_function
import sys
import os
diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
index f93f3c7c23..4b03f7d53b 100755
--- a/scripts/qapi-gen.py
+++ b/scripts/qapi-gen.py
@@ -1,10 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# QAPI generator
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
-from __future__ import print_function
import argparse
import re
diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 6f1c17f71f..1787a53d91 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -4,7 +4,6 @@
# See the COPYING file in the top-level directory.
"""This script produces the documentation of a qapi schema in texinfo format"""
-from __future__ import print_function
import re
from qapi.gen import QAPIGenDoc, QAPISchemaVisitor
diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client
index 30cf8a9a0d..ce122984a9 100755
--- a/scripts/qmp/qemu-ga-client
+++ b/scripts/qmp/qemu-ga-client
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
# QEMU Guest Agent Client
#
@@ -36,7 +36,6 @@
# See also: https://wiki.qemu.org/Features/QAPI/GuestAgent
#
-from __future__ import print_function
import os
import sys
import base64
diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp
index 6cb46fdae2..0625fc2aba 100755
--- a/scripts/qmp/qmp
+++ b/scripts/qmp/qmp
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# QMP command line tool
#
@@ -10,7 +10,6 @@
# This work is licensed under the terms of the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
-from __future__ import print_function
import sys, os
from qmp import QEMUMonitorProtocol
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index f1cddeafbc..a01d31de1e 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Low-level QEMU shell on top of QMP.
#
@@ -65,7 +65,6 @@
# which will echo back the properly formatted JSON-compliant QMP that is being
# sent to QEMU, which is useful for debugging and documentation generation.
-from __future__ import print_function
import json
import ast
import readline
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index 4d85970a78..6bada2c33d 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
##
# QEMU Object Model test tools
#
diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
index ec5275d53a..007b4cd442 100755
--- a/scripts/qmp/qom-get
+++ b/scripts/qmp/qom-get
@@ -11,7 +11,6 @@
# the COPYING file in the top-level directory.
##
-from __future__ import print_function
import sys
import os
from qmp import QEMUMonitorProtocol
diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
index 0f97440973..03bda3446b 100755
--- a/scripts/qmp/qom-list
+++ b/scripts/qmp/qom-list
@@ -11,7 +11,6 @@
# the COPYING file in the top-level directory.
##
-from __future__ import print_function
import sys
import os
from qmp import QEMUMonitorProtocol
diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
index 26ed9e3263..c37fe78b00 100755
--- a/scripts/qmp/qom-set
+++ b/scripts/qmp/qom-set
@@ -11,7 +11,6 @@
# the COPYING file in the top-level directory.
##
-from __future__ import print_function
import sys
import os
from qmp import QEMUMonitorProtocol
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
index 31603c681f..1c8acf61e7 100755
--- a/scripts/qmp/qom-tree
+++ b/scripts/qmp/qom-tree
@@ -13,7 +13,6 @@
# the COPYING file in the top-level directory.
##
-from __future__ import print_function
import sys
import os
from qmp import QEMUMonitorProtocol
diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py
index 656f0388ad..409b4321f2 100755
--- a/scripts/render_block_graph.py
+++ b/scripts/render_block_graph.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Render Qemu Block Graph
#
diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py
index ee7fda2638..4cbc1e47c6 100755
--- a/scripts/replay-dump.py
+++ b/scripts/replay-dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Dump the contents of a recorded execution stream
@@ -18,7 +18,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
import argparse
import struct
from collections import namedtuple
diff --git a/scripts/signrom.py b/scripts/signrom.py
index 313ee28a17..43693dba56 100644..100755
--- a/scripts/signrom.py
+++ b/scripts/signrom.py
@@ -1,4 +1,5 @@
-from __future__ import print_function
+#!/usr/bin/env python3
+
#
# Option ROM signing utility
#
@@ -44,14 +45,8 @@ fout.write(data)
checksum = 0
for b in data:
- # catch Python 2 vs. 3 differences
- if isinstance(b, int):
- checksum += b
- else:
- checksum += ord(b)
-checksum = (256 - checksum) % 256
-
-# Python 3 no longer allows chr(checksum)
+ checksum = (checksum - b) & 255
+
fout.write(struct.pack('B', checksum))
fin.close()
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py
index 45485b864b..20f0026066 100755
--- a/scripts/simpletrace.py
+++ b/scripts/simpletrace.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Pretty-printer for simple trace backend binary trace files
#
@@ -9,7 +9,6 @@
#
# For help see docs/devel/tracing.txt
-from __future__ import print_function
import struct
import inspect
from tracetool import read_events, Event
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 3beaa66bd8..264cc9eecc 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 44c118bc2a..13d29f1e42 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index 259c6a6531..54cab2c4de 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index c2f3a4e5a8..638990db79 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index 92f71b28f9..e9844dd335 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index 33c95af8e9..23b274c0fd 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index c2fd1c24c4..b650c262b5 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index 668fb73fee..1373a90192 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index 280cb7c106..a772a3b53b 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/format/__init__.py
index cf6e0e2da5..aba2f7a441 100644
--- a/scripts/tracetool/format/__init__.py
+++ b/scripts/tracetool/format/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py
index 31207961b0..78af8aff72 100644
--- a/scripts/tracetool/format/c.py
+++ b/scripts/tracetool/format/c.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py
index c7cb2a93a6..d3980b914b 100644
--- a/scripts/tracetool/format/d.py
+++ b/scripts/tracetool/format/d.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index 5596b304e6..83e1a2f355 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/format/log_stap.py
index 9ab0cf2cce..b486beb672 100644
--- a/scripts/tracetool/format/log_stap.py
+++ b/scripts/tracetool/format/log_stap.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py
index 57b04061cf..4f4633b4e6 100644
--- a/scripts/tracetool/format/simpletrace_stap.py
+++ b/scripts/tracetool/format/simpletrace_stap.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py
index e8ef3e762d..8fc808f2ef 100644
--- a/scripts/tracetool/format/stap.py
+++ b/scripts/tracetool/format/stap.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py
index 1651cc3f71..0180e3d76c 100644
--- a/scripts/tracetool/format/tcg_h.py
+++ b/scripts/tracetool/format/tcg_h.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py
index 1b3522a716..6527b69afd 100644
--- a/scripts/tracetool/format/tcg_helper_c.py
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/tcg_helper_h.py b/scripts/tracetool/format/tcg_helper_h.py
index 6b184b641b..98ebe52f18 100644
--- a/scripts/tracetool/format/tcg_helper_h.py
+++ b/scripts/tracetool/format/tcg_helper_h.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/tcg_helper_wrapper_h.py b/scripts/tracetool/format/tcg_helper_wrapper_h.py
index ff53447512..6adeab74df 100644
--- a/scripts/tracetool/format/tcg_helper_wrapper_h.py
+++ b/scripts/tracetool/format/tcg_helper_wrapper_h.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/format/ust_events_c.py
index 264784cdf2..deced9533d 100644
--- a/scripts/tracetool/format/ust_events_c.py
+++ b/scripts/tracetool/format/ust_events_c.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py
index b14054ac01..6ce559f6cc 100644
--- a/scripts/tracetool/format/ust_events_h.py
+++ b/scripts/tracetool/format/ust_events_h.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/transform.py b/scripts/tracetool/transform.py
index 2ca9286046..8fd4dcf20d 100644
--- a/scripts/tracetool/transform.py
+++ b/scripts/tracetool/transform.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/tracetool/vcpu.py b/scripts/tracetool/vcpu.py
index 452c7f589d..0b104e4f15 100644
--- a/scripts/tracetool/vcpu.py
+++ b/scripts/tracetool/vcpu.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
index f8b7b8f772..539ead62b4 100755
--- a/scripts/vmstate-static-checker.py
+++ b/scripts/vmstate-static-checker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Compares vmstate information stored in JSON format, obtained from
# the -dump-vmstate QEMU command.
@@ -19,7 +19,6 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
-from __future__ import print_function
import argparse
import json
import sys
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 6618ea67c1..d4358eb431 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -55,19 +55,16 @@ def pick_default_qemu_bin(arch=None):
return qemu_bin_from_src_dir_path
-def wait_for_console_pattern(test, success_message, failure_message=None):
- """
- Waits for messages to appear on the console, while logging the content
-
- :param test: an Avocado test containing a VM that will have its console
- read and probed for a success or failure message
- :type test: :class:`avocado_qemu.Test`
- :param success_message: if this message appears, test succeeds
- :param failure_message: if this message appears, test fails
- """
+def _console_interaction(test, success_message, failure_message,
+ send_string, keep_sending=False):
+ assert not keep_sending or send_string
console = test.vm.console_socket.makefile()
console_logger = logging.getLogger('console')
while True:
+ if send_string:
+ test.vm.console_socket.sendall(send_string.encode())
+ if not keep_sending:
+ send_string = None # send only once
msg = console.readline().strip()
if not msg:
continue
@@ -79,6 +76,43 @@ def wait_for_console_pattern(test, success_message, failure_message=None):
fail = 'Failure message found in console: %s' % failure_message
test.fail(fail)
+def interrupt_interactive_console_until_pattern(test, success_message,
+ failure_message=None,
+ interrupt_string='\r'):
+ """
+ Keep sending a string to interrupt a console prompt, while logging the
+ console output. Typical use case is to break a boot loader prompt, such:
+
+ Press a key within 5 seconds to interrupt boot process.
+ 5
+ 4
+ 3
+ 2
+ 1
+ Booting default image...
+
+ :param test: an Avocado test containing a VM that will have its console
+ read and probed for a success or failure message
+ :type test: :class:`avocado_qemu.Test`
+ :param success_message: if this message appears, test succeeds
+ :param failure_message: if this message appears, test fails
+ :param interrupt_string: a string to send to the console before trying
+ to read a new line
+ """
+ _console_interaction(test, success_message, failure_message,
+ interrupt_string, True)
+
+def wait_for_console_pattern(test, success_message, failure_message=None):
+ """
+ Waits for messages to appear on the console, while logging the content
+
+ :param test: an Avocado test containing a VM that will have its console
+ read and probed for a success or failure message
+ :type test: :class:`avocado_qemu.Test`
+ :param success_message: if this message appears, test succeeds
+ :param failure_message: if this message appears, test fails
+ """
+ _console_interaction(test, success_message, failure_message, None)
def exec_command_and_wait_for_pattern(test, command,
success_message, failure_message=None):
@@ -94,10 +128,7 @@ def exec_command_and_wait_for_pattern(test, command,
:param success_message: if this message appears, test succeeds
:param failure_message: if this message appears, test fails
"""
- command += '\r'
- test.vm.console_socket.sendall(command.encode())
- wait_for_console_pattern(test, success_message, failure_message)
-
+ _console_interaction(test, success_message, failure_message, command + '\r')
class Test(avocado.Test):
def _get_unique_tag_val(self, tag_name):
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index e40b84651b..34d37eba3b 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -40,7 +40,7 @@ class BootLinuxConsole(Test):
Extracts a file from a deb package into the test workdir
:param deb: path to the deb archive
- :param file: path within the deb archive of the file to be extracted
+ :param path: path within the deb archive of the file to be extracted
:returns: path of the extracted file
"""
cwd = os.getcwd()
@@ -49,7 +49,28 @@ class BootLinuxConsole(Test):
process.run("ar x %s %s" % (deb, file_path))
archive.extract(file_path, self.workdir)
os.chdir(cwd)
- return self.workdir + path
+ # Return complete path to extracted file. Because callers to
+ # extract_from_deb() specify 'path' with a leading slash, it is
+ # necessary to use os.path.relpath() as otherwise os.path.join()
+ # interprets it as an absolute path and drops the self.workdir part.
+ return os.path.normpath(os.path.join(self.workdir,
+ os.path.relpath(path, '/')))
+
+ def extract_from_rpm(self, rpm, path):
+ """
+ Extracts a file from an RPM package into the test workdir.
+
+ :param rpm: path to the rpm archive
+ :param path: path within the rpm archive of the file to be extracted
+ needs to be a relative path (starting with './') because
+ cpio(1), which is used to extract the file, expects that.
+ :returns: path of the extracted file
+ """
+ cwd = os.getcwd()
+ os.chdir(self.workdir)
+ process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
+ os.chdir(cwd)
+ return os.path.normpath(os.path.join(self.workdir, path))
def test_x86_64_pc(self):
"""
@@ -304,6 +325,7 @@ class BootLinuxConsole(Test):
:avocado: tags=arch:arm
:avocado: tags=machine:emcraft-sf2
:avocado: tags=endian:little
+ :avocado: tags=u-boot
"""
uboot_url = ('https://raw.githubusercontent.com/'
'Subbaraya-Sundeep/qemu-test-binaries/'
@@ -519,7 +541,7 @@ class BootLinuxConsole(Test):
self.vm.set_console()
kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
- self.vm.add_args('-vga', 'std',
+ self.vm.add_args('-nodefaults',
'-kernel', uncompressed_kernel,
'-append', kernel_command_line)
self.vm.launch()
@@ -568,3 +590,99 @@ class BootLinuxConsole(Test):
self.wait_for_console_pattern(console_pattern)
console_pattern = 'No filesystem could mount root'
self.wait_for_console_pattern(console_pattern)
+
+ def do_test_advcal_2018(self, day, tar_hash, kernel_name):
+ tar_url = ('https://www.qemu-advent-calendar.org'
+ '/2018/download/day' + day + '.tar.xz')
+ file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
+ archive.extract(file_path, self.workdir)
+ self.vm.set_console()
+ self.vm.add_args('-kernel',
+ self.workdir + '/day' + day + '/' + kernel_name)
+ self.vm.launch()
+ self.wait_for_console_pattern('QEMU advent calendar')
+
+ def test_arm_vexpressa9(self):
+ """
+ :avocado: tags=arch:arm
+ :avocado: tags=machine:vexpress-a9
+ """
+ tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
+ self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
+ self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
+
+ def test_m68k_mcf5208evb(self):
+ """
+ :avocado: tags=arch:m68k
+ :avocado: tags=machine:mcf5208evb
+ """
+ tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
+ self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
+
+ def test_microblaze_s3adsp1800(self):
+ """
+ :avocado: tags=arch:microblaze
+ :avocado: tags=machine:petalogix-s3adsp1800
+ """
+ tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
+ self.do_test_advcal_2018('17', tar_hash, 'ballerina.bin')
+
+ def test_or1k_sim(self):
+ """
+ :avocado: tags=arch:or1k
+ :avocado: tags=machine:or1k-sim
+ """
+ tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
+ self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
+
+ def test_nios2_10m50(self):
+ """
+ :avocado: tags=arch:nios2
+ :avocado: tags=machine:10m50-ghrd
+ """
+ tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
+ self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
+
+ def test_ppc64_e500(self):
+ """
+ :avocado: tags=arch:ppc64
+ :avocado: tags=machine:ppce500
+ """
+ tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
+ self.vm.add_args('-cpu', 'e5500')
+ self.do_test_advcal_2018('19', tar_hash, 'uImage')
+
+ def test_ppc_g3beige(self):
+ """
+ :avocado: tags=arch:ppc
+ :avocado: tags=machine:g3beige
+ """
+ tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
+ self.vm.add_args('-M', 'graphics=off')
+ self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
+
+ def test_ppc_mac99(self):
+ """
+ :avocado: tags=arch:ppc
+ :avocado: tags=machine:mac99
+ """
+ tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
+ self.vm.add_args('-M', 'graphics=off')
+ self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
+
+ def test_sparc_ss20(self):
+ """
+ :avocado: tags=arch:sparc
+ :avocado: tags=machine:SS-20
+ """
+ tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
+ self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
+
+ def test_xtensa_lx60(self):
+ """
+ :avocado: tags=arch:xtensa
+ :avocado: tags=machine:lx60
+ """
+ tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
+ self.vm.add_args('-cpu', 'dc233c')
+ self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')
diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index a44c1ae58f..a8367ca023 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -10,13 +10,19 @@
# later. See the COPYING file in the top-level directory.
+import tempfile
from avocado_qemu import Test
+from avocado import skipUnless
from avocado.utils import network
from avocado.utils import wait
+from avocado.utils.path import find_command
class Migration(Test):
+ """
+ :avocado: tags=migration
+ """
timeout = 10
@@ -24,6 +30,28 @@ class Migration(Test):
def migration_finished(vm):
return vm.command('query-migrate')['status'] in ('completed', 'failed')
+ def assert_migration(self, src_vm, dst_vm):
+ wait.wait_for(self.migration_finished,
+ timeout=self.timeout,
+ step=0.1,
+ args=(src_vm,))
+ self.assertEqual(src_vm.command('query-migrate')['status'], 'completed')
+ self.assertEqual(dst_vm.command('query-migrate')['status'], 'completed')
+ self.assertEqual(dst_vm.command('query-status')['status'], 'running')
+ self.assertEqual(src_vm.command('query-status')['status'],'postmigrate')
+
+ def do_migrate(self, dest_uri, src_uri=None):
+ dest_vm = self.get_vm('-incoming', dest_uri)
+ dest_vm.add_args('-nodefaults')
+ dest_vm.launch()
+ if src_uri is None:
+ src_uri = dest_uri
+ source_vm = self.get_vm()
+ source_vm.add_args('-nodefaults')
+ source_vm.launch()
+ source_vm.qmp('migrate', uri=src_uri)
+ self.assert_migration(source_vm, dest_vm)
+
def _get_free_port(self):
port = network.find_free_port()
if port is None:
@@ -32,19 +60,18 @@ class Migration(Test):
def test_migration_with_tcp_localhost(self):
- source_vm = self.get_vm()
dest_uri = 'tcp:localhost:%u' % self._get_free_port()
- dest_vm = self.get_vm('-incoming', dest_uri)
- dest_vm.launch()
- source_vm.launch()
- source_vm.qmp('migrate', uri=dest_uri)
- wait.wait_for(
- self.migration_finished,
- timeout=self.timeout,
- step=0.1,
- args=(source_vm,)
- )
- self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
- self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
- self.assertEqual(dest_vm.command('query-status')['status'], 'running')
- self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')
+ self.do_migrate(dest_uri)
+
+ def test_migration_with_unix(self):
+ with tempfile.TemporaryDirectory(prefix='socket_') as socket_path:
+ dest_uri = 'unix:%s/qemu-test.sock' % socket_path
+ self.do_migrate(dest_uri)
+
+ @skipUnless(find_command('nc', default=False), "'nc' command not found")
+ def test_migration_with_exec(self):
+ """
+ The test works for both netcat-traditional and netcat-openbsd packages
+ """
+ free_port = self._get_free_port()
+ dest_uri = 'exec:nc -l localhost %u' % free_port
diff --git a/tests/acceptance/version.py b/tests/acceptance/version.py
index 67c2192c93..79b923d4fc 100644
--- a/tests/acceptance/version.py
+++ b/tests/acceptance/version.py
@@ -17,6 +17,7 @@ class Version(Test):
:avocado: tags=quick
"""
def test_qmp_human_info_version(self):
+ self.vm.add_args('-nodefaults')
self.vm.launch()
res = self.vm.command('human-monitor-command',
command_line='info version')
diff --git a/tests/acceptance/virtio_seg_max_adjust.py b/tests/acceptance/virtio_check_params.py
index 5458573138..87e6c839d1 100755..100644
--- a/tests/acceptance/virtio_seg_max_adjust.py
+++ b/tests/acceptance/virtio_check_params.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#
# Test virtio-scsi and virtio-blk queue settings for all machine types
#
@@ -21,10 +20,12 @@
import sys
import os
import re
+import logging
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
from qemu.machine import QEMUMachine
from avocado_qemu import Test
+from avocado import skip
#list of machine types and virtqueue properties to test
VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust'}
@@ -73,12 +74,20 @@ class VirtioMaxSegSettingsCheck(Test):
return query_ok, props, error
def check_mt(self, mt, dev_type_name):
+ mt['device'] = dev_type_name # Only for the debug() call.
+ logger = logging.getLogger('machine')
+ logger.debug(mt)
with QEMUMachine(self.qemu_bin) as vm:
vm.set_machine(mt["name"])
+ vm.add_args('-nodefaults')
for s in VM_DEV_PARAMS[dev_type_name]:
vm.add_args(s)
- vm.launch()
- query_ok, props, error = self.query_virtqueue(vm, dev_type_name)
+ try:
+ vm.launch()
+ query_ok, props, error = self.query_virtqueue(vm, dev_type_name)
+ except:
+ query_ok = False
+ error = sys.exc_info()[0]
if not query_ok:
self.fail('machine type {0}: {1}'.format(mt['name'], error))
@@ -108,6 +117,7 @@ class VirtioMaxSegSettingsCheck(Test):
return True
return False
+ @skip("break multi-arch CI")
def test_machine_types(self):
# collect all machine types except 'none', 'isapc', 'microvm'
with QEMUMachine(self.qemu_bin) as vm:
diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/x86_cpu_model_versions.py
index 90558d9a71..01ff614ec2 100644
--- a/tests/acceptance/x86_cpu_model_versions.py
+++ b/tests/acceptance/x86_cpu_model_versions.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#
# Basic validation of x86 versioned CPU models and CPU model aliases
#
diff --git a/tests/docker/travis.py b/tests/docker/travis.py
index e1433012bd..37307ac366 100755
--- a/tests/docker/travis.py
+++ b/tests/docker/travis.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Travis YAML config parser
#
@@ -11,7 +11,6 @@
# or (at your option) any later version. See the COPYING file in
# the top-level directory.
-from __future__ import print_function
import sys
import yaml
import itertools
diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
index c7e3986a24..98a5df4d42 100644
--- a/tests/guest-debug/test-gdbstub.py
+++ b/tests/guest-debug/test-gdbstub.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
#
# This script needs to be run on startup
# qemu -kernel ${KERNEL} -s -S
diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestperf/engine.py
index 1dd04ce33b..fd63c66601 100644
--- a/tests/migration/guestperf/engine.py
+++ b/tests/migration/guestperf/engine.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
#
# Migration test main engine
#
diff --git a/tests/migration/guestperf/plot.py b/tests/migration/guestperf/plot.py
index aa98912a82..34cebd54ba 100644
--- a/tests/migration/guestperf/plot.py
+++ b/tests/migration/guestperf/plot.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
#
# Migration test graph plotting
#
diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py
index 61d2abbaad..5bcc066bb9 100644
--- a/tests/migration/guestperf/shell.py
+++ b/tests/migration/guestperf/shell.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
#
# Migration test command line shell integration
#
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index bad14edb47..41232c11a3 100755
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# QAPI parser test harness
#
@@ -11,7 +11,6 @@
# See the COPYING file in the top-level directory.
#
-from __future__ import print_function
import argparse
import difflib
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index 0990681c1e..aa911d266a 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for image streaming.
#
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index 74f62c3c4a..2e7ee0e84f 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for image block commit.
#
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index 0181f7a9b6..43556b9727 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for image mirroring.
#
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
index 8b2afa2a11..7e99ea7c68 100755
--- a/tests/qemu-iotests/044
+++ b/tests/qemu-iotests/044
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests growing a large refcount table.
#
diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045
index 01cc038884..5acc89099c 100755
--- a/tests/qemu-iotests/045
+++ b/tests/qemu-iotests/045
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for fdsets and getfd.
#
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index c732a112d6..82b9f5f47d 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for drive-backup and blockdev-backup
#
diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056
index f39287c162..f73fc74457 100755
--- a/tests/qemu-iotests/056
+++ b/tests/qemu-iotests/056
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for drive-backup
#
diff --git a/tests/qemu-iotests/057 b/tests/qemu-iotests/057
index 9fbba759b6..a8b4bb60e0 100755
--- a/tests/qemu-iotests/057
+++ b/tests/qemu-iotests/057
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for internal snapshot.
#
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index 5b21eb96bd..6426474271 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test for additional information emitted by qemu-img info on qcow2
# images
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index f03fa24a07..32ded11430 100755
--- a/tests/qemu-iotests/093
+++ b/tests/qemu-iotests/093
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for IO throttling
#
diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096
index ab9cb47822..5915f92786 100755
--- a/tests/qemu-iotests/096
+++ b/tests/qemu-iotests/096
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test that snapshots move the throttling configuration to the active
# layer
diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
index e20080e9a6..adc8a848b5 100755
--- a/tests/qemu-iotests/118
+++ b/tests/qemu-iotests/118
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test case for the QMP 'change' command and all other associated
# commands
diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index d3e851e1ae..3705cbb6b3 100755
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for incremental drive-backup
#
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
index cd6b9e9ce7..b0da4a5541 100755
--- a/tests/qemu-iotests/129
+++ b/tests/qemu-iotests/129
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests that "bdrv_drain_all" doesn't drain block jobs
#
diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132
index 0f2a106c81..39ea43067e 100755
--- a/tests/qemu-iotests/132
+++ b/tests/qemu-iotests/132
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test mirror with unmap
#
diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
index 012ea111ac..d59400c9fc 100755
--- a/tests/qemu-iotests/136
+++ b/tests/qemu-iotests/136
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for block device statistics
#
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
index cbb5a76530..6b1a444364 100755
--- a/tests/qemu-iotests/139
+++ b/tests/qemu-iotests/139
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test cases for the QMP 'blockdev-del' command
#
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 2b6f859a09..f4b0a11dba 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test case for NBD's blockdev-add interface
#
diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148
index 8c11c53cba..90931948e3 100755
--- a/tests/qemu-iotests/148
+++ b/tests/qemu-iotests/148
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test the rate limit of QMP events
#
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 8ab42e94c6..b4a21bf7b7 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2016 Red Hat, Inc.
#
@@ -20,7 +20,6 @@
# Exercise the QEMU 'luks' block driver to validate interoperability
# with the Linux dm-crypt + cryptsetup implementation
-from __future__ import print_function
import subprocess
import os
import os.path
diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151
index 76ae265cc1..f2df72c29c 100755
--- a/tests/qemu-iotests/151
+++ b/tests/qemu-iotests/151
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for active mirroring
#
diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152
index 732bf5f062..cc2ea09654 100755
--- a/tests/qemu-iotests/152
+++ b/tests/qemu-iotests/152
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for drive-mirror with source size unaligned to granularity
#
diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155
index e19485911c..e35b1d534b 100755
--- a/tests/qemu-iotests/155
+++ b/tests/qemu-iotests/155
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test whether the backing BDSs are correct after completion of a
# mirror block job; in "existing" modes (drive-mirror with
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
index d94728e080..5a3cc840a5 100755
--- a/tests/qemu-iotests/163
+++ b/tests/qemu-iotests/163
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for shrinking images
#
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
index 951ea011a2..fb56a769b4 100755
--- a/tests/qemu-iotests/165
+++ b/tests/qemu-iotests/165
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for persistent dirty bitmaps.
#
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
import os
import re
import iotests
diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169
index 9656a7f620..2c5a132aa3 100755
--- a/tests/qemu-iotests/169
+++ b/tests/qemu-iotests/169
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for dirty bitmaps migration.
#
diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194
index 72e47e8833..9dc1bd3510 100755
--- a/tests/qemu-iotests/194
+++ b/tests/qemu-iotests/194
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/196 b/tests/qemu-iotests/196
index 92fe9244f8..e8fcf37273 100755
--- a/tests/qemu-iotests/196
+++ b/tests/qemu-iotests/196
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test clearing unknown autoclear_features flag by qcow2 after
# migration. This test mimics migration to older qemu.
diff --git a/tests/qemu-iotests/199 b/tests/qemu-iotests/199
index a2c8ecab5a..40774eed74 100755
--- a/tests/qemu-iotests/199
+++ b/tests/qemu-iotests/199
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for dirty bitmaps postcopy migration.
#
diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202
index 581ca34d79..920a8683ef 100755
--- a/tests/qemu-iotests/202
+++ b/tests/qemu-iotests/202
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203
index 4874a1a0d8..49eff5d405 100755
--- a/tests/qemu-iotests/203
+++ b/tests/qemu-iotests/203
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205
index 4bb2c21e8b..43432cb599 100755
--- a/tests/qemu-iotests/205
+++ b/tests/qemu-iotests/205
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for qmp command nbd-server-remove.
#
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
index 9f16a7df8d..e2b50ae24d 100755
--- a/tests/qemu-iotests/206
+++ b/tests/qemu-iotests/206
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test qcow2 and file image creation
#
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
index 812ab34e47..3d9c1208ca 100755
--- a/tests/qemu-iotests/207
+++ b/tests/qemu-iotests/207
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test ssh image creation
#
diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208
index 546eb1de3e..1c3fc8c7fd 100755
--- a/tests/qemu-iotests/208
+++ b/tests/qemu-iotests/208
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2018 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/209 b/tests/qemu-iotests/209
index e0f464bcbe..65c1a1e70a 100755
--- a/tests/qemu-iotests/209
+++ b/tests/qemu-iotests/209
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for NBD BLOCK_STATUS extension
#
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
index 4ca0fe26ef..e49896e23d 100755
--- a/tests/qemu-iotests/210
+++ b/tests/qemu-iotests/210
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test luks and file image creation
#
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
index 8834ebfe85..163994d559 100755
--- a/tests/qemu-iotests/211
+++ b/tests/qemu-iotests/211
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test VDI and file image creation
#
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
index 8f3ccc7b15..800f92dd84 100755
--- a/tests/qemu-iotests/212
+++ b/tests/qemu-iotests/212
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test parallels and file image creation
#
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
index 3fc8dc6eaa..1eee45276a 100755
--- a/tests/qemu-iotests/213
+++ b/tests/qemu-iotests/213
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test vhdx and file image creation
#
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
index 3c0ae54b44..372f042d3e 100755
--- a/tests/qemu-iotests/216
+++ b/tests/qemu-iotests/216
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copy-on-read tests using a COR filter node
#
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index 2554d84581..1325ba9eaa 100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# This test covers what happens when a mirror block job is cancelled
# in various phases of its existence.
diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219
index 655f54d881..b8774770c4 100755
--- a/tests/qemu-iotests/219
+++ b/tests/qemu-iotests/219
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2018 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222
index 3f9f934ad8..bf1718e179 100644..100755
--- a/tests/qemu-iotests/222
+++ b/tests/qemu-iotests/222
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# This test covers the basic fleecing workflow, which provides a
# point-in-time snapshot of a node that can be queried over NBD.
diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224
index b4dfaa639f..e91fb26fd8 100755
--- a/tests/qemu-iotests/224
+++ b/tests/qemu-iotests/224
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test json:{} filenames with qemu-internal BDSs
# (the one of commit, to be precise)
diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228
index 9a50afd205..64bc82ee23 100755
--- a/tests/qemu-iotests/228
+++ b/tests/qemu-iotests/228
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test for when a backing file is considered overridden (thus, a
# json:{} filename is generated for the overlay) and when it is not
diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234
index 59a7f949ec..324c1549fd 100755
--- a/tests/qemu-iotests/234
+++ b/tests/qemu-iotests/234
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2018 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235
index 3d7533980d..760826128e 100755
--- a/tests/qemu-iotests/235
+++ b/tests/qemu-iotests/235
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Simple mirror test
#
diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236
index 79a6381f8e..8ce927a16c 100755
--- a/tests/qemu-iotests/236
+++ b/tests/qemu-iotests/236
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test bitmap merges.
#
diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237
index a2242a4736..50ba364a3e 100755
--- a/tests/qemu-iotests/237
+++ b/tests/qemu-iotests/237
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test vmdk and file image creation
#
diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238
index e5ac2b2ff8..d4e060228c 100755
--- a/tests/qemu-iotests/238
+++ b/tests/qemu-iotests/238
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Regression test for throttle group member unregister segfault with iothread
#
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index c176e92da6..97617876bc 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test for qcow2 bitmap printed information
#
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
index d12b253065..489bf78bd0 100644..100755
--- a/tests/qemu-iotests/245
+++ b/tests/qemu-iotests/245
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test cases for the QMP 'x-blockdev-reopen' command
#
diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246
index b0997a392f..59a216a839 100755
--- a/tests/qemu-iotests/246
+++ b/tests/qemu-iotests/246
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test persistent bitmap resizing.
#
diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248
index f26b4bb2aa..68c374692e 100755
--- a/tests/qemu-iotests/248
+++ b/tests/qemu-iotests/248
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test resume mirror after auto pause on ENOSPC
#
diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254
index 09584f3f7d..ee66c986db 100755
--- a/tests/qemu-iotests/254
+++ b/tests/qemu-iotests/254
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test external snapshot with bitmap copying and moving.
#
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index 0ba03d9e61..4a4818bafb 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test commit job graph modifications while requests are active
#
diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256
index c594a43205..e34074c83e 100755
--- a/tests/qemu-iotests/256
+++ b/tests/qemu-iotests/256
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test incremental/backup across iothread contexts
#
diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
index a9828251cf..004a433b8b 100755
--- a/tests/qemu-iotests/257
+++ b/tests/qemu-iotests/257
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test bitmap-sync backups (incremental, differential, and partials)
#
diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258
index b84cf02254..091755a45c 100755
--- a/tests/qemu-iotests/258
+++ b/tests/qemu-iotests/258
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Very specific tests for adjacent commit/stream block jobs
#
diff --git a/tests/qemu-iotests/260 b/tests/qemu-iotests/260
index 4f6082c9d2..30c0de380d 100755
--- a/tests/qemu-iotests/260
+++ b/tests/qemu-iotests/260
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tests for temporary external snapshot when we have bitmaps.
#
diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262
index bbcb5260a6..8835dce7be 100755
--- a/tests/qemu-iotests/262
+++ b/tests/qemu-iotests/262
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2019 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264
index 131366422b..879123a343 100755
--- a/tests/qemu-iotests/264
+++ b/tests/qemu-iotests/264
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test nbd reconnect
#
diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266
index c353cf88ee..91bdf8729e 100755
--- a/tests/qemu-iotests/266
+++ b/tests/qemu-iotests/266
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test VPC and file image creation
#
diff --git a/tests/qemu-iotests/277 b/tests/qemu-iotests/277
index 1f72dca2d4..04aa15a3d5 100755
--- a/tests/qemu-iotests/277
+++ b/tests/qemu-iotests/277
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test NBD client reconnection
#
diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280
index 85e9114c5e..69288fdd0e 100755
--- a/tests/qemu-iotests/280
+++ b/tests/qemu-iotests/280
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2019 Red Hat, Inc.
#
diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281
index 269d583b2c..0bf973bca6 100755
--- a/tests/qemu-iotests/281
+++ b/tests/qemu-iotests/281
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test cases for blockdev + IOThread interactions
#
diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283
index 293e557bd9..55b7cff953 100644
--- a/tests/qemu-iotests/283
+++ b/tests/qemu-iotests/283
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Test for backup-top filter permission activation failure
#
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index fff5fa956a..f7a2d3d6c3 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -846,7 +846,7 @@ do
start=$(_wallclock)
- if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
+ if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python3" ]; then
if $python_usable; then
run_command="$PYTHON $seq"
else
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index ead04a1ab5..0473e824ed 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
# Common utilities and Python wrappers for qemu-iotests
#
# Copyright (C) 2012 IBM Corp.
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
index 7e2dab6ea4..588d62aebf 100755
--- a/tests/qemu-iotests/nbd-fault-injector.py
+++ b/tests/qemu-iotests/nbd-fault-injector.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# NBD server - fault injection utility
#
# Configuration file syntax:
@@ -43,7 +43,6 @@
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
-from __future__ import print_function
import sys
import socket
import struct
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 91e4420b9f..94a07b2f6f 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -1,6 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
-from __future__ import print_function
import sys
import struct
import string
diff --git a/tests/qemu-iotests/qed.py b/tests/qemu-iotests/qed.py
index 8adaaf46c4..d6bec96069 100755
--- a/tests/qemu-iotests/qed.py
+++ b/tests/qemu-iotests/qed.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Tool to manipulate QED image files
#
@@ -10,7 +10,6 @@
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
-from __future__ import print_function
import sys
import struct
import random
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index ed5dd4f3d0..4dee6647e6 100755..100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#
# VM testing base class
#
@@ -12,7 +11,6 @@
# the COPYING file in the top-level directory.
#
-from __future__ import print_function
import os
import re
import sys
diff --git a/tests/vm/centos b/tests/vm/centos
index f2f0befd84..a41ff109eb 100755
--- a/tests/vm/centos
+++ b/tests/vm/centos
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# CentOS image
#
diff --git a/tests/vm/fedora b/tests/vm/fedora
index 8e270fc0f0..4d7d6049f4 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Fedora VM image
#
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 33a736298a..fb54334696 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# FreeBSD VM image
#
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index ec6f3563b2..c5069a45f4 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# NetBSD VM image
#
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index d6173506f7..22cd9513dd 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# OpenBSD VM image
#
diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386
index 3834cd7a8d..48e9cb1ad3 100755
--- a/tests/vm/ubuntu.i386
+++ b/tests/vm/ubuntu.i386
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Ubuntu i386 image
#