CSIT-514: Kill Qemu when it does not respond
[csit.git] / resources / libraries / python / QemuUtils.py
index 8ee9725..a4e14d2 100644 (file)
@@ -18,7 +18,7 @@ import json
 
 from robot.api import logger
 
-from resources.libraries.python.ssh import SSH
+from resources.libraries.python.ssh import SSH, SSHTimeout
 from resources.libraries.python.constants import Constants
 from resources.libraries.python.topology import NodeType
 
@@ -292,8 +292,8 @@ class QemuUtils(object):
             if time() - start > timeout:
                 raise RuntimeError('timeout, VM {0} not booted on {1}'.format(
                     self._qemu_opt['disk_image'], self._node['host']))
-            self._qemu_qga_flush()
             try:
+                self._qemu_qga_flush()
                 out = self._qemu_qga_exec('guest-ping')
             except ValueError:
                 logger.trace('QGA guest-ping unexpected output {}'.format(out))
@@ -519,7 +519,7 @@ class QemuUtils(object):
         # Wait until VM boot
         try:
             self._wait_until_vm_boot()
-        except RuntimeError:
+        except (RuntimeError, SSHTimeout):
             self.qemu_kill()
             self.qemu_clear_socks()
             raise