From 031201dc6adb4bff784140768e549c8bd6c9096e Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Sun, 11 Jan 2026 20:35:10 +0100 Subject: [PATCH] msr_module_load --- libvirt.spec.in | 18 ++++++++++++++++++ meson.build | 14 ++++++++++++++ meson_options.txt | 1 + src/util/libvirt-msr.modules-load.conf | 1 + src/util/meson.build | 8 ++++++++ tools/virt-host-validate-qemu.c | 7 +++++++ 6 files changed, 49 insertions(+) create mode 100644 src/util/libvirt-msr.modules-load.conf diff --git a/libvirt.spec.in b/libvirt.spec.in index ccfe75135b..305ddc0e5f 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -211,6 +211,13 @@ %define with_dmidecode 0%{!?_without_dmidecode:1} %endif +%define with_msr_module_load 0 +%if 0%{?fedora} || 0%{?rhel} + %ifarch %{arches_x86} + %define with_msr_module_load 0%{!?_without_msr_module_load:1} + %endif +%endif + %define with_modular_daemons 0 %if 0%{?fedora} || 0%{?rhel} %define with_modular_daemons 1 @@ -1338,6 +1345,12 @@ exit 1 %define arg_remote_mode -Dremote_default_mode=legacy %endif +%if %{with_msr_module_load} + %define arg_msr_module_load -Dmsr_module_load=enabled +%else + %define arg_msr_module_load -Dmsr_module_load=disabled +%endif + %define when %(date +"%%F-%%T") %define where %(hostname) %define who %{?packager}%{!?packager:Unknown} @@ -1422,6 +1435,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) -Dtls_priority=%{tls_priority} \ -Dsysctl_config=enabled \ -Dssh_proxy=enabled \ + %{?arg_msr_module_load} \ %{?enable_werror} \ -Dexpensive_tests=enabled \ -Dinit_script=systemd \ @@ -1509,6 +1523,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) -Dstorage_zfs=disabled \ -Dsysctl_config=disabled \ -Dssh_proxy=disabled \ + -Dmsr_module_load=disabled \ -Dtests=disabled \ -Dudev=disabled \ -Dwireshark_dissector=disabled \ @@ -2512,6 +2527,9 @@ exit 0 %endif %dir %{_datadir}/libvirt/cpu_map %{_datadir}/libvirt/cpu_map/*.xml + %if %{with_msr_module_load} +%{_sysconfdir}/modules-load.d/libvirt-msr.conf + %endif %if %{with_wireshark} %files wireshark diff --git a/meson.build b/meson.build index 2f807bc3a2..7bcdb35512 100644 --- a/meson.build +++ b/meson.build @@ -2042,6 +2042,19 @@ if prio == 'auto' endif conf.set_quoted('TLS_PRIORITY', prio) +if not get_option('msr_module_load').disabled() + if host_machine.system() != 'linux' + if get_option('msr_module_load').enabled() + error('msr module loading can be enabled on Linux only') + endif + endif + if host_machine.cpu_family() not in [ 'x86', 'x86_64' ] + if get_option('msr_module_load').enabled() + error('msr module loading can be enabled on x86 only') + endif + endif + conf.set('WITH_MSR_MODULE_LOAD', 1) +endif # test options @@ -2337,6 +2350,7 @@ misc_summary = { 'pm_utils': conf.has('WITH_PM_UTILS'), 'SSH proxy': conf.has('WITH_SSH_PROXY'), 'sysctl config': conf.has('WITH_SYSCTL'), + 'msr module load': conf.has('WITH_MSR_MODULE_LOAD'), 'tests': tests_enabled, 'TLS priority': conf.get_unquoted('TLS_PRIORITY'), 'virt-host-validate': conf.has('WITH_HOST_VALIDATE'), diff --git a/meson_options.txt b/meson_options.txt index e12ace4e11..4b6c030e92 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -133,3 +133,4 @@ option('pm_utils', type: 'feature', value: 'auto', description: 'use pm-utils fo option('ssh_proxy', type: 'feature', value: 'auto', description: 'Build ssh-proxy for ssh over vsock') option('sysctl_config', type: 'feature', value: 'auto', description: 'Whether to install sysctl configs') option('tls_priority', type: 'string', value: 'auto', description: 'set the default TLS session priority string') +option('msr_module_load', type: 'feature', value: 'auto', description: 'Install modules-load.d file for msr module') diff --git a/src/util/libvirt-msr.modules-load.conf b/src/util/libvirt-msr.modules-load.conf new file mode 100644 index 0000000000..3e5ee7fa15 --- /dev/null +++ b/src/util/libvirt-msr.modules-load.conf @@ -0,0 +1 @@ +msr diff --git a/src/util/meson.build b/src/util/meson.build index 4950a795cc..3d2dbe199d 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -223,4 +223,12 @@ if conf.has('WITH_LIBVIRTD') } endif +if conf.has('WITH_MSR_MODULE_LOAD') + install_data( + 'libvirt-msr.modules-load.conf', + install_dir: sysconfdir / 'modules-load.d', + rename: 'libvirt-msr.conf', + ) +endif + util_inc_dir = include_directories('.') diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c index c5c1a0ab7e..68e5d037c8 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -104,6 +104,13 @@ int virHostValidateQEMU(void) virValidatePass(); } + if (ARCH_IS_X86(arch)) { + if (virHostValidateDeviceExists("QEMU", "/dev/cpu/0/msr", + VIR_VALIDATE_WARN, + _("Load the 'msr' module for better x86 CPU features detection")) < 0) + ret = -1; + } + if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net", VIR_VALIDATE_WARN, _("Load the 'vhost_net' module to improve performance of virtio networking")) < 0) -- 2.52.0