Skip to content

Commit

Permalink
vt_console:Skip waiting screen when login via console
Browse files Browse the repository at this point in the history
To skip the UEFI guest reset process and prevent the forever waiting

Signed-off-by: Haijiao Zhao <haizhao@redhat.com>
  • Loading branch information
chloerh committed Jul 16, 2024
1 parent 72898b4 commit 220be4b
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions virttest/vt_console.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import logging
import threading
import time

from aexpect import remote

LOG = logging.getLogger("avocado." + __name__)


class ConsoleError(Exception):
"""A base class for console errors."""
Expand Down Expand Up @@ -73,14 +76,29 @@ def __login(
self._console.set_linesep(linesep)
self._console.set_status_test_command(status_test_command)

is_responsive = False
reset_str = "Press any key to stop system reset"
end_time = time.time() + timeout
while time.time() < end_time:
if self._console.is_responsive():
is_responsive = True
break
if not is_responsive:
raise ConsoleNotResponsiveError("Console is not responsive.")
self._console.read_nonblocking()
latest_output = "\n".join(self._console.get_output().splitlines()[-50:])

# If system is waiting for any key to stop reset, we'll wait after
# timeout(usually 5s) to avoid entering interactive screen
if reset_str in latest_output:
time.sleep(1)
continue
else:
# If the "Press any key to stop system reset" screen is passed,
# we don't need to wait anymore
if reset_str in self._console.get_output():
break
else:
# Only check output of the first 500 lines since the
# "system reset" screen appears at the beginning of
# system booting. If there's no such string in console
# within 500 lines, there shouldn't be any at all
if len(self._console.get_output().strip()) > 500:
break

remote.handle_prompts(self._console, username, password, prompt, timeout)

Expand Down

0 comments on commit 220be4b

Please sign in to comment.