Anton Beloglazov
2012-Aug-17 07:23 UTC
[libvirt-users] getCPUStats of a domain by a non-root user - libvirtError: Requested operation is not valid: cgroup CPUACCT controller is not mounted
Hello, I'm trying to use libvirt as a non-root user to obtain statistics on the CPU usage by VMs using the Python API. I'm performing basically the following steps: import libvirt conn = libvirt.openReadOnly(None) dom = conn.lookupByUUIDString('268e38ea-1bc7-41e4-c19e-8eff682e58e4') dom.getCPUStats(True, 0) However, they result in the following error: libvir: QEMU Driver error : Requested operation is not valid: cgroup CPUACCT controller is not mounted --------------------------------------------------------------------------- libvirtError Traceback (most recent call last) <ipython-input-23-9317cf967f6d> in <module>() ----> 1 dom.getCPUStats(True, 0) /usr/lib/python2.7/site-packages/libvirt.pyc in getCPUStats(self, total, flags) 1733 [{cpu_time:xxx, user_time:xxx, system_time:xxx}] """ 1734 ret = libvirtmod.virDomainGetCPUStats(self._o, total, flags) -> 1735 if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self) 1736 return ret 1737 libvirtError: Requested operation is not valid: cgroup CPUACCT controller is not mounted However, CPUACCT is actually started and mounted to /mnt/cgroups/cpuacct, and the following steps actually work for the root user: import libvirt conn = libvirt.open(None) dom = conn.lookupByUUIDString('e06c6b11-d655-5a98-fd90-724d106066f9') dom.getCPUStats(True, 0) Output: [{'cpu_time': 10245430984L, 'system_time': 5350000000L, 'user_time': 1870000000L}] The domains referenced above are started for the non-root and root users respectively. I would be very grateful for any pointers to possible solutions of my problem. Thanks, Anton Beloglazov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120817/a1a69851/attachment.htm>
Olivier Doucet
2012-Aug-17 13:24 UTC
[libvirt-users] getCPUStats of a domain by a non-root user - libvirtError: Requested operation is not valid: cgroup CPUACCT controller is not mounted
Hi,> libvir: QEMU Driver error : Requested operation is not valid: cgroup CPUACCT > controller is not mountedYou need to install/configure Cgroups on your system : http://en.wikipedia.org/wiki/Cgroups https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch01.html Olivier
Apparently Analagous Threads
- Issue with getCPUStats and getMemoryStats
- How i can calculate cpu utilization percentage for host using python libvirt API.
- how to limit cpu usage for specified processes
- problem when get the vm cpu stat
- Requested operation is not valid: domain is not running but exactly vm is running