python/machine: permanently switch to AQMP

Remove the QEMU_PYTHON_LEGACY_QMP environment variable, making the
switch from sync qmp to async qmp permanent. Update exceptions and
import paths as necessary.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Beraldo Leal <bleal@redhat.com>
Acked-by: Hanna Reitz <hreitz@redhat.com>
Message-id: 20220321203315.909411-2-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
John Snow 2022-03-21 16:33:12 -04:00
parent b1efff6bf0
commit a4225303a1
2 changed files with 8 additions and 12 deletions

View file

@ -40,21 +40,16 @@ from typing import (
TypeVar, TypeVar,
) )
from qemu.qmp import ( # pylint: disable=import-error from qemu.aqmp import SocketAddrT
from qemu.aqmp.legacy import (
QEMUMonitorProtocol,
QMPMessage, QMPMessage,
QMPReturnValue, QMPReturnValue,
SocketAddrT,
) )
from . import console_socket from . import console_socket
if os.environ.get('QEMU_PYTHON_LEGACY_QMP'):
from qemu.qmp import QEMUMonitorProtocol
else:
from qemu.aqmp.legacy import QEMUMonitorProtocol
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -743,8 +738,9 @@ class QEMUMachine:
:param timeout: Optional timeout, in seconds. :param timeout: Optional timeout, in seconds.
See QEMUMonitorProtocol.pull_event. See QEMUMonitorProtocol.pull_event.
:raise QMPTimeoutError: If timeout was non-zero and no matching events :raise asyncio.TimeoutError:
were found. If timeout was non-zero and no matching events were found.
:return: A QMP event matching the filter criteria. :return: A QMP event matching the filter criteria.
If timeout was 0 and no event matched, None. If timeout was 0 and no event matched, None.
""" """
@ -767,7 +763,7 @@ class QEMUMachine:
event = self._qmp.pull_event(wait=timeout) event = self._qmp.pull_event(wait=timeout)
if event is None: if event is None:
# NB: None is only returned when timeout is false-ish. # NB: None is only returned when timeout is false-ish.
# Timeouts raise QMPTimeoutError instead! # Timeouts raise asyncio.TimeoutError instead!
break break
if _match(event): if _match(event):
return event return event

View file

@ -26,7 +26,7 @@ from typing import (
TextIO, TextIO,
) )
from qemu.qmp import SocketAddrT # pylint: disable=import-error from qemu.aqmp import SocketAddrT
from .machine import QEMUMachine from .machine import QEMUMachine