- 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)
 -----BEGIN PGP SIGNATURE-----
 
 iQIyBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAl49e+QACgkQ4+MsLN6t
 wN7E6A/3dzCLP0QDoT/C2rC1uu2yXBpXsSUSGeRCA+NLGEOpkyWiEK/vCQp/WxGO
 YU3ToO5NIGMxjVGhy14D1U4NrmiUhxmkGlJQJ60WKAO/oJBElHz8aR2keGlbkBp3
 mh/Amyw+ubM3aBYcAmBbgn0y7yr+lV62mD1JmffQebwIMsT+6aL4XhZ6Lf8PAEkY
 0pCK30O0j8Mwk8ppwKjoRT0WhhcKInmaLElbcOstoqVjQerGV7ho7VjlS9v2BPeg
 uQbDbv5lask7XVoJzortQ9nP2Tq3R+T7hNc0RPa0/tuqZ/6ucq6eYbFgbr/S7r3/
 Lem3ByA1EPlNzjq1HZoU3zx0/Ydq6qPyiudO9fLOCDIGVG6ZKXmKVq71lWHotcAw
 Oir+RPSVhPmOekhOPXAEi3mwAqRX3iSUGSsm+aLgq9I1DJfdE8dG2n5ZKVSWClmF
 xwb8Dhlz1T5SIlLderfVFryLzV2/LoHQOpr37phw6Ec5gox6UR0i4ozKEaY1zmZV
 THvweFraoBUGwIN7ULfP8jxs8hjQY9HIxhYjNvPxqAQekH6hO97qkjbs44ujvNrS
 D/yL4Gk4XgDjGP37aeBoY0zCUMM3cpWZdVfycDiXe6r949ifOoF0gZSny7ryRTGh
 s1RvQAM9VaYcGTERkLLCC+QMuz24nN/cEg9H3SFlfHBGVBxaBw==
 =8xBQ
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Peter Maydell 2020-02-10 12:07:26 +00:00
commit 73d336510c
147 changed files with 432 additions and 234 deletions

20
.readthedocs.yml Normal file
View File

@ -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

View File

@ -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

View File

@ -24,7 +24,8 @@
# support which often includes its 32 bit cousin.
ADDITIONAL_ARCHES = {
"x86_64" : "i386",
"aarch64" : "armhf"
"aarch64" : "armhf",
"ppc64le" : "ppc64",
}
def list_accel(qemu_bin):

View File

@ -112,6 +112,7 @@ def __init__(self, binary, args=None, wrapper=None, name=None,
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 @@ def _base_args(self):
'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 @@ def set_machine(self, machine_type):
"""
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 @@ def set_console(self, device_type=None):
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):

View File

@ -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 @@
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 @@ def __init__(self, address, server=False):
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 @@ def __negotiate_capabilities(self):
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 @@ def __json_read(self, only_event=False):
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 @@ def __get_events(self, wait=False):
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 @@ def __get_events(self, wait=False):
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 @@ def connect(self, negotiate=True):
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 @@ def cmd_obj(self, qmp_cmd):
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 @@ def clear_events(self):
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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -12,7 +12,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 ctypes
import struct

View File

@ -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

View File

@ -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

2
scripts/minikconf.py Normal file → Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
##
# QEMU Object Model test tools
#

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Render Qemu Block Graph
#

View File

@ -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

11
scripts/signrom.py Normal file → Executable file
View File

@ -1,4 +1,5 @@
from __future__ import print_function
#!/usr/bin/env python3
#
# Option ROM signing utility
#
@ -44,14 +45,8 @@
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
checksum = (checksum - b) & 255
# Python 3 no longer allows chr(checksum)
fout.write(struct.pack('B', checksum))
fin.close()

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

View File

@ -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

View File

@ -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):

View File

@ -40,7 +40,7 @@ def extract_from_deb(self, deb, path):
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 @@ def extract_from_deb(self, deb, path):
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 @@ def test_arm_emcraft_sf2(self):
: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 @@ def test_alpha_clipper(self):
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 @@ def test_m68k_q800(self):
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')

View File

@ -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 @@ def _get_free_port(self):
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

View File

@ -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')

View File

@ -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 @@ def query_virtqueue(self, vm, dev_type_name):
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 @@ def seg_max_adjust_enabled(mt):
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:

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
#
# Basic validation of x86 versioned CPU models and CPU model aliases
#

View File

@ -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

View File

@ -1,4 +1,3 @@
from __future__ import print_function
#
# This script needs to be run on startup
# qemu -kernel ${KERNEL} -s -S

View File

@ -1,4 +1,3 @@
from __future__ import print_function
#
# Migration test main engine
#

View File

@ -1,4 +1,3 @@
from __future__ import print_function
#
# Migration test graph plotting
#

View File

@ -1,4 +1,3 @@
from __future__ import print_function
#
# Migration test command line shell integration
#

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for image streaming.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for image block commit.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for image mirroring.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests growing a large refcount table.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for fdsets and getfd.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for drive-backup and blockdev-backup
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for drive-backup
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for internal snapshot.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test for additional information emitted by qemu-img info on qcow2
# images

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for IO throttling
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test that snapshots move the throttling configuration to the active
# layer

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test case for the QMP 'change' command and all other associated
# commands

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for incremental drive-backup
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests that "bdrv_drain_all" doesn't drain block jobs
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test mirror with unmap
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for block device statistics
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test cases for the QMP 'blockdev-del' command
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test case for NBD's blockdev-add interface
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test the rate limit of QMP events
#

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for active mirroring
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for drive-mirror with source size unaligned to granularity
#

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for shrinking images
#

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for dirty bitmaps migration.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#

View File

@ -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.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for dirty bitmaps postcopy migration.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2017 Red Hat, Inc.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Tests for qmp command nbd-server-remove.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Test qcow2 and file image creation
#

Some files were not shown because too many files have changed in this diff Show More