nixos/test-driver: Crash on closed socket during connect()

If a VM crashes during `connect()`, e.g. because of `panic_on_fail`
during initrd, we would spin on the closed socket forever. We should
rasie an exception instead.
This commit is contained in:
Will Fancher
2025-09-14 19:12:10 -04:00
parent ab0f3607a6
commit 90e7c6f90c

View File

@@ -819,9 +819,8 @@ class Machine:
while True: while True:
chunk = self.shell.recv(1024) chunk = self.shell.recv(1024)
# No need to print empty strings, it means we are waiting.
if len(chunk) == 0: if len(chunk) == 0:
continue raise RuntimeError("Shell disconnected")
self.log(f"Guest shell says: {chunk!r}") self.log(f"Guest shell says: {chunk!r}")
# NOTE: for this to work, nothing must be printed after this line! # NOTE: for this to work, nothing must be printed after this line!
if b"Spawning backdoor root shell..." in chunk: if b"Spawning backdoor root shell..." in chunk: