mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: driver: Extract vcpu halted state directly
Don't extract the halted state into a separate array, but rater access the vcpu structures directly. We still need to call the vcpu helper to retrieve the performance statistics though.
This commit is contained in:
parent
a9ab2abbf6
commit
38d26864f7
@ -19660,12 +19660,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|||||||
int *maxparams,
|
int *maxparams,
|
||||||
unsigned int privflags)
|
unsigned int privflags)
|
||||||
{
|
{
|
||||||
|
virDomainVcpuDefPtr vcpu;
|
||||||
|
qemuDomainVcpuPrivatePtr vcpupriv;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
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;
|
bool vcpuhalted = false;
|
||||||
|
|
||||||
if (virTypedParamsAddUInt(&record->params,
|
if (virTypedParamsAddUInt(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
@ -19691,14 +19693,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|||||||
/* it's ok to be silent and go ahead, because halted vcpu info
|
/* it's ok to be silent and go ahead, because halted vcpu info
|
||||||
* wasn't here from the beginning */
|
* wasn't here from the beginning */
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
} else if (VIR_ALLOC_N(cpuhalted, virDomainDefGetVcpus(dom->def)) < 0) {
|
} else {
|
||||||
goto cleanup;
|
vcpuhalted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
|
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
|
||||||
virDomainDefGetVcpus(dom->def),
|
virDomainDefGetVcpus(dom->def),
|
||||||
NULL, 0, cpuhalted) < 0) {
|
NULL, 0, NULL) < 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;
|
||||||
@ -19735,14 +19737,20 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|||||||
cpuwait[i]) < 0)
|
cpuwait[i]) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (cpuhalted) {
|
/* state below is extracted from the individual vcpu structs */
|
||||||
|
if (!(vcpu = virDomainDefGetVcpu(dom->def, cpuinfo[i].number)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
|
||||||
|
|
||||||
|
if (vcpuhalted) {
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"vcpu.%u.halted", cpuinfo[i].number);
|
"vcpu.%u.halted", cpuinfo[i].number);
|
||||||
if (virTypedParamsAddBoolean(&record->params,
|
if (virTypedParamsAddBoolean(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
param_name,
|
param_name,
|
||||||
cpuhalted[i]) < 0)
|
vcpupriv->halted) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19752,7 +19760,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|||||||
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