python: avoid creating additional event loops per thread
"Too hasty by far!", commit 21ce2ee4 attempted to avoid deprecated behavior altogether by calling new_event_loop() directly if there was no loop currently running, but this has the unfortunate side effect of potentially creating multiple event loops per thread if tests instantiate multiple QMP connections in a single thread. This behavior is apparently not well-defined and causes problems in some, but not all, combinations of Python interpreter version and platform environment.
Partially revert to Daniel Berrange's original patch, which calls get_event_loop and simply suppresses the deprecation warning in Python<=3.13. This time, however, additionally register new loops created with new_event_loop() so that future calls to get_event_loop() will return the loop already created.
Dan: This is almost identical to your original patch (ugh) except that it registers the new loop so subsequent QMP connections within a single thread will share the same event loop, avoiding various issues during teardown. Registering the loop also (appears to) delegate cleanup of the loop to Python itself, removing the need for __del__ time cleanup of the loop resource itself.
This time, I tested both python-qemu-qmp locally and via pipeline, and backported the changes to qemu.git and ran a full pipeline there as well as locally testing it. To the very best of my ability, I believe this is safe and correct. See https://gitlab.com/jsnow/qemu/-/pipelines/2012358178 for the qemu.git pipeline which incorporates all changes made to python-qemu-qmp thus far, as well as integrating all of your changes designed to eliminate any deprecated behavior.