Python queue, 2019-07-01
The following changes since commit 7d0e02405fc02a181319b1ab8681d2f72246b7c6:
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-patches-pull-request' into staging (2019-07-01 17:40:32 +0100)
are available in the Git repository at:
git://github.com/ehabkost/qemu.git tags/python-next-pull-request
for you to fetch changes up to e5abf59eae5990296c243202f95f801495c52e76:
Deprecate Python 2 support (2019-07-01 19:02:10 -0300)
----------------------------------------------------------------
Python queue, 2019-07-01
* Deprecate Python 2 support (Eduardo Habkost)
* qemu/__init__.py refactor (John Snow)
* make qmp-shell work with python3 (Igor Mammedov)
----------------------------------------------------------------
Eduardo Habkost (1):
Deprecate Python 2 support
Igor Mammedov (1):
qmp: make qmp-shell work with python3
John Snow (2):
python/qemu: split QEMUMachine out from underneath __init__.py machine.py: minor delinting
configure | 8 + scripts/render_block_graph.py | 2 +- python/qemu/__init__.py | 502 +------------------- python/qemu/machine.py | 531 ++++++++++++++++++++++ python/qemu/qtest.py | 2 +- qemu-deprecated.texi | 8 + scripts/device-crash-test | 2 +- scripts/qmp/qmp-shell | 5 +- tests/acceptance/avocado_qemu/__init__.py | 2 +- tests/acceptance/virtio_version.py | 2 +- tests/migration/guestperf/engine.py | 24 +- tests/qemu-iotests/235 | 2 +- tests/vm/basevm.py | 3 +- 13 files changed, 572 insertions(+), 521 deletions(-) create mode 100644 python/qemu/machine.py
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[Qemu-devel] [PULL 2/4] python/qemu: split QEMUMachine out from underneath __init__.py
From: John Snow <[email protected]>
It's not obvious that something named __init__.py actually houses important code that isn't relevant to python packaging glue. Move the QEMUMachine and related error classes out into their own module.
Adjust users to the new import location.
Message-Id: <[email protected]>
--- scripts/render_block_graph.py | 2 +- python/qemu/__init__.py | 502 +-------------------- python/qemu/machine.py | 520 ++++++++++++++++++++++ python/qemu/qtest.py | 2 +- scripts/device-crash-test | 2 +- tests/acceptance/avocado_qemu/__init__.py | 2 +- tests/acceptance/virtio_version.py | 2 +- tests/migration/guestperf/engine.py | 24 +- tests/qemu-iotests/235 | 2 +- tests/vm/basevm.py | 3 +- 10 files changed, 541 insertions(+), 520 deletions(-) create mode 100644 python/qemu/machine.py
scripts/render_block_graph.py +1 -1
@@ -25,7 +25,7 @@ import json from graphviz import Digraph sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu import MonitorResponseError +from qemu.machine import MonitorResponseError def perm(arr):
python/qemu/__init__.py +1 -501
515 lines not on this page · raw message
python/qemu/machine.py new file +520 -0
520 lines not on this page · raw message
python/qemu/qtest.py +1 -1
@@ -14,7 +14,7 @@ import socket import os -from . import QEMUMachine +from .machine import QEMUMachine class QEMUQtestProtocol(object):
scripts/device-crash-test +1 -1
@@ -36,7 +36,7 @@ import argparse from itertools import chain sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu import QEMUMachine +from qemu.machine import QEMUMachine logger = logging.getLogger('device-crash-test') dbg = logger.debug
tests/acceptance/avocado_qemu/__init__.py +1 -1
@@ -17,7 +17,7 @@ import avocado SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..') sys.path.append(os.path.join(SRC_ROOT_DIR, 'python')) -from qemu import QEMUMachine +from qemu.machine import QEMUMachine def is_readable_executable_file(path): return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
tests/acceptance/virtio_version.py +1 -1
@@ -12,7 +12,7 @@ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import QEMUMachine +from qemu.machine import QEMUMachine from avocado_qemu import Test # Virtio Device IDs:
tests/migration/guestperf/engine.py +12 -12
@@ -30,7 +30,7 @@ from guestperf.timings import TimingRecord, Timings sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'python')) -import qemu +from qemu.machine import QEMUMachine class Engine(object):
@@ -386,17 +386,17 @@ class Engine(object): dstmonaddr = "/var/tmp/qemu-dst-%d-monitor.sock" % os.getpid() srcmonaddr = "/var/tmp/qemu-src-%d-monitor.sock" % os.getpid() - src = qemu.QEMUMachine(self._binary, - args=self._get_src_args(hardware), - wrapper=self._get_src_wrapper(hardware), - name="qemu-src-%d" % os.getpid(), - monitor_address=srcmonaddr) - - dst = qemu.QEMUMachine(self._binary, - args=self._get_dst_args(hardware, uri), - wrapper=self._get_dst_wrapper(hardware), - name="qemu-dst-%d" % os.getpid(), - monitor_address=dstmonaddr) + src = QEMUMachine(self._binary, + args=self._get_src_args(hardware), + wrapper=self._get_src_wrapper(hardware), + name="qemu-src-%d" % os.getpid(), + monitor_address=srcmonaddr) + + dst = QEMUMachine(self._binary, + args=self._get_dst_args(hardware, uri), + wrapper=self._get_dst_wrapper(hardware), + name="qemu-dst-%d" % os.getpid(), + monitor_address=dstmonaddr) try: src.launch()
tests/qemu-iotests/235 +1 -1
@@ -25,7 +25,7 @@ from iotests import qemu_img_create, qemu_io, file_path, log sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import QEMUMachine +from qemu.machine import QEMUMachine # Note: # This test was added to check that mirror dead-lock was fixed (see previous
tests/vm/basevm.py +2 -1
@@ -18,7 +18,8 @@ import logging import time import datetime sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu import QEMUMachine, kvm_available +from qemu import kvm_available +from qemu.machine import QEMUMachine import subprocess import hashlib import optparse
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[Qemu-devel] [PULL 1/4] qmp: make qmp-shell work with python3
In reply to Eduardo HabkostFrom: Igor Mammedov <[email protected]>
python3 doesn't have raw_input(), so qmp-shell breaks. Use input() instead and override it with raw_input() if running on python2.
Message-Id: <[email protected]>
--- scripts/qmp/qmp-shell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/qmp/qmp-shell +4 -1
@@ -78,6 +78,9 @@ import re sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qmp +if sys.version_info[0] == 2: + input = raw_input + class QMPCompleter(list): def complete(self, text, state): for cmd in self:
@@ -308,7 +311,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): @return True if execution was ok, return False if disconnected. """ try: - cmdline = raw_input(prompt) + cmdline = input(prompt) except EOFError: print() return False
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[Qemu-devel] [PULL 3/4] machine.py: minor delinting
In reply to Eduardo HabkostFrom: John Snow <[email protected]>
Since we're out in a new module, do a quick cursory pass of some of the more obvious style issues.
Message-Id: <[email protected]>
--- python/qemu/machine.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
python/qemu/machine.py +22 -11
@@ -1,5 +1,10 @@ -# QEMU library -# +""" +QEMU machine module: + +The machine module primarily provides the QEMUMachine class, +which provides facilities for managing the lifetime of a QEMU VM. +""" + # Copyright (C) 2015-2016 Red Hat Inc. # Copyright (C) 2012 IBM Corp. #
@@ -16,7 +21,6 @@ import errno import logging import os import subprocess -import re import shutil import socket import tempfile
@@ -119,8 +123,10 @@ class QEMUMachine(object): self.shutdown() return False - # This can be used to add an unused monitor instance. def add_monitor_null(self): + """ + This can be used to add an unused monitor instance. + """ self._args.append('-monitor') self._args.append('null')
@@ -143,10 +149,13 @@ class QEMUMachine(object): self._args.append(','.join(options)) return self - # Exactly one of fd and file_path must be given. - # (If it is file_path, the helper will open that file and pass its - # own fd) def send_fd_scm(self, fd=None, file_path=None): + """ + Send an fd or file_path to socket_scm_helper. + + Exactly one of fd and file_path must be given. + If it is file_path, the helper will open that file and pass its own fd. + """ # In iotest.py, the qmp should always use unix socket. assert self._qmp.is_scm_available() if self._socket_scm_helper is None:
@@ -194,14 +203,17 @@ class QEMUMachine(object): raise def is_running(self): + """Returns true if the VM is running.""" return self._popen is not None and self._popen.poll() is None def exitcode(self): + """Returns the exit code if possible, or None.""" if self._popen is None: return None return self._popen.poll() def get_pid(self): + """Returns the PID of the running process, or None.""" if not self.is_running(): return None return self._popen.pid
@@ -339,7 +351,7 @@ class QEMUMachine(object): command = ' '.join(self._qemu_full_args) else: command = '' - LOG.warn(msg, -exitcode, command) + LOG.warning(msg, -exitcode, command) self._launched = False
@@ -373,7 +385,7 @@ class QEMUMachine(object): """ Poll for one queued QMP events and return it """ - if len(self._events) > 0: + if self._events: return self._events.pop(0) return self._qmp.pull_event(wait=wait)
@@ -441,8 +453,7 @@ class QEMUMachine(object): """ def _match(event): for name, match in events: - if (event['event'] == name and - self.event_match(event, match)): + if event['event'] == name and self.event_match(event, match): return True return False
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[Qemu-devel] [PULL 4/4] Deprecate Python 2 support
In reply to Eduardo HabkostPython 2 will reach end of life in January 1 2020. Declare it as deprecated.
Message-Id: <[email protected]>
--- configure | 8 ++++++++ qemu-deprecated.texi | 8 ++++++++ 2 files changed, 16 insertions(+)
configure +8 -0
@@ -6502,6 +6502,14 @@ if test "$supported_os" = "no"; then echo "us upstream at [email protected]." fi +# Note that if the Python conditional here evaluates True we will exit +# with status 1 which is a shell 'false' value. +if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then + echo + echo "warning: Python 2 support is deprecated" >&2 + echo "warning: Python 3 will be required for building future versions of QEMU" >&2 +fi + config_host_mak="config-host.mak" echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
qemu-deprecated.texi +8 -0
@@ -243,3 +243,11 @@ Note that if you are exposing the export via /dev/nbd0, it is easier to just export the entire image and then mount only /dev/nbd0p1 than it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a subset of the image. + +@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.
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Peter Maydell
AppliedQuoted 11 lines · Eduardo Habkost
The following changes since commit
7d0e02405fc02a181319b1ab8681d2f72246b7c6:Merge remote-tracking branch 'remotes/vivier2/tags/trivial-patches-pull-request' into staging (2019-07-01 17:40:32 +0100)
are available in the Git repository at:
git://github.com/ehabkost/qemu.gittags/python-next-pull-requestfor you to fetch changes up to
e5abf59eae5990296c243202f95f801495c52e76:
Quoted 9 lines
Deprecate Python 2 support (2019-07-01 19:02:10 -0300)
----------------------------------------------------------------
Python queue, 2019-07-01* Deprecate Python 2 support (Eduardo Habkost)
*qemu/__init__.pyrefactor (John Snow)
* make qmp-shell work with python3 (Igor Mammedov)
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.
(In particular we should flag up the python 2 deprecation in the 'build information' section.)
-- PMM