Bug 2375004 - qemu tests fail with Python 3.14
Summary: qemu tests fail with Python 3.14
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: qemu
Version: rawhide
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14 F43FTBFS
TreeView+ depends on / blocked
 
Reported: 2025-06-26 17:14 UTC by Yaakov Selkowitz
Modified: 2025-07-15 20:46 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-07-15 18:30:34 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Yaakov Selkowitz 2025-06-26 17:14:04 UTC
rawhide: https://koji.fedoraproject.org/koji/taskinfo?taskID=134435155
eln: https://koji.fedoraproject.org/koji/taskinfo?taskID=134434490

Traceback (most recent call last):
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/python/qemu/machine/machine.py", line 448, in launch
    self._launch()
    ~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/python/qemu/machine/machine.py", line 475, in _launch
    self._pre_launch()
    ~~~~~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/python/qemu/machine/machine.py", line 349, in _pre_launch
    self._qmp_connection = QEMUMonitorProtocol(
                           ~~~~~~~~~~~~~~~~~~~^
        sock_or_addr,
        ^^^^^^^^^^^^^
        server=bool(self._monitor_address),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        nickname=self._name
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/python/qemu/qmp/legacy.py", line 89, in __init__
    self._aloop = asyncio.get_event_loop()
                  ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.14/asyncio/events.py", line 718, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
                       % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'MainThread'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/tests/functional/test_x86_cpu_model_versions.py", line 267, in test_4_0
    self.vm.launch()
    ~~~~~~~~~~~~~~^^
  File "/builddir/build/BUILD/qemu-10.0.2-build/qemu-10.0.2/python/qemu/machine/machine.py", line 461, in launch
    raise VMLaunchFailure(
    ...<3 lines>...
    ) from exc
qemu.machine.machine.VMLaunchFailure: RuntimeError: There is no current event loop in thread 'MainThread'.
	Command: 
	Output: None


Reproducible: Always

Comment 1 Miro Hrončok 2025-06-27 12:14:47 UTC
https://docs.python.org/3.14/whatsnew/3.14.html#id7

> Removed implicit creation of event loop by asyncio.get_event_loop(). It now raises a RuntimeError if there is no current event loop. https://github.com/python/cpython/issues/126353

Comment 2 Miro Hrončok 2025-07-15 09:45:50 UTC
This is now blocking a stoname bump in libcbor.

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/5CO7XNDVNYEQPREU4U2GCYNPII2WK2YT/

Please, respond.

Comment 3 Richard W.M. Jones 2025-07-15 09:55:46 UTC
I don't see any upstream fix yet.  Can you suggest a fix?  I'm neither an expert
in Python asyncio nor in QMP.  The code in python/qemu/qmp/legacy.py doesn't exactly
match any of the suggestions in the Python docs.

Comment 4 Miro Hrončok 2025-07-15 10:11:53 UTC
I'd try replacing:

  self._aloop = asyncio.get_event_loop()

With:

  try:
    self._aloop = asyncio.get_event_loop()
  except RuntimeError:
    self._aloop = asyncio.new_event_loop()


This should effectively revert to the behavior of Python < 3.14, as get_event_loop used to return a new event loop when there was no current event loop.

Comment 5 Daniel Berrangé 2025-07-15 10:29:08 UTC
What puzzles me is why we've never seen any deprecation warnings with python < 3.13, because if we were triggering the fallback 'create a new loop' code previously, we should have seen warnings. This makes me wonder if we've got further problems than just the headline event loop issue.

Comment 6 Richard W.M. Jones 2025-07-15 10:44:50 UTC
OK I reproduced this locally and implemented the fix as suggested by Miro above.

Comment 7 Miro Hrončok 2025-07-15 10:46:23 UTC
> What puzzles me is why we've never seen any deprecation warnings with python < 3.13

I am not sure the warning would propagate through the tests.

Comment 9 Daniel Berrangé 2025-07-15 11:11:45 UTC
(In reply to Daniel Berrangé from comment #5)
> What puzzles me is why we've never seen any deprecation warnings with python
> < 3.13, because if we were triggering the fallback 'create a new loop' code
> previously, we should have seen warnings. This makes me wonder if we've got
> further problems than just the headline event loop issue.

Urgh, python only emits warnings if triggered *directly* by the __main__ module, so any usage from imports never shows warnings. This is spectacularly unhelpful at alerting people to usage of deprecated features :-(

Comment 10 Richard W.M. Jones 2025-07-15 11:22:59 UTC
New Fedora build: https://koji.fedoraproject.org/koji/taskinfo?taskID=134838848

Comment 11 Richard W.M. Jones 2025-07-15 12:12:20 UTC
This failed to build on i686 with what might be a random failure.  I will
retry the build when all the other arches have finished.

 54/310 qemu:qtest+qtest-arm / qtest-arm/aspeed_smc-test                    ERROR           43.15s   killed by signal 6 SIGABRT

Comment 12 Richard W.M. Jones 2025-07-15 13:18:25 UTC
It also failed on ppc64 with a test timeout.

Here is a new build (unmodified): https://koji.fedoraproject.org/koji/taskinfo?taskID=134842457

Comment 13 Daniel Berrangé 2025-07-15 13:34:36 UTC
The ppc64 test failure was on 'test-replication' which normally takes only 2 seconds, so a 60 second timeout is a clear hang. I notice upstream there is report that this test causes 'tsan' thread safety warning, so further looks like a bug. I've filed this to track it:

https://gitlab.com/qemu-project/qemu/-/issues/3035

Comment 14 Richard W.M. Jones 2025-07-15 14:43:20 UTC
I cherry picked another patch from upstream to improve the stability of
a test that failed on x86_64 (thanks Dan!)

New build: https://koji.fedoraproject.org/koji/taskinfo?taskID=134842989

Comment 15 Richard W.M. Jones 2025-07-15 17:09:55 UTC
I added a further patch to increase the test-replication timeout, for:
https://gitlab.com/qemu-project/qemu/-/issues/3035

New build:

https://koji.fedoraproject.org/koji/taskinfo?taskID=134845860

Comment 16 Richard W.M. Jones 2025-07-15 18:30:34 UTC
Finally fixed in Rawhide - qemu-10.0.2-5.fc43

Comment 17 Miro Hrončok 2025-07-15 19:48:20 UTC
Thank you.

Comment 18 Yaakov Selkowitz 2025-07-15 20:46:13 UTC
For c10s (for merging back to ELN): https://gitlab.com/redhat/centos-stream/rpms/qemu-kvm/-/merge_requests/237


Note You need to log in before you can comment on or make changes to this bug.