diff options
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu/0012-Remove-deprecated-get_event_loop-calls.patch | 85 |
2 files changed, 86 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index 7893df0df2..2ee76e9a7c 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
| @@ -31,6 +31,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ | |||
| 31 | file://0008-Define-MAP_SYNC-and-MAP_SHARED_VALIDATE-on-needed-li.patch \ | 31 | file://0008-Define-MAP_SYNC-and-MAP_SHARED_VALIDATE-on-needed-li.patch \ |
| 32 | file://0010-configure-lookup-meson-exutable-from-PATH.patch \ | 32 | file://0010-configure-lookup-meson-exutable-from-PATH.patch \ |
| 33 | file://0011-qemu-Ensure-pip-and-the-python-venv-aren-t-used-for-.patch \ | 33 | file://0011-qemu-Ensure-pip-and-the-python-venv-aren-t-used-for-.patch \ |
| 34 | file://0012-Remove-deprecated-get_event_loop-calls.patch \ | ||
| 34 | file://qemu-guest-agent.init \ | 35 | file://qemu-guest-agent.init \ |
| 35 | file://qemu-guest-agent.udev \ | 36 | file://qemu-guest-agent.udev \ |
| 36 | " | 37 | " |
diff --git a/meta/recipes-devtools/qemu/qemu/0012-Remove-deprecated-get_event_loop-calls.patch b/meta/recipes-devtools/qemu/qemu/0012-Remove-deprecated-get_event_loop-calls.patch new file mode 100644 index 0000000000..64816fe7d9 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0012-Remove-deprecated-get_event_loop-calls.patch | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | From 5240406747fd43886618ae8194153e6fc957a82a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: John Snow <jsnow@redhat.com> | ||
| 3 | Date: Tue, 13 Aug 2024 09:35:30 -0400 | ||
| 4 | Subject: [PATCH] Remove deprecated get_event_loop calls | ||
| 5 | |||
| 6 | This method was deprecated in 3.12 because it ordinarily should not be | ||
| 7 | used from coroutines; if there is not a currently running event loop, | ||
| 8 | this automatically creates a new event loop - which is usually not what | ||
| 9 | you want from code that would ever run in the bottom half. | ||
| 10 | |||
| 11 | In our case, we do want this behavior in two places: | ||
| 12 | |||
| 13 | (1) The synchronous shim, for convenience: this allows fully sync | ||
| 14 | programs to use QEMUMonitorProtocol() without needing to set up an event | ||
| 15 | loop beforehand. This is intentional to fully box in the async | ||
| 16 | complexities into the legacy sync shim. | ||
| 17 | |||
| 18 | (2) The qmp_tui shell; instead of relying on asyncio.run to create and | ||
| 19 | run an asyncio program, we need to be able to pass the current asyncio | ||
| 20 | loop to urwid setup functions. For convenience, again, we create one if | ||
| 21 | one is not present to simplify the creation of the TUI appliance. | ||
| 22 | |||
| 23 | The remaining user of get_event_loop() was in fact one of the erroneous | ||
| 24 | users that should not have been using this function: if there's no | ||
| 25 | running event loop inside of a coroutine, you're in big trouble :) | ||
| 26 | |||
| 27 | Upstream-Status: Backport [https://gitlab.com/qemu-project/python-qemu-qmp/-/merge_requests/33] | ||
| 28 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
| 29 | --- | ||
| 30 | python/qemu/qmp/legacy.py | 9 ++++++++- | ||
| 31 | python/qemu/qmp/qmp_tui.py | 7 ++++++- | ||
| 32 | python/tests/protocol.py | 2 +- | ||
| 33 | 3 files changed, 15 insertions(+), 3 deletions(-) | ||
| 34 | |||
| 35 | diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py | ||
| 36 | index 22a2b56..ea9b803 100644 | ||
| 37 | --- a/python/qemu/qmp/legacy.py | ||
| 38 | +++ b/python/qemu/qmp/legacy.py | ||
| 39 | @@ -86,7 +86,14 @@ def __init__(self, | ||
| 40 | "server argument should be False when passing a socket") | ||
| 41 | |||
| 42 | self._qmp = QMPClient(nickname) | ||
| 43 | - self._aloop = asyncio.get_event_loop() | ||
| 44 | + | ||
| 45 | + try: | ||
| 46 | + self._aloop = asyncio.get_running_loop() | ||
| 47 | + except RuntimeError: | ||
| 48 | + # No running loop; since this is a sync shim likely to be | ||
| 49 | + # used in fully sync programs, create one if neccessary. | ||
| 50 | + self._aloop = asyncio.get_event_loop_policy().get_event_loop() | ||
| 51 | + | ||
| 52 | self._address = address | ||
| 53 | self._timeout: Optional[float] = None | ||
| 54 | |||
| 55 | diff --git a/python/qemu/qmp/qmp_tui.py b/python/qemu/qmp/qmp_tui.py | ||
| 56 | index 2d9ebbd..d11b9fc 100644 | ||
| 57 | --- a/python/qemu/qmp/qmp_tui.py | ||
| 58 | +++ b/python/qemu/qmp/qmp_tui.py | ||
| 59 | @@ -377,7 +377,12 @@ def run(self, debug: bool = False) -> None: | ||
| 60 | screen = urwid.raw_display.Screen() | ||
| 61 | screen.set_terminal_properties(256) | ||
| 62 | |||
| 63 | - self.aloop = asyncio.get_event_loop() | ||
| 64 | + try: | ||
| 65 | + self.aloop = asyncio.get_running_loop() | ||
| 66 | + except RuntimeError: | ||
| 67 | + # No running asyncio event loop. Create one if necessary. | ||
| 68 | + self.aloop = asyncio.get_event_loop_policy().get_event_loop() | ||
| 69 | + | ||
| 70 | self.aloop.set_debug(debug) | ||
| 71 | |||
| 72 | # Gracefully handle SIGTERM and SIGINT signals | ||
| 73 | diff --git a/python/tests/protocol.py b/python/tests/protocol.py | ||
| 74 | index 56c4d44..8dcef57 100644 | ||
| 75 | --- a/python/tests/protocol.py | ||
| 76 | +++ b/python/tests/protocol.py | ||
| 77 | @@ -228,7 +228,7 @@ def async_test(async_test_method): | ||
| 78 | Decorator; adds SetUp and TearDown to async tests. | ||
| 79 | """ | ||
| 80 | async def _wrapper(self, *args, **kwargs): | ||
| 81 | - loop = asyncio.get_event_loop() | ||
| 82 | + loop = asyncio.get_running_loop() | ||
| 83 | loop.set_debug(True) | ||
| 84 | |||
| 85 | await self._asyncSetUp() | ||
