As a preparation to get statistics without domain lock. Let's take all we want from domain cache first. After this point domain lock can be dropped. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/vz/vz_driver.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 0609594..62d5047 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -885,24 +885,29 @@ vzDomainGetVcpus(virDomainPtr domain, goto cleanup; } - if (maxinfo >= 1) { - if (info != NULL) { - memset(info, 0, sizeof(*info) * maxinfo); - for (i = 0; i < maxinfo; i++) { - info[i].number = i; - info[i].state = VIR_VCPU_RUNNING; - if (prlsdkGetVcpuStats(privdom, i, &info[i].cpuTime) < 0) - goto cleanup; - } - } - if (cpumaps != NULL) { - memset(cpumaps, 0, maplen * maxinfo); - for (i = 0; i < maxinfo; i++) - virBitmapToDataBuf(privdom->def->cpumask, - VIR_GET_CPUMAP(cpumaps, maplen, i), - maplen); + if (maxinfo < 1) { + ret = 0; + goto cleanup; + } + + if (cpumaps != NULL) { + memset(cpumaps, 0, maplen * maxinfo); + for (i = 0; i < maxinfo; i++) + virBitmapToDataBuf(privdom->def->cpumask, + VIR_GET_CPUMAP(cpumaps, maplen, i), + maplen); + } + + if (info != NULL) { + memset(info, 0, sizeof(*info) * maxinfo); + for (i = 0; i < maxinfo; i++) { + info[i].number = i; + info[i].state = VIR_VCPU_RUNNING; + if (prlsdkGetVcpuStats(privdom, i, &info[i].cpuTime) < 0) + goto cleanup; } } + ret = maxinfo; cleanup: -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list