[libvirt PATCH] util: Fix getting CPU frequency on Apple Silicon
Menci
huanghaorui301 at gmail.com
Sun Feb 13 20:59:11 UTC 2022
I tested the patch (applying to v7.10.0) and it works on my M1 MacBook Air.
Thanks.
On Sat, Feb 12, 2022 at 1:32 AM Andrea Bolognani <abologna at redhat.com>
wrote:
> On Thu, Feb 10, 2022 at 10:08:42AM +0100, Andrea Bolognani wrote:
> > +++ b/src/util/virhostcpu.c
> > @@ -928,8 +928,14 @@ virHostCPUGetInfo(virArch hostarch G_GNUC_UNUSED,
> > *mhz = cpu_freq;
> > # else
> > if (sysctlbyname("hw.cpufrequency", &cpu_freq, &cpu_freq_len, NULL,
> 0) < 0) {
> > - virReportSystemError(errno, "%s", _("cannot obtain CPU freq"));
> > - return -1;
> > + if (errno == ENOENT) {
> > + /* The hw.cpufrequency sysctl is not implemented on Apple
> Silicon.
> > + * In that case, we report 0 instead of erroring out */
> > + cpu_freq = 0;
> > + } else {
> > + virReportSystemError(errno, "%s", _("cannot obtain CPU
> freq"));
> > + return -1;
> > + }
> > }
>
> Menci, can you please confirm this works for you before I push? I
> have no way of verifying that on my own. Thanks!
>
> --
> Andrea Bolognani / Red Hat / Virtualization
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220214/bf144963/attachment-0001.htm>
More information about the libvir-list
mailing list