Skip to content

Commit 8226a4b

Browse files
jnsnowpm215
authored andcommitted
python/machine: Change default timeout to 30 seconds
3 seconds is too short for some tests running inside busy VMs. Build it out to a rather generous 30 seconds to find out conclusively if there are more severe problems in the merge/CI tests. Signed-off-by: John Snow <[email protected]> Reviewed-by: Eduardo Habkost <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent e68808a commit 8226a4b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

python/qemu/machine.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,15 @@ def _hard_shutdown(self) -> None:
394394
self._popen.kill()
395395
self._popen.wait(timeout=60)
396396

397-
def _soft_shutdown(self, has_quit: bool = False,
398-
timeout: Optional[int] = 3) -> None:
397+
def _soft_shutdown(self, timeout: Optional[int],
398+
has_quit: bool = False) -> None:
399399
"""
400400
Perform early cleanup, attempt to gracefully shut down the VM, and wait
401401
for it to terminate.
402402
403+
:param timeout: Timeout in seconds for graceful shutdown.
404+
A value of None is an infinite wait.
403405
:param has_quit: When True, don't attempt to issue 'quit' QMP command
404-
:param timeout: Optional timeout in seconds for graceful shutdown.
405-
Default 3 seconds, A value of None is an infinite wait.
406406
407407
:raise ConnectionReset: On QMP communication errors
408408
:raise subprocess.TimeoutExpired: When timeout is exceeded waiting for
@@ -418,30 +418,30 @@ def _soft_shutdown(self, has_quit: bool = False,
418418
# May raise subprocess.TimeoutExpired
419419
self._popen.wait(timeout=timeout)
420420

421-
def _do_shutdown(self, has_quit: bool = False,
422-
timeout: Optional[int] = 3) -> None:
421+
def _do_shutdown(self, timeout: Optional[int],
422+
has_quit: bool = False) -> None:
423423
"""
424424
Attempt to shutdown the VM gracefully; fallback to a hard shutdown.
425425
426+
:param timeout: Timeout in seconds for graceful shutdown.
427+
A value of None is an infinite wait.
426428
:param has_quit: When True, don't attempt to issue 'quit' QMP command
427-
:param timeout: Optional timeout in seconds for graceful shutdown.
428-
Default 3 seconds, A value of None is an infinite wait.
429429
430430
:raise AbnormalShutdown: When the VM could not be shut down gracefully.
431431
The inner exception will likely be ConnectionReset or
432432
subprocess.TimeoutExpired. In rare cases, non-graceful termination
433433
may result in its own exceptions, likely subprocess.TimeoutExpired.
434434
"""
435435
try:
436-
self._soft_shutdown(has_quit, timeout)
436+
self._soft_shutdown(timeout, has_quit)
437437
except Exception as exc:
438438
self._hard_shutdown()
439439
raise AbnormalShutdown("Could not perform graceful shutdown") \
440440
from exc
441441

442442
def shutdown(self, has_quit: bool = False,
443443
hard: bool = False,
444-
timeout: Optional[int] = 3) -> None:
444+
timeout: Optional[int] = 30) -> None:
445445
"""
446446
Terminate the VM (gracefully if possible) and perform cleanup.
447447
Cleanup will always be performed.
@@ -453,7 +453,7 @@ def shutdown(self, has_quit: bool = False,
453453
:param hard: When true, do not attempt graceful shutdown, and
454454
suppress the SIGKILL warning log message.
455455
:param timeout: Optional timeout in seconds for graceful shutdown.
456-
Default 3 seconds, A value of None is an infinite wait.
456+
Default 30 seconds, A `None` value is an infinite wait.
457457
"""
458458
if not self._launched:
459459
return
@@ -463,7 +463,7 @@ def shutdown(self, has_quit: bool = False,
463463
self._user_killed = True
464464
self._hard_shutdown()
465465
else:
466-
self._do_shutdown(has_quit, timeout=timeout)
466+
self._do_shutdown(timeout, has_quit)
467467
finally:
468468
self._post_shutdown()
469469

@@ -473,12 +473,12 @@ def kill(self):
473473
"""
474474
self.shutdown(hard=True)
475475

476-
def wait(self, timeout: Optional[int] = 3) -> None:
476+
def wait(self, timeout: Optional[int] = 30) -> None:
477477
"""
478478
Wait for the VM to power off and perform post-shutdown cleanup.
479479
480-
:param timeout: Optional timeout in seconds.
481-
Default 3 seconds, A value of None is an infinite wait.
480+
:param timeout: Optional timeout in seconds. Default 30 seconds.
481+
A value of `None` is an infinite wait.
482482
"""
483483
self.shutdown(has_quit=True, timeout=timeout)
484484

0 commit comments

Comments
 (0)