Bug 2157094

Summary: Backport the qemuDomainGetStatsCpu fallback Implementation [rhel-9.1.0.z]
Product: Red Hat Enterprise Linux 9 Reporter: RHEL Program Management Team <pgm-rhel-tools>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
libvirt sub component: General QA Contact: Luyao Huang <lhuang>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: alitman, dzheng, jdenemar, jsuchane, kbidarka, kmajcher, lhuang, lmen, lpivarc, pkrempa, sgott, sradco, virt-maint, yalzhang, ymankad
Version: 9.1Keywords: Triaged, ZStream
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-8.5.0-7.3.el9_1 Doc Type: Enhancement
Doc Text:
Feature: When fetching statistics for a running QEMU guest, libvirt looks into CGroups and fetches some statistics from there (e.g. on CPU usage). However, this is not possible for session mode because there libvirt does not have permissions to even place QEMU into CGroups. Therefore, a workaround needs to be implemented where stats are fetched from a different source (procfs). Reason: Result:
Story Points: ---
Clone Of: 2148266 Environment:
Last Closed: 2023-01-23 15:18:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2148266    
Bug Blocks:    

Comment 5 Luyao Huang 2023-01-06 06:57:12 UTC
Verify this bug with libvirt-8.5.0-7.3.el9_1.x86_64:

1. switch to a unprivileged user:

# su - test

2. start a guest
$ virsh start vm1
Domain 'vm1' started

3. use domstats get vm cpu.time, cpu.user and cpu.system and compare the value in /proc/pid/stat:

$ virsh domstats vm1; cat /proc/`pidof qemu-kvm`/stat
Domain: 'vm1'
  state.state=1
  state.reason=1
  cpu.time=550000000
  cpu.user=230000000
  cpu.system=320000000
  cpu.cache.monitor.count=0
  balloon.current=2097152
  balloon.maximum=2097152
  balloon.last-update=0
  balloon.rss=89508
  vcpu.current=2
  vcpu.maximum=2
  vcpu.0.state=1
  vcpu.0.time=240000000
  vcpu.0.wait=0
  vcpu.0.delay=512171
  vcpu.1.state=1
  vcpu.1.time=0
  vcpu.1.wait=0
  vcpu.1.delay=5245
  net.count=0
  block.count=0
  dirtyrate.calc_status=0
  dirtyrate.calc_start_time=0
  dirtyrate.calc_period=0
  dirtyrate.calc_mode=page-sampling

53941 (qemu-kvm) S 1 53940 53940 0 -1 138428544 10554 0 0 0 **32 23** 0 0 20 0 6 0 8063226 2664464384 22377 18446744073709551615 94791831449600 94791837966397 140737053288768 0 0 0 268444224 4096 16963 0 0 0 17 39 0 0 0 9 0 94791842521976 94791844707810 94791856136192 140737053291518 140737053294351 140737053294351 140737053294562 0

Comment 9 errata-xmlrpc 2023-01-23 15:18:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (libvirt bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:0311