--- src/vz/vz_driver.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index c282858..a0a61eb 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3627,6 +3627,57 @@ vzDomainGetNetStats(virDomainObjPtr dom, return 0; } +static int +vzDomainGetVCPUStats(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + vzDomObjPtr privdom = dom->privateData; + size_t i; + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + + if (virTypedParamsAddUInt(&record->params, + &record->nparams, + maxparams, + "vcpu.current", + virDomainDefGetVcpus(dom->def)) < 0) + return -1; + + if (virTypedParamsAddUInt(&record->params, + &record->nparams, + maxparams, + "vcpu.maximum", + virDomainDefGetVcpusMax(dom->def)) < 0) + return -1; + + for (i = 0; i < virDomainDefGetVcpusMax(dom->def); i++) { + int state = dom->def->vcpus[i]->online ? VIR_VCPU_RUNNING : + VIR_VCPU_OFFLINE; + unsigned long long time; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.state", i); + if (virTypedParamsAddInt(&record->params, + &record->nparams, + maxparams, + param_name, + state) < 0) + return -1; + + if (prlsdkGetVcpuStats(privdom->stats, i, &time) < 0) + return -1; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.time", i); + if (virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + param_name, + time) < 0) + return -1; + } + + return 0; +} + static virDomainStatsRecordPtr vzDomainGetAllStats(virConnectPtr conn, virDomainObjPtr dom) @@ -3643,6 +3694,9 @@ vzDomainGetAllStats(virConnectPtr conn, if (vzDomainGetNetStats(dom, stat, &maxparams) < 0) goto error; + if (vzDomainGetVCPUStats(dom, stat, &maxparams) < 0) + goto error; + if (!(stat->dom = virGetDomain(conn, dom->def->name, dom->def->uuid))) goto error; -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list