cli/libvirt: actually use bool to gather mem stats
We rely mostly on bulk stats API to get the stats from libvirt
domain's. At the same time, we need the memory statistics, thus
a separate libvirt call is needed.
We want to keep this separate libvirt call optional.
@@ -212,10 +212,14 @@ func (l *LibvirtConnection) GetDomainStats(statsTypes libvirt.DomainStatsTypes,
var list []*stats.DomainStats
for _, domStat := range domStats {
- memStats, err := domStat.Domain.MemoryStats(uint32(libvirt.DOMAIN_MEMORY_STAT_NR), 0)
+ var err error
+ var memStats []libvirt.DomainMemoryStat
+ if statsMemory {
+ memStats, err = domStat.Domain.MemoryStats(uint32(libvirt.DOMAIN_MEMORY_STAT_NR), 0)
if err != nil {
return list, err
}
+ }
stat := &stats.DomainStats{}
err = stats.Convert_libvirt_DomainStats_to_stats_DomainStats(stats.DomainIdentifier(domStat.Domain), &domStat, memStats, stat)
