2

I am trying to use lm_sensors to detect the host CPU temperature in KVM guest.

In the host, with the x86_pkg_temp_thermal kernel module inserted, the sysfs interface /sys/class/thermal/thermal_zone*/temp expose desired information.

Here's the output of sensors-detect script from lm-sensors on the host:

$ sudo sensors-detect
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System: LENOVO 20C60065TW [ThinkPad Edge E540] (laptop)
# Kernel: 4.8.8-200.fc24.x86_64 x86_64
# Processor: Intel(R) Core(TM) i7-4702MQ CPU @ 2.20GHz (6/60/3)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): YES
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Intel digital thermal sensor...                             Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No

In the KVM guest running Fedora 24, the kernel module cannot be inserted:

[root@fedora ~]# modprobe -v x86_pkg_temp_thermal
insmod /lib/modules/4.8.8300.fc25.x86_64/kernel/drivers/thermal/x86_pkg_temp_thermal.ko.xz 
modprobe: ERROR: could not insert 'x86_pkg_temp_thermal': No such device
[root@fedora ~]# modprobe -v coretemp
insmod /lib/modules/4.8.8-300.fc25.x86_64/kernel/drivers/hwmon/coretemp.ko.xz 
modprobe: ERROR: could not insert 'coretemp': No such device

The output of sensors-detect script in the guest indicates that such capability has not been exposed from host.

[root@fedora ~]# sensors-detect 
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System: QEMU Standard PC (i440FX + PIIX, 1996) [pc-i440fx-2.6]
# Kernel: 4.8.8-300.fc25.x86_64 x86_64
# Processor: Westmere E56xx/L56xx/X56xx (Nehalem-C) (6/44/1)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): YES
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Intel digital thermal sensor...                             No
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No

Is there any way I can expose the "Intel digital thermal sensor" to the KVM guest?

  • Which makes sense, since the VMs only see virtualized CPUs. Why not measuring it directly in the host? – Rui F Ribeiro Dec 1 '16 at 2:51
  • 1
    Virtual CPUs are virtual and do not have a temperature. – AlexP Dec 1 '16 at 2:53
2

Temperatures should not be present in virtualized CPUs, and this is expected behaviour.

The CPUs in a VM are virtual, and they may not map exactly one-to-one to real CPUs.

There are also expected differences/trade offs in a virtual environment/VMs, where complete emulations of the host environment are not expected to be found, and often are even not desirable due to performance reasons.

Thus, for instance, the extra effort in some virtualization plataforms to paravirtualize network interface cards and disk controllers instead of emulating the full hardware - the differences in performance often can reach orders of magnitude.

For capturing hardware data, namely temperature, and other monitoring data of the host, I would advise besides monitoring the VMs, also doing direct monitoring to the host, for instance, configuring SNMP services.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.