From: Yu Watanabe Date: Sun, 20 Jun 2021 15:09:07 +0000 (+0900) Subject: virt: improve log message when we cannot read /sys/firmware/dmi/entries/0-0/raw X-Git-Tag: v249-rc2~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=932feb79b301014f12cefc3201a4c6eeee1e1def;p=thirdparty%2Fsystemd.git virt: improve log message when we cannot read /sys/firmware/dmi/entries/0-0/raw As the file is usually readable by only root. Prompted by https://github.com/systemd/systemd/issues/19978#issuecomment-864561357. --- diff --git a/src/basic/virt.c b/src/basic/virt.c index 9b8518bd084..7e88f09b485 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -186,6 +186,7 @@ static int detect_vm_dmi_vendor(void) { return dmi_vendor_table[j].id; } } + log_debug("No virtualization found in DMI vendor table."); return VIRTUALIZATION_NONE; } @@ -202,7 +203,8 @@ static int detect_vm_smbios(void) { r = read_full_virtual_file("/sys/firmware/dmi/entries/0-0/raw", &s, &readsize); if (r < 0) { - log_debug_errno(r, "Unable to read /sys/firmware/dmi/entries/0-0/raw, ignoring: %m"); + log_debug_errno(r, "Unable to read /sys/firmware/dmi/entries/0-0/raw, " + "using the virtualization information found in DMI vendor table, ignoring: %m"); return SMBIOS_VM_BIT_UNKNOWN; } if (readsize < 20 || s[1] < 20) { @@ -210,16 +212,17 @@ static int detect_vm_smbios(void) { * extension bytes. The data we're interested in is in extension byte 2, which would be at * 0x13. If we didn't read that much data, or if the BIOS indicates that we don't have that * much data, we don't infer anything from the SMBIOS. */ - log_debug("Only read %zu bytes from /sys/firmware/dmi/entries/0-0/raw (expected 20)", readsize); + log_debug("Only read %zu bytes from /sys/firmware/dmi/entries/0-0/raw (expected 20). " + "Using the virtualization information found in DMI vendor table.", readsize); return SMBIOS_VM_BIT_UNKNOWN; } uint8_t byte = (uint8_t) s[19]; if (byte & (1U<<4)) { - log_debug("DMI BIOS Extension table indicates virtualization"); + log_debug("DMI BIOS Extension table indicates virtualization."); return SMBIOS_VM_BIT_SET; } - log_debug("DMI BIOS Extension table does not indicate virtualization"); + log_debug("DMI BIOS Extension table does not indicate virtualization."); return SMBIOS_VM_BIT_UNSET; } #endif /* defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) */