unsigned long long *cpuwait,
int maxinfo,
unsigned char *cpumaps,
- int maplen)
+ int maplen,
+ bool *cpuhalted)
{
size_t ncpuinfo = 0;
size_t i;
if (cpumaps)
memset(cpumaps, 0, sizeof(*cpumaps) * maxinfo);
+ if (cpuhalted)
+ memset(cpuhalted, 0, sizeof(*cpuhalted) * maxinfo);
+
for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) {
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i);
pid_t vcpupid = qemuDomainGetVcpuPid(vm, i);
return -1;
}
+ if (cpuhalted)
+ cpuhalted[ncpuinfo] = qemuDomainGetVcpuHalted(vm, ncpuinfo);
+
ncpuinfo++;
}
goto cleanup;
}
- ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen);
+ ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen,
+ NULL);
cleanup:
virDomainObjEndAPI(&vm);
static int
-qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
virDomainObjPtr dom,
virDomainStatsRecordPtr record,
int *maxparams,
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
virVcpuInfoPtr cpuinfo = NULL;
unsigned long long *cpuwait = NULL;
+ bool *cpuhalted = NULL;
if (virTypedParamsAddUInt(&record->params,
&record->nparams,
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
goto cleanup;
+ if (qemuDomainRefreshVcpuHalted(driver, dom,
+ QEMU_ASYNC_JOB_NONE) == 0 &&
+ VIR_ALLOC_N(cpuhalted, virDomainDefGetVcpus(dom->def)) < 0)
+ goto cleanup;
+
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
virDomainDefGetVcpus(dom->def),
- NULL, 0) < 0) {
+ NULL, 0, cpuhalted) < 0) {
virResetLastError();
ret = 0; /* it's ok to be silent and go ahead */
goto cleanup;
param_name,
cpuwait[i]) < 0)
goto cleanup;
+
+ if (cpuhalted) {
+ snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "vcpu.%u.halted", cpuinfo[i].number);
+ if (virTypedParamsAddBoolean(&record->params,
+ &record->nparams,
+ maxparams,
+ param_name,
+ cpuhalted[i]) < 0)
+ goto cleanup;
+ }
}
ret = 0;
cleanup:
VIR_FREE(cpuinfo);
VIR_FREE(cpuwait);
+ VIR_FREE(cpuhalted);
return ret;
}