mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
65bd5da471
commit
1488baea7a
2 changed files with 23 additions and 3 deletions
|
|
@ -66,7 +66,7 @@ class ConsoleWorkerTests(TestCase):
|
|||
console.domain = MagicMock()
|
||||
console.stream = None # from_vm dropped it at the stream's end
|
||||
console.active = True
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_SHUTOFF]
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_SHUTOFF, 0]
|
||||
with patch.object(self.cb, "say") as say:
|
||||
console.check()
|
||||
console.check()
|
||||
|
|
@ -77,7 +77,7 @@ class ConsoleWorkerTests(TestCase):
|
|||
console.domain, console.connection = MagicMock(), MagicMock()
|
||||
console.stream = None
|
||||
console.active = True
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_RUNNING]
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_RUNNING, 0]
|
||||
console.domain.openConsole.side_effect = self.cb.libvirt.libvirtError("domain is not running")
|
||||
console.domain.isActive.return_value = 0
|
||||
with patch.object(self.cb, "say") as say:
|
||||
|
|
@ -85,6 +85,21 @@ class ConsoleWorkerTests(TestCase):
|
|||
say.assert_called_once_with("The VM is not running: its console opens again when it starts")
|
||||
self.assertIsNone(console.stream)
|
||||
|
||||
def test_a_vm_being_started_is_waited_for(self):
|
||||
# its terminal is not assigned yet: opening its console then fails
|
||||
console = self.cb.Console.__new__(self.cb.Console)
|
||||
console.domain, console.connection = MagicMock(), MagicMock()
|
||||
console.stream = None
|
||||
console.active = False
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_PAUSED,
|
||||
self.cb.libvirt.VIR_DOMAIN_PAUSED_STARTING_UP]
|
||||
console.check()
|
||||
console.domain.openConsole.assert_not_called()
|
||||
console.domain.state.return_value = [self.cb.libvirt.VIR_DOMAIN_PAUSED, self.cb.libvirt.VIR_DOMAIN_PAUSED_USER]
|
||||
console.check()
|
||||
console.domain.openConsole.assert_called_once()
|
||||
self.assertTrue(console.active)
|
||||
|
||||
def test_a_closed_client_ends_the_worker(self):
|
||||
with patch.object(self.cb.os, "read", return_value=b""):
|
||||
self.cb.from_client(None, 0, None, self.console)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue