Bug 1264684

Summary: RFE: use libvirt virConnectGetAllDomainStats
Product: [Community] Virtualization Tools Reporter: Cole Robinson <crobinso>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, crobinso, gscrivan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-10 21:57:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Cole Robinson 2015-09-20 17:28:31 UTC
Since libvirt 1.2.8 there's an API virConnectGetAllDomainStats that allows fetching all stats and domain status info for all domains in one API call, which will definitely can definitely reduce a lot of the remaining polling we do in virt-manager.

API: https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectGetAllDomainStats

Python example getting all active domain state+stats in one go:

$ cat test.py
import libvirt
import pprint

conn = libvirt.open("qemu:///system")
ret = conn.getAllDomainStats(

$ python test.py 
[(<libvirt.virDomain object at 0x7ff5424b3490>,
  {'cpu.system': 229450000000L,
   'cpu.time': 1136059669906L,
   'cpu.user': 118530000000L,
   'state.reason': 1,
   'state.state': 1}),
 (<libvirt.virDomain object at 0x7ff5424b34d0>,
  {'cpu.system': 2088720000000L,
   'cpu.time': 7899984603220L,
   'cpu.user': 28280000000L,
   'state.reason': 1,
   'state.state': 1})]

Comment 1 Cole Robinson 2018-10-10 21:57:14 UTC
This is in:

commit 68a5abe27971d8273e13bb8d846cdaa5f17c3ae4
Author: Simon Kobyda <skobyda>
Date:   Fri Oct 5 16:54:25 2018 +0200

    statsmanager: new class for VM/conn stats polling

And following commits