1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-21 09:33:57 +03:00

virt: correctly detect QEMU emulated pSeries guests

Resolves: #26629
(cherry picked from commit 8c7a6c742a)
(cherry picked from commit 1a22006574)
This commit is contained in:
Frantisek Sumsal 2023-03-01 13:57:03 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 8e6234064d
commit 48911dc5ec

View File

@ -102,6 +102,7 @@ static Virtualization detect_vm_device_tree(void) {
r = read_one_line_file("/proc/device-tree/hypervisor/compatible", &hvtype);
if (r == -ENOENT) {
_cleanup_closedir_ DIR *dir = NULL;
_cleanup_free_ char *compat = NULL;
if (access("/proc/device-tree/ibm,partition-name", F_OK) == 0 &&
access("/proc/device-tree/hmc-managed?", F_OK) == 0 &&
@ -123,6 +124,14 @@ static Virtualization detect_vm_device_tree(void) {
return VIRTUALIZATION_QEMU;
}
r = read_one_line_file("/proc/device-tree/compatible", &compat);
if (r < 0 && r != -ENOENT)
return r;
if (r >= 0 && streq(compat, "qemu,pseries")) {
log_debug("Virtualization %s found in /proc/device-tree/compatible", compat);
return VIRTUALIZATION_QEMU;
}
log_debug("No virtualization found in /proc/device-tree/*");
return VIRTUALIZATION_NONE;
} else if (r < 0)