]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Provide virDomainGetCPUStats() implementation for session connection
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 16 Jan 2023 11:46:09 +0000 (12:46 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Jan 2023 15:16:06 +0000 (16:16 +0100)
commit8865c42771600a40eddf40663f73b458423059a4
tree3243c19a7c44c79a0d0639f0e552ed9f492ca08c
parent818c9717c53446ca7abbaa7b3fd7925e1c5ab663
qemu: Provide virDomainGetCPUStats() implementation for session connection

We have virDomainGetCPUStats() API which offers querying
statistics on host CPU usage by given guest. And it works in two
modes: getting overall stats (@start_cpu == -1, @ncpus == 1) or
getting per host CPU usage.

For the QEMU driver it is implemented by looking into values
stored in corresponding cpuacct CGroup controller. Well, this
works for system instances, where libvirt has permissions to
create CGroups and place QEMU process into them. But it does not
fly for session connection, where no CGroups are set up.

Fortunately, we can do something similar to v8.8.0-rc1~95 and use
virProcessGetStatInfo() to fill the overall stats. Unfortunately,
I haven't found any source of per host CPU usage, so we just
continue throwing an error in that case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_driver.c