]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
python/machine.py: Add a configurable timeout to shutdown()
authorJohn Snow <jsnow@redhat.com>
Fri, 10 Jul 2020 05:06:43 +0000 (01:06 -0400)
committerPhilippe Mathieu-Daudé <philmd@redhat.com>
Tue, 14 Jul 2020 20:22:22 +0000 (22:22 +0200)
Three seconds is hardcoded. Use it as a default parameter instead, and use that
value for both waits that may occur in the function.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20200710050649.32434-7-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
python/qemu/machine.py

index c28957ee82f11a2eaca1bc4cf0ccc3369ff27cd2..e825f0bdc60e8fb8d67823ab6b3a6d13391c668d 100644 (file)
@@ -393,7 +393,9 @@ class QEMUMachine:
         self._popen.wait()
         self._post_shutdown()
 
-    def shutdown(self, has_quit=False, hard=False):
+    def shutdown(self, has_quit: bool = False,
+                 hard: bool = False,
+                 timeout: Optional[int] = 3) -> None:
         """
         Terminate the VM and clean up
         """
@@ -409,10 +411,10 @@ class QEMUMachine:
                 try:
                     if not has_quit:
                         self._qmp.cmd('quit')
-                    self._popen.wait(timeout=3)
+                    self._popen.wait(timeout=timeout)
                 except:
                     self._popen.kill()
-            self._popen.wait()
+            self._popen.wait(timeout=timeout)
 
         self._post_shutdown()