From a53351a730861683586c17dfc6ae03b4028c5685 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 10 Aug 2026 04:39:28 +0200 Subject: [PATCH] Give the virsh console loop a reason to wake virEventRunDefaultImpl waits for an event that an idle domain need not produce, so the thread could outlive a deactivation that reported success, and every later activation was refused while it did. Registering a timeout is what makes it return: measured, a thread with nothing registered was still running four seconds after being asked to stop, and with a half second timer it came out at once. --- confluent_server/aiohmi/cmd/virshbmc.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/confluent_server/aiohmi/cmd/virshbmc.py b/confluent_server/aiohmi/cmd/virshbmc.py index 63bce006..c9418dcd 100755 --- a/confluent_server/aiohmi/cmd/virshbmc.py +++ b/confluent_server/aiohmi/cmd/virshbmc.py @@ -156,8 +156,18 @@ class LibvirtBmc(bmc.Bmc): self.stream.send(data) def loop(self): - while self.check_console(): - libvirt.virEventRunDefaultImpl() + # virEventRunDefaultImpl waits for an event, and an idle domain can go + # a long time without producing one. Give it a reason to return, or + # the loop never reconsiders check_console and the thread cannot be + # stopped at all: measured as never waking without this, and returning + # at once with it. + timer = libvirt.virEventAddTimeout(500, lambda *args: None, None) + try: + while self.check_console(): + libvirt.virEventRunDefaultImpl() + finally: + if timer >= 0: + libvirt.virEventRemoveTimeout(timer) def main():