+ qemu_cpus = self._qemu_qmp_exec('query-cpus')['return']
+
+ if len(qemu_cpus) != len(host_cpus):
+ logger.debug('Host CPU count {0}, Qemu Thread count {1}'.format(
+ len(host_cpus), len(qemu_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'])
+ (ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd)
+ if int(ret_code) != 0:
+ logger.debug('Set affinity failed {0}'.format(stderr))
+ raise RuntimeError('Set affinity failed on {0}'.format(
+ self._node['host']))