aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2016-12-14 10:31:46 +0000
committerPeter Mikus <pmikus@cisco.com>2016-12-14 11:21:07 +0000
commit17e37d73121212028049a9c965319a2ad9c57ae5 (patch)
tree0c58f6705176eaa3fa55c3dead4e4b8303ad744f /resources
parent2415648fb8c852ca5f01ac37c5b36440472d6b18 (diff)
Fix: Qemu wait_until_vm_boot
There is an issue that booting Nested VM is successful but QGA guest-ping returns partial response. This fix suppose to do checking until an error or timeout occurs. In case of QGA returns correct response it is success. In case of partial response it will log an error and continue in checking. Change-Id: I8a2469287abaa9398a9206988e579912840f20c4 Signed-off-by: pmikus <pmikus@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/QemuUtils.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/resources/libraries/python/QemuUtils.py b/resources/libraries/python/QemuUtils.py
index 1e3a8aa6b6..8ee972533a 100644
--- a/resources/libraries/python/QemuUtils.py
+++ b/resources/libraries/python/QemuUtils.py
@@ -142,8 +142,7 @@ class QemuUtils(object):
raise ValueError('Host CPU count must match Qemu Thread count')
for qemu_cpu, host_cpu in zip(qemu_cpus, host_cpus):
- cmd = 'taskset -p {0} {1}'.format(hex(1 << int(host_cpu)),
- qemu_cpu['thread_id'])
+ cmd = 'taskset -pc {0} {1}'.format(host_cpu, qemu_cpu['thread_id'])
(ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd)
if int(ret_code) != 0:
logger.debug('Set affinity failed {0}'.format(stderr))
@@ -280,21 +279,24 @@ class QemuUtils(object):
return {}
return json.loads(stdout.split('\n', 1)[0])
- def _wait_until_vm_boot(self, timeout=300):
+ def _wait_until_vm_boot(self, timeout=60):
"""Wait until QEMU VM is booted.
Ping QEMU guest agent each 5s until VM booted or timeout.
- :param timeout: Waiting timeout in seconds (optional, default 300s).
+ :param timeout: Waiting timeout in seconds (optional, default 60s).
:type timeout: int
"""
start = time()
- while 1:
+ while True:
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()
- out = self._qemu_qga_exec('guest-ping')
+ try:
+ out = self._qemu_qga_exec('guest-ping')
+ except ValueError:
+ logger.trace('QGA guest-ping unexpected output {}'.format(out))
# Empty output - VM not booted yet
if not out:
sleep(5)
@@ -305,8 +307,10 @@ class QemuUtils(object):
elif out.get('error') is not None:
sleep(5)
else:
- raise RuntimeError('QGA guest-ping unexpected output {}'.format(
- out))
+ # If there is an unexpected output from QGA guest-info, try
+ # again until timeout.
+ logger.trace('QGA guest-ping unexpected output {}'.format(out))
+
logger.trace('VM {0} booted on {1}'.format(self._qemu_opt['disk_image'],
self._node['host']))
@@ -513,7 +517,12 @@ class QemuUtils(object):
self._node['host']))
logger.trace('QEMU running')
# Wait until VM boot
- self._wait_until_vm_boot()
+ try:
+ self._wait_until_vm_boot()
+ except RuntimeError:
+ self.qemu_kill()
+ self.qemu_clear_socks()
+ raise
# Update interface names in VM node dict
self._update_vm_interfaces()
# Return VM node dict