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>
raise ValueError('Host CPU count must match Qemu Thread count')
for qemu_cpu, host_cpu in zip(qemu_cpus, host_cpus):
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))
(ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd)
if int(ret_code) != 0:
logger.debug('Set affinity failed {0}'.format(stderr))
return {}
return json.loads(stdout.split('\n', 1)[0])
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.
"""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()
:type timeout: int
"""
start = time()
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()
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)
# Empty output - VM not booted yet
if not out:
sleep(5)
elif out.get('error') is not None:
sleep(5)
else:
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']))
logger.trace('VM {0} booted on {1}'.format(self._qemu_opt['disk_image'],
self._node['host']))
self._node['host']))
logger.trace('QEMU running')
# Wait until VM boot
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
# Update interface names in VM node dict
self._update_vm_interfaces()
# Return VM node dict