diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml index 762b6ab992..f21493df64 100644 --- a/man/systemd-detect-virt.xml +++ b/man/systemd-detect-virt.xml @@ -70,6 +70,7 @@ microsoft, oracle, xen, bochs, chroot, + uml, openvz, lxc, lxc-libvirt, systemd-nspawn. diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index a14e452fa3..f45632a0e3 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -969,6 +969,7 @@ xen, bochs, chroot, + uml, openvz, lxc, lxc-libvirt, diff --git a/src/shared/virt.c b/src/shared/virt.c index 1c86a3dd1e..1abd6863ea 100644 --- a/src/shared/virt.c +++ b/src/shared/virt.c @@ -67,6 +67,7 @@ int detect_vm(const char **id) { const char *j, *k; bool hypervisor; _cleanup_free_ char *hvtype = NULL; + _cleanup_free_ char *cpuinfo_contents = NULL; int r; /* Try high-level hypervisor sysfs file first: @@ -164,6 +165,16 @@ int detect_vm(const char **id) { } #endif + + /* Detect User-Mode Linux by reading /proc/cpuinfo */ + r = read_full_file("/proc/cpuinfo", &cpuinfo_contents, NULL); + if (r < 0) + return r; + if (strstr(cpuinfo_contents, "\nvendor_id\t: User Mode Linux\n")) { + *id = "uml"; + return 1; + } + return 0; }