mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
basic/virt: provide a nicer message is /proc/cpuinfo is not available
$ sudo systemd-run -p RootDirectory=/usr -E LD_LIBRARY_PATH=/lib/systemd/ -E SYSTEMD_LOG_LEVEL=debug /bin/systemd-detect-virt Before systemd-detect-virt[18498]: No virtualization found in DMI systemd-detect-virt[18498]: No virtualization found in CPUID systemd-detect-virt[18498]: Virtualization XEN not found, /proc/xen does not exist systemd-detect-virt[18498]: This platform does not support /proc/device-tree systemd-detect-virt[18498]: Failed to check for virtualization: No such file or directory The first four lines are at debug level, so the user would only see that last one usually, which is not very enlightening. This now becomes: systemd-detect-virt[21172]: No virtualization found in DMI systemd-detect-virt[21172]: No virtualization found in CPUID systemd-detect-virt[21172]: Virtualization XEN not found, /proc/xen does not exist systemd-detect-virt[21172]: This platform does not support /proc/device-tree systemd-detect-virt[21172]: /proc/cpuinfo not found, assuming no UML virtualization. systemd-detect-virt[21172]: This platform does not support /proc/sysinfo systemd-detect-virt[21172]: Found VM virtualization none systemd-detect-virt[21172]: none We do more checks, which is good too.
This commit is contained in:
parent
a2896612a3
commit
ef2a48aa01
@ -282,6 +282,10 @@ static int detect_vm_uml(void) {
|
|||||||
|
|
||||||
/* Detect User-Mode Linux by reading /proc/cpuinfo */
|
/* Detect User-Mode Linux by reading /proc/cpuinfo */
|
||||||
r = read_full_file("/proc/cpuinfo", &cpuinfo_contents, NULL);
|
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)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -290,7 +294,7 @@ static int detect_vm_uml(void) {
|
|||||||
return VIRTUALIZATION_UML;
|
return VIRTUALIZATION_UML;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("No virtualization found in /proc/cpuinfo.");
|
log_debug("UML virtualization not found in /proc/cpuinfo.");
|
||||||
return VIRTUALIZATION_NONE;
|
return VIRTUALIZATION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,16 +608,16 @@ int running_in_userns(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int running_in_chroot(void) {
|
int running_in_chroot(void) {
|
||||||
int ret;
|
int r;
|
||||||
|
|
||||||
if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0)
|
if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = files_same("/proc/1/root", "/", 0);
|
r = files_same("/proc/1/root", "/", 0);
|
||||||
if (ret < 0)
|
if (r < 0)
|
||||||
return ret;
|
return r;
|
||||||
|
|
||||||
return ret == 0;
|
return r == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
|
static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user