systemd version the issue has been seen with
249.9
Used distribution
Ubuntu Jammy (22.04)
Linux kernel version used (uname -a)
Linux ubuntu 5.15.0-18-generic #18-Ubuntu SMP Fri Jan 21 14:57:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
CPU architecture issue was seen on
x86_64
Expected behaviour you didn't see
systemd-detect-virt should identify KVM-accelerated VMs as "kvm" or something indicating that KVM is in use
Unexpected behaviour you saw
systemd-detect-virt identifies KVM-accelerated VMs as "qemu" when hv_passthrough is used
Steps to reproduce the problem
#!/bin/sh
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
# cloud-config sets user password
cat >user-data <<EOF
#cloud-config
password: password
chpasswd:
expire: False
EOF
# requires package cloud-utils, adds user/password to cloud image
cloud-localds seed.img user-data
# The second invocation uses hv_passthrough, which causes systemd-detect-virt to report "qemu" as the virtualization method
# Log in and execute `systemd-detect-virt`
#
# Moniker: ubuntu
# Password: password
#
# Works as expected:
qemu-system-x86_64 -net nic -net user -machine accel=kvm,type=q35 -cpu host -m 512 -nographic -hda jammy-server-cloudimg-amd64.img -hdb seed.img
# Reports "qemu" as virtualization type
qemu-system-x86_64 -net nic -net user -machine accel=kvm,type=q35 -cpu host,hv_passthrough -m 512 -nographic -hda jammy-server-cloudimg-amd64.img -hdb seed.img
Additional program output to the terminal or log subsystem illustrating the issue
# without hv_passthrough:
ubuntu@ubuntu:~$ SYSTEMD_LOG_LEVEL=debug systemd-detect-virt
Failed to read $container of PID 1, ignoring: Permission denied
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Virtualization QEMU found in DMI (/sys/class/dmi/id/sys_vendor)
UML virtualization not found in /proc/cpuinfo.
Virtualization found, CPUID=KVMKVMKVM
Found VM virtualization kvm
kvm
# with hv_passthrough (incorrect identification)
ubuntu@ubuntu:~$ SYSTEMD_LOG_LEVEL=debug systemd-detect-virt
Failed to read $container of PID 1, ignoring: Permission denied
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Virtualization QEMU found in DMI (/sys/class/dmi/id/sys_vendor)
UML virtualization not found in /proc/cpuinfo.
Virtualization found, CPUID=Linux KVM Hv
Found VM virtualization qemu
qemu
systemd version the issue has been seen with
249.9
Used distribution
Ubuntu Jammy (22.04)
Linux kernel version used (
uname -a)Linux ubuntu 5.15.0-18-generic #18-Ubuntu SMP Fri Jan 21 14:57:54 UTC 2022 x86_64 x86_64 x86_64 GNU/LinuxCPU architecture issue was seen on
x86_64
Expected behaviour you didn't see
systemd-detect-virtshould identify KVM-accelerated VMs as "kvm" or something indicating that KVM is in useUnexpected behaviour you saw
systemd-detect-virtidentifies KVM-accelerated VMs as "qemu" whenhv_passthroughis usedSteps to reproduce the problem
Additional program output to the terminal or log subsystem illustrating the issue