diff --git a/src/basic/virt.c b/src/basic/virt.c index c4335ab909..39b4a98d89 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -282,6 +282,10 @@ static int detect_vm_uml(void) { /* Detect User-Mode Linux by reading /proc/cpuinfo */ r = read_full_file("/proc/cpuinfo", &cpuinfo_contents, NULL); + if (r == -ENOENT) { + log_debug("/proc/cpuinfo not found, assuming no UML virtualization."); + return VIRTUALIZATION_NONE; + } if (r < 0) return r; @@ -290,7 +294,7 @@ static int detect_vm_uml(void) { return VIRTUALIZATION_UML; } - log_debug("No virtualization found in /proc/cpuinfo."); + log_debug("UML virtualization not found in /proc/cpuinfo."); return VIRTUALIZATION_NONE; } @@ -604,16 +608,16 @@ int running_in_userns(void) { } int running_in_chroot(void) { - int ret; + int r; if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0) return 0; - ret = files_same("/proc/1/root", "/", 0); - if (ret < 0) - return ret; + r = files_same("/proc/1/root", "/", 0); + if (r < 0) + return r; - return ret == 0; + return r == 0; } static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {