1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00

fix(console): a serial console waits for its VM's start instead of closing

While a VM starts, libvirt shows it paused, reason "starting up", before
its devices are set up. The worker took that for a running VM, asked for
its console before the terminal existed ("PTY device is not yet assigned")
and closed, although it had just said that the console opens again when
the VM starts. A VM paused while starting up now counts as not running.
This commit is contained in:
catborise 2026-11-10 18:57:20 +03:00
parent b251741a27
commit ad6ee7f67c
2 changed files with 23 additions and 3 deletions

View file

@ -47,7 +47,12 @@ class Console:
def check(self):
"""Open the stream while the VM runs, drop it while it does not. The
stream may have ended first: the VM's stop is still reported."""
active = self.domain.state()[0] in (libvirt.VIR_DOMAIN_RUNNING, libvirt.VIR_DOMAIN_PAUSED)
state, reason = self.domain.state()
# a VM being started is paused until its devices are set up: its
# console has no terminal yet
active = state == libvirt.VIR_DOMAIN_RUNNING or (
state == libvirt.VIR_DOMAIN_PAUSED and reason != libvirt.VIR_DOMAIN_PAUSED_STARTING_UP
)
if active and self.stream is None:
stream = self.connection.newStream(libvirt.VIR_STREAM_NONBLOCK)
try: