qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' into staging

Python queue, 2018-02-05

# gpg: Signature made Mon 05 Feb 2018 23:07:57 GMT
# gpg: using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/python-next-pull-request: (21 commits)
docker: change Fedora images to run with python3
travis: improve python version test coverage
ui: update keycodemapdb to get py3 fixes
input: add missing JIS keys to virtio input
qemu.py: don't launch again before shutdown()
qemu.py: cleanup redundant calls in launch()
qemu.py: use poll() instead of 'returncode'
qemu.py: always cleanup on shutdown()
qemu.py: refactor launch()
qemu.py: better control of created files
qemu.py: remove unused import
configure: allow use of python 3
scripts: ensure signrom treats data as bytes
qapi: force a UTF-8 locale for running Python
qapi: ensure stable sort ordering when checking QAPI entities
qapi: remove '-q' arg to diff when comparing QAPI output
qapi: Adapt to moved location of 'maketrans' function in py3
qapi: adapt to moved location of StringIO module in py3
qapi: Use OrderedDict from standard library if available
qapi: use items()/values() intead of iteritems()/itervalues()
...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+150 -100
+9 -5
.travis.yml
··· 1 1 sudo: false 2 2 language: c 3 3 python: 4 - - "2.4" 4 + - "2.6" 5 5 compiler: 6 6 - gcc 7 7 cache: ccache ··· 115 115 - sudo apt-get build-dep -qq qemu 116 116 - wget -O - http://people.linaro.org/~alex.bennee/qemu-submodule-git-seed.tar.xz | tar -xvJ 117 117 - git submodule update --init --recursive 118 - # Trusty System build with latest stable clang 118 + # Trusty System build with latest stable clang & python 3.0 119 119 - sudo: required 120 120 addons: 121 121 dist: trusty 122 122 language: generic 123 123 compiler: none 124 + python: 125 + - "3.0" 124 126 env: 125 127 - COMPILER_NAME=clang CXX=clang++-3.9 CC=clang-3.9 126 - - CONFIG="--disable-linux-user --cc=clang-3.9 --cxx=clang++-3.9" 128 + - CONFIG="--disable-linux-user --cc=clang-3.9 --cxx=clang++-3.9 --python=/usr/bin/python3" 127 129 before_install: 128 130 - wget -nv -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - 129 131 - sudo apt-add-repository -y 'deb http://llvm.org/apt/trusty llvm-toolchain-trusty-3.9 main' ··· 134 136 - git submodule update --init --recursive 135 137 before_script: 136 138 - ./configure ${CONFIG} || cat config.log 137 - # Trusty Linux User build with latest stable clang 139 + # Trusty Linux User build with latest stable clang & python 3.6 138 140 - sudo: required 139 141 addons: 140 142 dist: trusty 141 143 language: generic 142 144 compiler: none 145 + python: 146 + - "3.6" 143 147 env: 144 148 - COMPILER_NAME=clang CXX=clang++-3.9 CC=clang-3.9 145 - - CONFIG="--disable-system --cc=clang-3.9 --cxx=clang++-3.9" 149 + - CONFIG="--disable-system --cc=clang-3.9 --cxx=clang++-3.9 --python=/usr/bin/python3" 146 150 before_install: 147 151 - wget -nv -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - 148 152 - sudo apt-add-repository -y 'deb http://llvm.org/apt/trusty llvm-toolchain-trusty-3.9 main'
+12 -10
Makefile
··· 20 20 all: 21 21 include config-host.mak 22 22 23 + PYTHON_UTF8 = LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(PYTHON) 24 + 23 25 git-submodule-update: 24 26 25 27 .PHONY: git-submodule-update ··· 487 489 488 490 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ 489 491 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) 490 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ 492 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \ 491 493 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ 492 494 "GEN","$@") 493 495 qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ 494 496 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) 495 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ 497 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \ 496 498 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ 497 499 "GEN","$@") 498 500 qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ 499 501 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) 500 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ 502 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \ 501 503 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ 502 504 "GEN","$@") 503 505 ··· 518 520 519 521 qapi-types.c qapi-types.h :\ 520 522 $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) 521 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ 523 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \ 522 524 $(gen-out-type) -o "." -b $<, \ 523 525 "GEN","$@") 524 526 qapi-visit.c qapi-visit.h :\ 525 527 $(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) 526 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ 528 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \ 527 529 $(gen-out-type) -o "." -b $<, \ 528 530 "GEN","$@") 529 531 qapi-event.c qapi-event.h :\ 530 532 $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) 531 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ 533 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-event.py \ 532 534 $(gen-out-type) -o "." $<, \ 533 535 "GEN","$@") 534 536 qmp-commands.h qmp-marshal.c :\ 535 537 $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) 536 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ 538 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \ 537 539 $(gen-out-type) -o "." $<, \ 538 540 "GEN","$@") 539 541 qmp-introspect.h qmp-introspect.c :\ 540 542 $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) 541 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ 543 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-introspect.py \ 542 544 $(gen-out-type) -o "." $<, \ 543 545 "GEN","$@") 544 546 ··· 811 813 docs/interop/qemu-qmp-qapi.texi docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py) 812 814 813 815 docs/interop/qemu-qmp-qapi.texi: $(qapi-modules) 814 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") 816 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") 815 817 816 818 docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json 817 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") 819 + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") 818 820 819 821 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi 820 822 qemu.1: qemu-option-trace.texi
+2 -3
configure
··· 1604 1604 1605 1605 # Note that if the Python conditional here evaluates True we will exit 1606 1606 # with status 1 which is a shell 'false' value. 1607 - if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then 1608 - error_exit "Cannot use '$python', Python 2.6 or later is required." \ 1609 - "Note that Python 3 or later is not yet supported." \ 1607 + if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6))'; then 1608 + error_exit "Cannot use '$python', Python 2 >= 2.6 or Python 3 is required." \ 1610 1609 "Use --python=/path/to/python to specify a supported Python." 1611 1610 fi 1612 1611
+4 -1
qapi/ui.json
··· 748 748 # @ac_bookmarks: since 2.10 749 749 # altgr, altgr_r: dropped in 2.10 750 750 # 751 + # @muhenkan: since 2.12 752 + # @katakanahiragana: since 2.12 753 + # 751 754 # 'sysrq' was mistakenly added to hack around the fact that 752 755 # the ps2 driver was not generating correct scancodes sequences 753 756 # when 'alt+print' was pressed. This flaw is now fixed and the ··· 775 778 'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again', 776 779 'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut', 777 780 'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 778 - 'ro', 'hiragana', 'henkan', 'yen', 781 + 'ro', 'hiragana', 'henkan', 'yen', 'muhenkan', 'katakanahiragana', 779 782 'kp_comma', 'kp_equals', 'power', 'sleep', 'wake', 780 783 'audionext', 'audioprev', 'audiostop', 'audioplay', 'audiomute', 781 784 'volumeup', 'volumedown', 'mediaselect',
+26 -17
scripts/qapi.py
··· 11 11 # This work is licensed under the terms of the GNU GPL, version 2. 12 12 # See the COPYING file in the top-level directory. 13 13 14 + from __future__ import print_function 14 15 import errno 15 16 import getopt 16 17 import os 17 18 import re 18 19 import string 19 20 import sys 20 - from ordereddict import OrderedDict 21 + try: 22 + from collections import OrderedDict 23 + except: 24 + from ordereddict import OrderedDict 25 + try: 26 + from StringIO import StringIO 27 + except ImportError: 28 + from io import StringIO 21 29 22 30 builtin_types = { 23 31 'null': 'QTYPE_QNULL', ··· 244 252 "'Returns:' is only valid for commands") 245 253 246 254 def check(self): 247 - bogus = [name for name, section in self.args.iteritems() 255 + bogus = [name for name, section in self.args.items() 248 256 if not section.member] 249 257 if bogus: 250 258 raise QAPISemError( ··· 299 307 if not isinstance(pragma, dict): 300 308 raise QAPISemError( 301 309 info, "Value of 'pragma' must be a dictionary") 302 - for name, value in pragma.iteritems(): 310 + for name, value in pragma.items(): 303 311 self._pragma(name, value, info) 304 312 else: 305 313 expr_elem = {'expr': expr, ··· 1467 1475 self._def_exprs() 1468 1476 self.check() 1469 1477 except QAPIError as err: 1470 - print >>sys.stderr, err 1478 + print(err, file=sys.stderr) 1471 1479 exit(1) 1472 1480 1473 1481 def _def_entity(self, ent): ··· 1565 1573 1566 1574 def _make_members(self, data, info): 1567 1575 return [self._make_member(key, value, info) 1568 - for (key, value) in data.iteritems()] 1576 + for (key, value) in data.items()] 1569 1577 1570 1578 def _def_struct_type(self, expr, info, doc): 1571 1579 name = expr['struct'] ··· 1597 1605 name, info, doc, 'base', self._make_members(base, info))) 1598 1606 if tag_name: 1599 1607 variants = [self._make_variant(key, value) 1600 - for (key, value) in data.iteritems()] 1608 + for (key, value) in data.items()] 1601 1609 members = [] 1602 1610 else: 1603 1611 variants = [self._make_simple_variant(key, value, info) 1604 - for (key, value) in data.iteritems()] 1612 + for (key, value) in data.items()] 1605 1613 typ = self._make_implicit_enum_type(name, info, 1606 1614 [v.name for v in variants]) 1607 1615 tag_member = QAPISchemaObjectTypeMember('type', typ, False) ··· 1616 1624 name = expr['alternate'] 1617 1625 data = expr['data'] 1618 1626 variants = [self._make_variant(key, value) 1619 - for (key, value) in data.iteritems()] 1627 + for (key, value) in data.items()] 1620 1628 tag_member = QAPISchemaObjectTypeMember('type', 'QType', False) 1621 1629 self._def_entity( 1622 1630 QAPISchemaAlternateType(name, info, doc, ··· 1670 1678 assert False 1671 1679 1672 1680 def check(self): 1673 - for ent in self._entity_dict.values(): 1681 + for (name, ent) in sorted(self._entity_dict.items()): 1674 1682 ent.check(self) 1675 1683 1676 1684 def visit(self, visitor): ··· 1726 1734 type_name = prefix 1727 1735 return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() 1728 1736 1729 - c_name_trans = string.maketrans('.-', '__') 1737 + if hasattr(str, 'maketrans'): 1738 + c_name_trans = str.maketrans('.-', '__') 1739 + else: 1740 + c_name_trans = string.maketrans('.-', '__') 1730 1741 1731 1742 1732 1743 # Map @name to a valid C identifier. ··· 1931 1942 ['source', 'header', 'prefix=', 1932 1943 'output-dir='] + extra_long_options) 1933 1944 except getopt.GetoptError as err: 1934 - print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err)) 1945 + print("%s: %s" % (sys.argv[0], str(err)), file=sys.stderr) 1935 1946 sys.exit(1) 1936 1947 1937 1948 output_dir = '' ··· 1945 1956 if o in ('-p', '--prefix'): 1946 1957 match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) 1947 1958 if match.end() != len(a): 1948 - print >>sys.stderr, \ 1949 - "%s: 'funny character '%s' in argument of --prefix" \ 1950 - % (sys.argv[0], a[match.end()]) 1959 + print("%s: 'funny character '%s' in argument of --prefix" \ 1960 + % (sys.argv[0], a[match.end()]), file=sys.stderr) 1951 1961 sys.exit(1) 1952 1962 prefix = a 1953 1963 elif o in ('-o', '--output-dir'): ··· 1964 1974 do_h = True 1965 1975 1966 1976 if len(args) != 1: 1967 - print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0] 1977 + print("%s: need exactly one argument" % sys.argv[0], file=sys.stderr) 1968 1978 sys.exit(1) 1969 1979 fname = args[0] 1970 1980 ··· 1992 2002 if really: 1993 2003 return open(name, opt) 1994 2004 else: 1995 - import StringIO 1996 - return StringIO.StringIO() 2005 + return StringIO() 1997 2006 1998 2007 fdef = maybe_open(do_c, c_file, 'w') 1999 2008 fdecl = maybe_open(do_h, h_file, 'w')
+6 -5
scripts/qapi2texi.py
··· 4 4 # This work is licensed under the terms of the GNU LGPL, version 2+. 5 5 # See the COPYING file in the top-level directory. 6 6 """This script produces the documentation of a qapi schema in texinfo format""" 7 + from __future__ import print_function 7 8 import re 8 9 import sys 9 10 ··· 145 146 def texi_members(doc, what, base, variants, member_func): 146 147 """Format the table of members""" 147 148 items = '' 148 - for section in doc.args.itervalues(): 149 + for section in doc.args.values(): 149 150 # TODO Drop fallbacks when undocumented members are outlawed 150 151 if section.text: 151 152 desc = texi_format(section.text) ··· 274 275 def main(argv): 275 276 """Takes schema argument, prints result to stdout""" 276 277 if len(argv) != 2: 277 - print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] 278 + print("%s: need exactly 1 argument: SCHEMA" % argv[0], file=sys.stderr) 278 279 sys.exit(1) 279 280 280 281 schema = qapi.QAPISchema(argv[1]) 281 282 if not qapi.doc_required: 282 - print >>sys.stderr, ("%s: need pragma 'doc-required' " 283 - "to generate documentation" % argv[0]) 283 + print("%s: need pragma 'doc-required' " 284 + "to generate documentation" % argv[0], file=sys.stderr) 284 285 sys.exit(1) 285 - print texi_schema(schema) 286 + print(texi_schema(schema)) 286 287 287 288 288 289 if __name__ == '__main__':
+62 -32
scripts/qemu.py
··· 15 15 import errno 16 16 import logging 17 17 import os 18 - import sys 19 18 import subprocess 20 19 import qmp.qmp 20 + import shutil 21 + import tempfile 21 22 22 23 23 24 LOG = logging.getLogger(__name__) ··· 73 74 wrapper = [] 74 75 if name is None: 75 76 name = "qemu-%d" % os.getpid() 76 - if monitor_address is None: 77 - monitor_address = os.path.join(test_dir, name + "-monitor.sock") 77 + self._name = name 78 78 self._monitor_address = monitor_address 79 - self._qemu_log_path = os.path.join(test_dir, name + ".log") 79 + self._vm_monitor = None 80 + self._qemu_log_path = None 81 + self._qemu_log_file = None 80 82 self._popen = None 81 83 self._binary = binary 82 84 self._args = list(args) # Force copy args in case we modify them ··· 86 88 self._socket_scm_helper = socket_scm_helper 87 89 self._qmp = None 88 90 self._qemu_full_args = None 91 + self._test_dir = test_dir 92 + self._temp_dir = None 93 + self._launched = False 89 94 90 95 # just in case logging wasn't configured by the main script: 91 96 logging.basicConfig() ··· 146 151 raise 147 152 148 153 def is_running(self): 149 - return self._popen is not None and self._popen.returncode is None 154 + return self._popen is not None and self._popen.poll() is None 150 155 151 156 def exitcode(self): 152 157 if self._popen is None: 153 158 return None 154 - return self._popen.returncode 159 + return self._popen.poll() 155 160 156 161 def get_pid(self): 157 162 if not self.is_running(): ··· 159 164 return self._popen.pid 160 165 161 166 def _load_io_log(self): 162 - with open(self._qemu_log_path, "r") as iolog: 163 - self._iolog = iolog.read() 167 + if self._qemu_log_path is not None: 168 + with open(self._qemu_log_path, "r") as iolog: 169 + self._iolog = iolog.read() 164 170 165 171 def _base_args(self): 166 172 if isinstance(self._monitor_address, tuple): ··· 168 174 self._monitor_address[0], 169 175 self._monitor_address[1]) 170 176 else: 171 - moncdev = 'socket,id=mon,path=%s' % self._monitor_address 177 + moncdev = 'socket,id=mon,path=%s' % self._vm_monitor 172 178 return ['-chardev', moncdev, 173 179 '-mon', 'chardev=mon,mode=control', 174 180 '-display', 'none', '-vga', 'none'] 175 181 176 182 def _pre_launch(self): 177 - self._qmp = qmp.qmp.QEMUMonitorProtocol(self._monitor_address, 183 + self._temp_dir = tempfile.mkdtemp(dir=self._test_dir) 184 + if self._monitor_address is not None: 185 + self._vm_monitor = self._monitor_address 186 + else: 187 + self._vm_monitor = os.path.join(self._temp_dir, 188 + self._name + "-monitor.sock") 189 + self._qemu_log_path = os.path.join(self._temp_dir, self._name + ".log") 190 + self._qemu_log_file = open(self._qemu_log_path, 'wb') 191 + 192 + self._qmp = qmp.qmp.QEMUMonitorProtocol(self._vm_monitor, 178 193 server=True) 179 194 180 195 def _post_launch(self): 181 196 self._qmp.accept() 182 197 183 198 def _post_shutdown(self): 184 - if not isinstance(self._monitor_address, tuple): 185 - self._remove_if_exists(self._monitor_address) 186 - self._remove_if_exists(self._qemu_log_path) 199 + if self._qemu_log_file is not None: 200 + self._qemu_log_file.close() 201 + self._qemu_log_file = None 202 + 203 + self._qemu_log_path = None 204 + 205 + if self._temp_dir is not None: 206 + shutil.rmtree(self._temp_dir) 207 + self._temp_dir = None 187 208 188 209 def launch(self): 189 - '''Launch the VM and establish a QMP connection''' 210 + """ 211 + Launch the VM and make sure we cleanup and expose the 212 + command line/output in case of exception 213 + """ 214 + 215 + if self._launched: 216 + raise QEMUMachineError('VM already launched') 217 + 190 218 self._iolog = None 191 219 self._qemu_full_args = None 192 - devnull = open(os.path.devnull, 'rb') 193 - qemulog = open(self._qemu_log_path, 'wb') 194 220 try: 195 - self._pre_launch() 196 - self._qemu_full_args = (self._wrapper + [self._binary] + 197 - self._base_args() + self._args) 198 - self._popen = subprocess.Popen(self._qemu_full_args, 199 - stdin=devnull, 200 - stdout=qemulog, 201 - stderr=subprocess.STDOUT, 202 - shell=False) 203 - self._post_launch() 221 + self._launch() 222 + self._launched = True 204 223 except: 205 - if self.is_running(): 206 - self._popen.kill() 207 - self._popen.wait() 208 - self._load_io_log() 209 - self._post_shutdown() 224 + self.shutdown() 210 225 211 226 LOG.debug('Error launching VM') 212 227 if self._qemu_full_args: ··· 215 230 LOG.debug('Output: %r', self._iolog) 216 231 raise 217 232 233 + def _launch(self): 234 + '''Launch the VM and establish a QMP connection''' 235 + devnull = open(os.path.devnull, 'rb') 236 + self._pre_launch() 237 + self._qemu_full_args = (self._wrapper + [self._binary] + 238 + self._base_args() + self._args) 239 + self._popen = subprocess.Popen(self._qemu_full_args, 240 + stdin=devnull, 241 + stdout=self._qemu_log_file, 242 + stderr=subprocess.STDOUT, 243 + shell=False) 244 + self._post_launch() 245 + 218 246 def wait(self): 219 247 '''Wait for the VM to power off''' 220 248 self._popen.wait() ··· 232 260 self._popen.kill() 233 261 self._popen.wait() 234 262 235 - self._load_io_log() 236 - self._post_shutdown() 263 + self._load_io_log() 264 + self._post_shutdown() 237 265 238 266 exitcode = self.exitcode() 239 267 if exitcode is not None and exitcode < 0: ··· 243 271 else: 244 272 command = '' 245 273 LOG.warn(msg, exitcode, command) 274 + 275 + self._launched = False 246 276 247 277 def qmp(self, cmd, conv_keys=True, **args): 248 278 '''Invoke a QMP command and return the response dict'''
+2 -2
scripts/signrom.py
··· 18 18 fout = open(sys.argv[2], 'wb') 19 19 20 20 magic = fin.read(2) 21 - if magic != '\x55\xaa': 21 + if magic != b'\x55\xaa': 22 22 sys.exit("%s: option ROM does not begin with magic 55 aa" % sys.argv[1]) 23 23 24 24 size_byte = ord(fin.read(1)) ··· 33 33 # Add padding if necessary, rounding the whole input to a multiple of 34 34 # 512 bytes according to the third byte of the input. 35 35 # size-1 because a final byte is added below to store the checksum. 36 - data = data.ljust(size-1, '\0') 36 + data = data.ljust(size-1, b'\0') 37 37 else: 38 38 if ord(data[-1:]) != 0: 39 39 sys.stderr.write('WARNING: ROM includes nonzero checksum\n')
+3 -3
tests/Makefile.include
··· 919 919 $^ >$*.test.out 2>$*.test.err; \ 920 920 echo $$? >$*.test.exit, \ 921 921 "TEST","$*.out") 922 - @diff -q $(SRC_PATH)/$*.out $*.test.out 922 + @diff $(SRC_PATH)/$*.out $*.test.out 923 923 @# Sanitize error messages (make them independent of build directory) 924 - @perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err - 925 - @diff -q $(SRC_PATH)/$*.exit $*.test.exit 924 + @perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff $(SRC_PATH)/$*.err - 925 + @diff $(SRC_PATH)/$*.exit $*.test.exit 926 926 927 927 .PHONY: check-tests/qapi-schema/doc-good.texi 928 928 check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi
+2 -1
tests/docker/dockerfiles/fedora.docker
··· 1 1 FROM fedora:latest 2 2 ENV PACKAGES \ 3 - ccache gettext git tar PyYAML sparse flex bison python2 bzip2 hostname \ 3 + ccache gettext git tar PyYAML sparse flex bison python3 bzip2 hostname \ 4 4 glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel \ 5 5 gcc gcc-c++ clang make perl which bc findutils libaio-devel \ 6 6 nettle-devel libasan libubsan \ ··· 12 12 mingw64-gtk2 mingw64-gtk3 mingw64-gnutls mingw64-nettle mingw64-libtasn1 \ 13 13 mingw64-libjpeg-turbo mingw64-libpng mingw64-curl mingw64-libssh2 \ 14 14 mingw64-bzip2 15 + ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3 15 16 16 17 RUN dnf install -y $PACKAGES 17 18 RUN rpm -q $PACKAGES | sort > /packages.txt
+22 -21
tests/qapi-schema/test-qapi.py
··· 10 10 # See the COPYING file in the top-level directory. 11 11 # 12 12 13 + from __future__ import print_function 13 14 from qapi import * 14 15 from pprint import pprint 15 16 import os ··· 18 19 19 20 class QAPISchemaTestVisitor(QAPISchemaVisitor): 20 21 def visit_enum_type(self, name, info, values, prefix): 21 - print 'enum %s %s' % (name, values) 22 + print('enum %s %s' % (name, values)) 22 23 if prefix: 23 - print ' prefix %s' % prefix 24 + print(' prefix %s' % prefix) 24 25 25 26 def visit_object_type(self, name, info, base, members, variants): 26 - print 'object %s' % name 27 + print('object %s' % name) 27 28 if base: 28 - print ' base %s' % base.name 29 + print(' base %s' % base.name) 29 30 for m in members: 30 - print ' member %s: %s optional=%s' % \ 31 - (m.name, m.type.name, m.optional) 31 + print(' member %s: %s optional=%s' % \ 32 + (m.name, m.type.name, m.optional)) 32 33 self._print_variants(variants) 33 34 34 35 def visit_alternate_type(self, name, info, variants): 35 - print 'alternate %s' % name 36 + print('alternate %s' % name) 36 37 self._print_variants(variants) 37 38 38 39 def visit_command(self, name, info, arg_type, ret_type, 39 40 gen, success_response, boxed): 40 - print 'command %s %s -> %s' % \ 41 - (name, arg_type and arg_type.name, ret_type and ret_type.name) 42 - print ' gen=%s success_response=%s boxed=%s' % \ 43 - (gen, success_response, boxed) 41 + print('command %s %s -> %s' % \ 42 + (name, arg_type and arg_type.name, ret_type and ret_type.name)) 43 + print(' gen=%s success_response=%s boxed=%s' % \ 44 + (gen, success_response, boxed)) 44 45 45 46 def visit_event(self, name, info, arg_type, boxed): 46 - print 'event %s %s' % (name, arg_type and arg_type.name) 47 - print ' boxed=%s' % boxed 47 + print('event %s %s' % (name, arg_type and arg_type.name)) 48 + print(' boxed=%s' % boxed) 48 49 49 50 @staticmethod 50 51 def _print_variants(variants): 51 52 if variants: 52 - print ' tag %s' % variants.tag_member.name 53 + print(' tag %s' % variants.tag_member.name) 53 54 for v in variants.variants: 54 - print ' case %s: %s' % (v.name, v.type.name) 55 + print(' case %s: %s' % (v.name, v.type.name)) 55 56 56 57 schema = QAPISchema(sys.argv[1]) 57 58 schema.visit(QAPISchemaTestVisitor()) 58 59 59 60 for doc in schema.docs: 60 61 if doc.symbol: 61 - print 'doc symbol=%s' % doc.symbol 62 + print('doc symbol=%s' % doc.symbol) 62 63 else: 63 - print 'doc freeform' 64 - print ' body=\n%s' % doc.body.text 65 - for arg, section in doc.args.iteritems(): 66 - print ' arg=%s\n%s' % (arg, section.text) 64 + print('doc freeform') 65 + print(' body=\n%s' % doc.body.text) 66 + for arg, section in doc.args.items(): 67 + print(' arg=%s\n%s' % (arg, section.text)) 67 68 for section in doc.sections: 68 - print ' section=%s\n%s' % (section.name, section.text) 69 + print(' section=%s\n%s' % (section.name, section.text))