teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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