- try:
- qemu_cpus = self.get_qemu_pids()
-
- if len(qemu_cpus) != len(host_cpus):
- raise ValueError('Host CPU count must match Qemu Thread count!')
-
- for qemu_cpu, host_cpu in zip(qemu_cpus, host_cpus):
- command = ('taskset -pc {host_cpu} {thread}'.
- format(host_cpu=host_cpu, thread=qemu_cpu))
- message = ('QEMU: Set affinity failed on {host}!'.
- format(host=self._node['host']))
- exec_cmd_no_error(self._node, command, sudo=True,
- message=message)
- except (RuntimeError, ValueError):
+ for _ in range(3):
+ try:
+ qemu_cpus = self.get_qemu_pids()
+
+ if len(qemu_cpus) != len(host_cpus):
+ sleep(1)
+ continue
+ for qemu_cpu, host_cpu in zip(qemu_cpus, host_cpus):
+ command = ('taskset -pc {host_cpu} {thread}'.
+ format(host_cpu=host_cpu, thread=qemu_cpu))
+ message = ('QEMU: Set affinity failed on {host}!'.
+ format(host=self._node['host']))
+ exec_cmd_no_error(self._node, command, sudo=True,
+ message=message)
+ break
+ except (RuntimeError, ValueError):
+ self.qemu_kill_all()
+ raise
+ else: