Skip to content

Commit 654e805

Browse files
mrc0mmandbluca
authored andcommitted
virt: correctly detect QEMU emulated pSeries guests
Resolves: #26629 (cherry picked from commit 8c7a6c7) (cherry picked from commit 1a22006) (cherry picked from commit 48911dc) (cherry picked from commit 0857956)
1 parent fadf3c4 commit 654e805

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/basic/virt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static int detect_vm_device_tree(void) {
9898
r = read_one_line_file("/proc/device-tree/hypervisor/compatible", &hvtype);
9999
if (r == -ENOENT) {
100100
_cleanup_closedir_ DIR *dir = NULL;
101+
_cleanup_free_ char *compat = NULL;
101102

102103
if (access("/proc/device-tree/ibm,partition-name", F_OK) == 0 &&
103104
access("/proc/device-tree/hmc-managed?", F_OK) == 0 &&
@@ -119,6 +120,14 @@ static int detect_vm_device_tree(void) {
119120
return VIRTUALIZATION_QEMU;
120121
}
121122

123+
r = read_one_line_file("/proc/device-tree/compatible", &compat);
124+
if (r < 0 && r != -ENOENT)
125+
return r;
126+
if (r >= 0 && streq(compat, "qemu,pseries")) {
127+
log_debug("Virtualization %s found in /proc/device-tree/compatible", compat);
128+
return VIRTUALIZATION_QEMU;
129+
}
130+
122131
log_debug("No virtualization found in /proc/device-tree/*");
123132
return VIRTUALIZATION_NONE;
124133
} else if (r < 0)

0 commit comments

Comments
 (0)