Hello,<div><br></div><div>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:</div><div><br></div><div>import libvirt</div>

<div>conn = libvirt.openReadOnly(None)</div><div><div>dom = conn.lookupByUUIDString('268e38ea-1bc7-41e4-c19e-8eff682e58e4')</div></div><div>dom.getCPUStats(True, 0)</div><div><br></div><div><br></div><div>However, they result in the following error:</div>

<div><br></div><div><br></div><div><div>libvir: QEMU Driver error : Requested operation is not valid: cgroup CPUACCT controller is not mounted</div><div>---------------------------------------------------------------------------</div>

<div>libvirtError                              Traceback (most recent call last)</div><div><ipython-input-23-9317cf967f6d> in <module>()</div><div>----> 1 dom.getCPUStats(True, 0)</div><div><br></div><div>
/usr/lib/python2.7/site-packages/libvirt.pyc in getCPUStats(self, total, flags)</div>
<div>   1733            [{cpu_time:xxx, user_time:xxx, system_time:xxx}] """</div><div>   1734         ret = libvirtmod.virDomainGetCPUStats(self._o, total, flags)</div><div>-> 1735         if ret is None: raise libvirtError ('virDomainGetCPUStats() failed', dom=self)</div>

<div>   1736         return ret</div><div>   1737 </div><div><br></div><div>libvirtError: Requested operation is not valid: cgroup CPUACCT controller is not mounted</div></div><div><br></div><div><br></div><div>However, CPUACCT is actually started and mounted to /mnt/cgroups/cpuacct, and the following steps actually work for the root user:</div>

<div><br></div><div><br></div><div>import libvirt</div><div>conn = libvirt.open(None)</div><div>dom = conn.lookupByUUIDString('e06c6b11-d655-5a98-fd90-724d106066f9')</div><div>dom.getCPUStats(True, 0)</div><div><br>

</div><div>Output:</div><div><br></div><div><div>[{'cpu_time': 10245430984L,</div><div>  'system_time': 5350000000L,</div><div>  'user_time': 1870000000L}]</div></div><div><br></div><div><br></div>

<div>The domains referenced above are started for the non-root and root users respectively.</div><div><br></div><div>I would be very grateful for any pointers to possible solutions of my problem.</div><div><br></div><div>

Thanks,</div><div>Anton Beloglazov</div>