Bug 1264684 - RFE: use libvirt virConnectGetAllDomainStats
Summary: RFE: use libvirt virConnectGetAllDomainStats
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: virt-manager
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-20 17:28 UTC by Cole Robinson
Modified: 2018-10-10 21:57 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-10 21:57:14 UTC


Attachments (Terms of Use)

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(
    libvirt.VIR_DOMAIN_STATS_STATE | libvirt.VIR_DOMAIN_STATS_CPU_TOTAL,
    libvirt.VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE)
pprint.pprint(ret)

$ 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


Note You need to log in before you can comment on or make changes to this bug.