As a preparation to get statistics without domain lock. Resolving libvirt names to vzsdk ones is not possible without domain lock thus we need to do it beforehand. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/vz/vz_driver.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 725076f..0609594 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1275,6 +1275,8 @@ vzDomainBlockStats(virDomainPtr domain, const char *path, size_t i; int idx; char *disk = NULL; + char **disks = NULL; + int ndisks = 0; if (!(dom = vzDomObjFromDomainRef(domain))) return -1; @@ -1300,10 +1302,16 @@ vzDomainBlockStats(virDomainPtr domain, const char *path, #undef PARALLELS_ZERO_STATS - for (i = 0; i < dom->def->ndisks; i++) { - if (!(disk = prlsdkGetDiskStatName(dom->def->disks[i]))) + ndisks = dom->def->ndisks; + + if (VIR_ALLOC_N(disks, ndisks)) + goto cleanup; + + for (i = 0; i < ndisks; i++) + if (!(disks[i] = prlsdkGetDiskStatName(dom->def->disks[i]))) goto cleanup; + for (i = 0; i < ndisks; i++) { if (prlsdkGetBlockStats(dom, disk, &s) < 0) goto cleanup; @@ -1314,8 +1322,6 @@ vzDomainBlockStats(virDomainPtr domain, const char *path, PARALLELS_BLOCK_STATS_FOREACH(PARALLELS_SUM_STATS) #undef PARALLELS_SUM_STATS - - VIR_FREE(disk); } } stats->errs = -1; @@ -1325,6 +1331,7 @@ vzDomainBlockStats(virDomainPtr domain, const char *path, if (dom) virDomainObjEndAPI(&dom); VIR_FREE(disk); + virStringFreeListCount(disks, ndisks); return ret; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list