mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
Don't require domain obj in qemuDomainGetPercpuStats
All we need is the virCgroupPtr and number of vcpupids. This will allow the function to be moved to util/vircgroup.c.
This commit is contained in:
parent
63fb786307
commit
3e7e6ad6ee
@ -15979,22 +15979,22 @@ qemuDomainGetMetadata(virDomainPtr dom,
|
|||||||
* s3 = t03 + t13
|
* s3 = t03 + t13
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
getSumVcpuPercpuStats(virDomainObjPtr vm,
|
getSumVcpuPercpuStats(virCgroupPtr group,
|
||||||
|
unsigned int nvcpupids,
|
||||||
unsigned long long *sum_cpu_time,
|
unsigned long long *sum_cpu_time,
|
||||||
unsigned int num)
|
unsigned int num)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
||||||
virCgroupPtr group_vcpu = NULL;
|
virCgroupPtr group_vcpu = NULL;
|
||||||
|
|
||||||
for (i = 0; i < priv->nvcpupids; i++) {
|
for (i = 0; i < nvcpupids; i++) {
|
||||||
char *pos;
|
char *pos;
|
||||||
unsigned long long tmp;
|
unsigned long long tmp;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
if (virCgroupNewVcpu(priv->cgroup, i, false, &group_vcpu) < 0)
|
if (virCgroupNewVcpu(group, i, false, &group_vcpu) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCgroupGetCpuacctPercpuUsage(group_vcpu, &buf) < 0)
|
if (virCgroupGetCpuacctPercpuUsage(group_vcpu, &buf) < 0)
|
||||||
@ -16022,11 +16022,12 @@ getSumVcpuPercpuStats(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetPercpuStats(virDomainObjPtr vm,
|
qemuDomainGetPercpuStats(virCgroupPtr group,
|
||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
unsigned int nparams,
|
unsigned int nparams,
|
||||||
int start_cpu,
|
int start_cpu,
|
||||||
unsigned int ncpus)
|
unsigned int ncpus,
|
||||||
|
unsigned int nvcpupids)
|
||||||
{
|
{
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -16036,7 +16037,6 @@ qemuDomainGetPercpuStats(virDomainObjPtr vm,
|
|||||||
unsigned long long *sum_cpu_time = NULL;
|
unsigned long long *sum_cpu_time = NULL;
|
||||||
unsigned long long *sum_cpu_pos;
|
unsigned long long *sum_cpu_pos;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
||||||
virTypedParameterPtr ent;
|
virTypedParameterPtr ent;
|
||||||
int param_idx;
|
int param_idx;
|
||||||
unsigned long long cpu_time;
|
unsigned long long cpu_time;
|
||||||
@ -16063,7 +16063,7 @@ qemuDomainGetPercpuStats(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* we get percpu cputime accounting info. */
|
/* we get percpu cputime accounting info. */
|
||||||
if (virCgroupGetCpuacctPercpuUsage(priv->cgroup, &buf))
|
if (virCgroupGetCpuacctPercpuUsage(group, &buf))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
pos = buf;
|
pos = buf;
|
||||||
|
|
||||||
@ -16100,7 +16100,7 @@ qemuDomainGetPercpuStats(virDomainObjPtr vm,
|
|||||||
|
|
||||||
if (VIR_ALLOC_N(sum_cpu_time, n) < 0)
|
if (VIR_ALLOC_N(sum_cpu_time, n) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (getSumVcpuPercpuStats(vm, sum_cpu_time, n) < 0)
|
if (getSumVcpuPercpuStats(group, nvcpupids, sum_cpu_time, n) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
sum_cpu_pos = sum_cpu_time;
|
sum_cpu_pos = sum_cpu_time;
|
||||||
@ -16164,8 +16164,8 @@ qemuDomainGetCPUStats(virDomainPtr domain,
|
|||||||
ret = virCgroupGetDomainTotalCpuStats(priv->cgroup,
|
ret = virCgroupGetDomainTotalCpuStats(priv->cgroup,
|
||||||
params, nparams);
|
params, nparams);
|
||||||
else
|
else
|
||||||
ret = qemuDomainGetPercpuStats(vm, params, nparams,
|
ret = qemuDomainGetPercpuStats(priv->cgroup, params, nparams,
|
||||||
start_cpu, ncpus);
|
start_cpu, ncpus, priv->nvcpupids);
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user