Bug 1992479

Summary: Detecting TSC timer frequencies requires too many privileges
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Roman Mohr <rmohr>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Luyao Huang <lhuang>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.4CC: chhu, jdenemar, jsuchane, lmen, mprivozn, pkrempa, virt-maint, xuzhang, ymankad
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: 8.5   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-7.6.0-3.module+el8.5.0+12510+80564ecf Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1996130 (view as bug list) Environment:
Last Closed: 2021-11-16 07:55:01 UTC Type: Bug
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:    
Bug Blocks: 1996130    

Description Roman Mohr 2021-08-11 07:54:25 UTC
Description of problem:

CNV runs libvirt with limited permissions. As a consequence libvirt does not have access to files like `/dev/cpu/0/msr` to determine the TSC frequency. A correct fallback was implemented in https://gitlab.com/libvirt/libvirt/-/issues/188 which we will need in CNV 4.9 to allow migrations with the inftsc cpu flag.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:

CNV can't detect the TSC frequency correctly.

Expected results:

CNV can detect the TSC frequency correctly.

Additional info:

We need a backport of https://gitlab.com/libvirt/libvirt/-/issues/188.

Comment 1 Roman Mohr 2021-08-11 08:00:34 UTC
Michal it would be great if we could get a backport.

Comment 2 Peter Krempa 2021-08-11 08:26:10 UTC
The commit from upstream issue #188 is:

commit 5df2c49263338da7221f24b3ad67ffd21d88047c
Author: Daniel P. Berrangé <berrange>
Date:   Wed Aug 4 18:05:59 2021 +0100

    util: directly query KVM for TSC scaling support
    
    We currently query the host MSRs to determine if TSC scaling is
    supported. This works OK when running privileged and can open
    the /dev/cpu/0/msr. When unprivileged we fallback to querying
    MSRs from /dev/kvm. This is incorrect because /dev/kvm only
    reports accurate info for MSRs that are valid to use from inside
    a guest.  The TSC scaling support MSR is not, thus we always end
    up reporting lack of TSC scaling when unprivileged.
    
    The solution to this is easy, because KVM can directly report
    whether TSC scaling is available, which matches what QEMU will
    do at startup.
    
    Closes: https://gitlab.com/libvirt/libvirt/-/issues/188
    Reported-by: Roman Mohr <rmohr>
    Reviewed-by: Michal Privoznik <mprivozn>
    Signed-off-by: Daniel P. Berrangé <berrange>

v7.6.0-53-g5df2c49263

Comment 12 Luyao Huang 2021-08-30 08:39:36 UTC
Preverify this bug with rebuild libvirt with patch:
https://mailman-int.corp.redhat.com/archives/rhvirt-patches/2021-August/msg00103.html

Comment 15 Luyao Huang 2021-09-07 02:43:58 UTC
Verify this bug with libvirt-daemon-7.6.0-3.module+el8.5.0+12510+80564ecf.x86_64 with the same steps in bug 1996130 comment 4.

Comment 17 errata-xmlrpc 2021-11-16 07:55:01 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 (virt:av 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-2021:4684