From: Michal Suchanek Date: Fri, 2 Oct 2020 09:05:23 +0000 (+0200) Subject: basic/virt: Detect PowerVM hypervisor X-Git-Tag: v247-rc1~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3224e38bb6b3287ca253cbafb460a150544d5818;p=thirdparty%2Fsystemd.git basic/virt: Detect PowerVM hypervisor Currently systemd-detect-virt fails to detect running under PowerVM. Add code to detect PowerVM based on code in util-linux. Signed-off-by: Michal Suchanek --- diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml index 9c66fa7afaf..36c4602d696 100644 --- a/man/systemd-detect-virt.xml +++ b/man/systemd-detect-virt.xml @@ -62,7 +62,7 @@ - VM + VM qemu QEMU software virtualization, without KVM @@ -92,6 +92,11 @@ Oracle VM VirtualBox (historically marketed by innotek and Sun Microsystems), for legacy and KVM hypervisor + + powervm + IBM PowerVM hypervisor - comes as firmware with some IBM POWER servers + + xen Xen hypervisor (only domU, not dom0) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 1ab6e2b0b94..a845bc23b27 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1160,6 +1160,7 @@ vmware, microsoft, oracle, + powervm, xen, bochs, uml, diff --git a/src/basic/virt.c b/src/basic/virt.c index 80128cb3aaf..bb908847f5b 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -93,6 +93,11 @@ static int detect_vm_device_tree(void) { _cleanup_closedir_ DIR *dir = NULL; struct dirent *dent; + if (access("/proc/device-tree/ibm,partition-name", F_OK) == 0 && + access("/proc/device-tree/hmc-managed?", F_OK) == 0 && + access("/proc/device-tree/chosen/qemu,graphic-width", F_OK) != 0) + return VIRTUALIZATION_POWERVM; + dir = opendir("/proc/device-tree"); if (!dir) { if (errno == ENOENT) { @@ -679,6 +684,7 @@ static const char *const virtualization_table[_VIRTUALIZATION_MAX] = { [VIRTUALIZATION_BHYVE] = "bhyve", [VIRTUALIZATION_QNX] = "qnx", [VIRTUALIZATION_ACRN] = "acrn", + [VIRTUALIZATION_POWERVM] = "powervm", [VIRTUALIZATION_VM_OTHER] = "vm-other", [VIRTUALIZATION_SYSTEMD_NSPAWN] = "systemd-nspawn", diff --git a/src/basic/virt.h b/src/basic/virt.h index 18aa5eff153..2f7f7203d29 100644 --- a/src/basic/virt.h +++ b/src/basic/virt.h @@ -22,6 +22,7 @@ enum { VIRTUALIZATION_BHYVE, VIRTUALIZATION_QNX, VIRTUALIZATION_ACRN, + VIRTUALIZATION_POWERVM, VIRTUALIZATION_VM_OTHER, VIRTUALIZATION_VM_LAST = VIRTUALIZATION_VM_OTHER,