mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
qemu: add vcpu.n.halted to vcpu domain stats
Extended qemuDomainGetStatsVcpu to include the per vcpu halted indicator if reported by QEMU. The key for new boolean value has the format "vcpu.<n>.halted". Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
This commit is contained in:
parent
08f22976b1
commit
7a51d9ebbd
@ -1454,7 +1454,8 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
|
|||||||
unsigned long long *cpuwait,
|
unsigned long long *cpuwait,
|
||||||
int maxinfo,
|
int maxinfo,
|
||||||
unsigned char *cpumaps,
|
unsigned char *cpumaps,
|
||||||
int maplen)
|
int maplen,
|
||||||
|
bool *cpuhalted)
|
||||||
{
|
{
|
||||||
size_t ncpuinfo = 0;
|
size_t ncpuinfo = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -1474,6 +1475,9 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
|
|||||||
if (cpumaps)
|
if (cpumaps)
|
||||||
memset(cpumaps, 0, sizeof(*cpumaps) * maxinfo);
|
memset(cpumaps, 0, sizeof(*cpumaps) * maxinfo);
|
||||||
|
|
||||||
|
if (cpuhalted)
|
||||||
|
memset(cpuhalted, 0, sizeof(*cpuhalted) * maxinfo);
|
||||||
|
|
||||||
for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) {
|
for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) {
|
||||||
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i);
|
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i);
|
||||||
pid_t vcpupid = qemuDomainGetVcpuPid(vm, i);
|
pid_t vcpupid = qemuDomainGetVcpuPid(vm, i);
|
||||||
@ -1511,6 +1515,9 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cpuhalted)
|
||||||
|
cpuhalted[ncpuinfo] = qemuDomainGetVcpuHalted(vm, ncpuinfo);
|
||||||
|
|
||||||
ncpuinfo++;
|
ncpuinfo++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5455,7 +5462,8 @@ qemuDomainGetVcpus(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen);
|
ret = qemuDomainHelperGetVcpus(vm, info, NULL, maxinfo, cpumaps, maplen,
|
||||||
|
NULL);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
@ -18922,7 +18930,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
virDomainStatsRecordPtr record,
|
virDomainStatsRecordPtr record,
|
||||||
int *maxparams,
|
int *maxparams,
|
||||||
@ -18933,6 +18941,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
|
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
|
||||||
virVcpuInfoPtr cpuinfo = NULL;
|
virVcpuInfoPtr cpuinfo = NULL;
|
||||||
unsigned long long *cpuwait = NULL;
|
unsigned long long *cpuwait = NULL;
|
||||||
|
bool *cpuhalted = NULL;
|
||||||
|
|
||||||
if (virTypedParamsAddUInt(&record->params,
|
if (virTypedParamsAddUInt(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
@ -18952,9 +18961,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
|
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
|
||||||
goto cleanup;
|
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,
|
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
|
||||||
virDomainDefGetVcpus(dom->def),
|
virDomainDefGetVcpus(dom->def),
|
||||||
NULL, 0) < 0) {
|
NULL, 0, cpuhalted) < 0) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
ret = 0; /* it's ok to be silent and go ahead */
|
ret = 0; /* it's ok to be silent and go ahead */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -18990,6 +19004,17 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
param_name,
|
param_name,
|
||||||
cpuwait[i]) < 0)
|
cpuwait[i]) < 0)
|
||||||
goto cleanup;
|
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;
|
ret = 0;
|
||||||
@ -18997,6 +19022,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(cpuinfo);
|
VIR_FREE(cpuinfo);
|
||||||
VIR_FREE(cpuwait);
|
VIR_FREE(cpuwait);
|
||||||
|
VIR_FREE(cpuhalted);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user