1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

util: Introduce virResctrlMonitorFreeStats

The call of virResctrlMonitorGetStats will allocate the memory for
holding cache occupancy or memory bandwidth statistics.

This patch adds the function virResctrlMonitorFreeStats as the
opposing action of virResctrlMonitorGetStats to free the memory.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Wang Huaqiang 2018-11-27 01:56:15 +08:00 committed by John Ferlan
parent ef0027ceb6
commit a60b7d7582
3 changed files with 21 additions and 0 deletions

View File

@ -2692,6 +2692,7 @@ virResctrlInfoNew;
virResctrlMonitorAddPID;
virResctrlMonitorCreate;
virResctrlMonitorDeterminePath;
virResctrlMonitorFreeStats;
virResctrlMonitorGetCacheOccupancy;
virResctrlMonitorGetID;
virResctrlMonitorNew;

View File

@ -2747,6 +2747,22 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
}
void
virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats,
size_t nstats)
{
size_t i = 0;
if (!stats)
return;
for (i = 0; i < nstats; i++)
VIR_FREE(stats[i]);
VIR_FREE(stats);
}
/*
* virResctrlMonitorGetCacheOccupancy
*

View File

@ -231,4 +231,8 @@ int
virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor,
virResctrlMonitorStatsPtr **stats,
size_t *nstats);
void
virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats,
size_t nstats);
#endif /* __VIR_RESCTRL_H__ */