[PATCH v4 2/3] util: Add virHostCPUGetHaltPollTime

Michal Prívozník mprivozn at redhat.com
Tue Jul 27 09:03:01 UTC 2021


On 7/27/21 11:02 AM, Yang Fei wrote:
> 
> 
> On 2021/7/27 16:31, Michal Prívozník wrote:
>> On 7/22/21 10:05 AM, Yang Fei wrote:
>>> Add helper function virHostCPUGetHaltPollTime to obtain halt polling
>>> time. If the kernel support halt polling time statistic, and mount
>>> debugfs. This function will take effect on KVM VMs.
>>>
>>> Signed-off-by: Yang Fei <yangfei85 at huawei.com>
>>> ---
>>>  src/libvirt_private.syms |  1 +
>>>  src/util/virhostcpu.c    | 39 +++++++++++++++++++++++++++++++++++++++
>>>  src/util/virhostcpu.h    |  4 ++++
>>>  3 files changed, 44 insertions(+)
>>>
>>
>>> diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
>>> index bf7fda23af..7f577c3e3e 100644
>>> --- a/src/util/virhostcpu.c
>>> +++ b/src/util/virhostcpu.c
>>> @@ -1535,3 +1535,42 @@ virHostCPUGetSignature(char **signature)
>>>  }
>>>  
>>>  #endif /* __linux__ */
>>> +
>>> +int
>>> +virHostCPUGetHaltPollTime(pid_t pid,
>>> +                      unsigned long long *haltPollSuccess,
>>> +                      unsigned long long *haltPollFail)
>>> +{
>>> +    g_autofree char *pidToStr = NULL;
>>> +    g_autofree char *debugFsPath = NULL;
>>> +    g_autofree char *kvmPath = NULL;
>>> +    struct dirent *ent = NULL;
>>> +    g_autoptr(DIR) dir = NULL;
>>> +    bool found = false;
>>> +
>>> +    if (!(debugFsPath = virFileFindMountPoint("debugfs")))
>>> +        return -1;
>>> +
>>> +    kvmPath = g_strdup_printf("%s/%s", debugFsPath, "kvm");
>>> +    if (virDirOpenQuiet(&dir, kvmPath) != 1)
>>> +        return -1;
>>> +
>>> +    pidToStr = g_strdup_printf("%lld%c", (long long)pid, '-');
>>
>> Just a tiny nit: this could be "%lld-".
>>
> 
> Thanks for your review Michal. And do I need to send another version to fix it now?

No, it's pushed. I've fixed it just before pushing.

Michal




More information about the libvir-list mailing list