teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0581-basic-virt-Detect-PowerVM-hypervisor.patch

b677e7
From 48dacf8d30cd61b72939e9c3419acced4b2fde74 Mon Sep 17 00:00:00 2001
b677e7
From: Michal Suchanek <msuchanek@suse.de>
b677e7
Date: Fri, 2 Oct 2020 11:05:23 +0200
b677e7
Subject: [PATCH] basic/virt: Detect PowerVM hypervisor
b677e7
b677e7
Currently systemd-detect-virt fails to detect running under PowerVM.
b677e7
b677e7
Add code to detect PowerVM based on code in util-linux.
b677e7
b677e7
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
b677e7
(cherry picked from commit 3224e38bb6b3287ca253cbafb460a150544d5818)
b677e7
b677e7
Resolves: #1937989
b677e7
---
b677e7
 man/systemd-detect-virt.xml | 7 ++++++-
b677e7
 src/basic/virt.c            | 6 ++++++
b677e7
 src/basic/virt.h            | 1 +
b677e7
 3 files changed, 13 insertions(+), 1 deletion(-)
b677e7
b677e7
diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml
b677e7
index c4763fd561..6beb2c2aa1 100644
b677e7
--- a/man/systemd-detect-virt.xml
b677e7
+++ b/man/systemd-detect-virt.xml
b677e7
@@ -65,7 +65,7 @@
b677e7
         
b677e7
         
b677e7
           <row>
b677e7
-            <entry valign="top" morerows="11">VM</entry>
b677e7
+            <entry valign="top" morerows="12">VM</entry>
b677e7
             <entry><varname>qemu</varname></entry>
b677e7
             <entry>QEMU software virtualization, without KVM</entry>
b677e7
           </row>
b677e7
@@ -95,6 +95,11 @@
b677e7
             <entry>Oracle VM VirtualBox (historically marketed by innotek and Sun Microsystems), for legacy and KVM hypervisor</entry>
b677e7
           </row>
b677e7
 
b677e7
+          <row>
b677e7
+            <entry><varname>powervm</varname></entry>
b677e7
+            <entry>IBM PowerVM hypervisor - comes as firmware with some IBM POWER servers</entry>
b677e7
+          </row>
b677e7
+
b677e7
           <row>
b677e7
             <entry><varname>xen</varname></entry>
b677e7
             <entry>Xen hypervisor (only domU, not dom0)</entry>
b677e7
diff --git a/src/basic/virt.c b/src/basic/virt.c
b677e7
index dfa1525219..0b88005ed6 100644
b677e7
--- a/src/basic/virt.c
b677e7
+++ b/src/basic/virt.c
b677e7
@@ -92,6 +92,11 @@ static int detect_vm_device_tree(void) {
b677e7
                 _cleanup_closedir_ DIR *dir = NULL;
b677e7
                 struct dirent *dent;
b677e7
 
b677e7
+                if (access("/proc/device-tree/ibm,partition-name", F_OK) == 0 &&
b677e7
+                    access("/proc/device-tree/hmc-managed?", F_OK) == 0 &&
b677e7
+                    access("/proc/device-tree/chosen/qemu,graphic-width", F_OK) != 0)
b677e7
+                        return VIRTUALIZATION_POWERVM;
b677e7
+
b677e7
                 dir = opendir("/proc/device-tree");
b677e7
                 if (!dir) {
b677e7
                         if (errno == ENOENT) {
b677e7
@@ -635,6 +640,7 @@ static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
b677e7
         [VIRTUALIZATION_PARALLELS] = "parallels",
b677e7
         [VIRTUALIZATION_BHYVE] = "bhyve",
b677e7
         [VIRTUALIZATION_QNX] = "qnx",
b677e7
+        [VIRTUALIZATION_POWERVM] = "powervm",
b677e7
         [VIRTUALIZATION_VM_OTHER] = "vm-other",
b677e7
 
b677e7
         [VIRTUALIZATION_SYSTEMD_NSPAWN] = "systemd-nspawn",
b677e7
diff --git a/src/basic/virt.h b/src/basic/virt.h
b677e7
index c4cf4bfeab..640b3ed779 100644
b677e7
--- a/src/basic/virt.h
b677e7
+++ b/src/basic/virt.h
b677e7
@@ -21,6 +21,7 @@ enum {
b677e7
         VIRTUALIZATION_PARALLELS,
b677e7
         VIRTUALIZATION_BHYVE,
b677e7
         VIRTUALIZATION_QNX,
b677e7
+        VIRTUALIZATION_POWERVM,
b677e7
         VIRTUALIZATION_VM_OTHER,
b677e7
         VIRTUALIZATION_VM_LAST = VIRTUALIZATION_VM_OTHER,
b677e7