提交 09183163 编写于 作者: G Guannan Ren

qemu: fix an off-by-one error in qemuDomainGetPercpuStats

The max value of number of cpus to compute(id) should not
be equal or greater than max cpu number.
The bug ocurrs when id value is equal to max cpu number which
leads to the off-by-one error in the following for loop.

 # virsh  cpu-stats guest --start 1
 error: Failed to virDomainGetCPUStats()

 error: internal error cpuacct parse error
上级 5c9034bf
......@@ -14331,9 +14331,9 @@ qemuDomainGetPercpuStats(virDomainObjPtr vm,
param_idx = 0;
/* number of cpus to compute */
id = max_id;
if (max_id - start_cpu > ncpus - 1)
if (start_cpu >= max_id - ncpus)
id = max_id - 1;
else
id = start_cpu + ncpus - 1;
for (i = 0; i <= id; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册