43ff24c
From 4b41b0d24b5efe70a5d6a39ff7b1f6571a7315b5 Mon Sep 17 00:00:00 2001
43ff24c
From: Thomas Blume <Thomas.Blume@suse.com>
43ff24c
Date: Fri, 18 Jul 2014 09:13:36 -0400
43ff24c
Subject: [PATCH] systemd-detect-virt: detect s390 virtualization
43ff24c
43ff24c
A system that is running on a logical partition (LPAR) provided by
43ff24c
PR/SM has access to physical hardware (except CPU). It is true that
43ff24c
PR/SM abstracts the hardware, but only for sharing purposes.
43ff24c
43ff24c
Details are statet at:
43ff24c
43ff24c
http://publib.boulder.ibm.com/infocenter/eserver/v1r2/topic/eicaz/eicazzlpar.htm
43ff24c
43ff24c
-->--
43ff24c
In other words, PR/SM transforms physical resources into virtual resources so
43ff24c
that many logical partitions can share the same physical resources.
43ff24c
--<--
43ff24c
43ff24c
Still, from the OS point of view, the shared virtual resource is real
43ff24c
hardware. ConditionVirtualization must be set to false if the OS runs
43ff24c
directly on PR/SM (e.g. in an LPAR).
43ff24c
43ff24c
[zj: reorder code so that variables are not allocated when #if-def is
43ff24c
false. Add commit message.]
43ff24c
43ff24c
(cherry picked from commit f41925b4e442a34c93ad120ef1426c974a047ed1)
43ff24c
---
43ff24c
 man/systemd.unit.xml |  1 +
43ff24c
 src/shared/virt.c    | 17 +++++++++++++++++
43ff24c
 2 files changed, 18 insertions(+)
43ff24c
43ff24c
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
43ff24c
index f66c580a37..e66be4ee51 100644
43ff24c
--- a/man/systemd.unit.xml
43ff24c
+++ b/man/systemd.unit.xml
43ff24c
@@ -995,6 +995,7 @@
43ff24c
                                 virtualization solution, or one of
43ff24c
                                 <varname>qemu</varname>,
43ff24c
                                 <varname>kvm</varname>,
43ff24c
+                                <varname>zvm</varname>,
43ff24c
                                 <varname>vmware</varname>,
43ff24c
                                 <varname>microsoft</varname>,
43ff24c
                                 <varname>oracle</varname>,
43ff24c
diff --git a/src/shared/virt.c b/src/shared/virt.c
43ff24c
index 20a8d7c5bf..b4368952ff 100644
43ff24c
--- a/src/shared/virt.c
43ff24c
+++ b/src/shared/virt.c
43ff24c
@@ -220,6 +220,23 @@ int detect_vm(const char **id) {
43ff24c
                 goto finish;
43ff24c
         }
43ff24c
 
43ff24c
+#if defined(__s390__)
43ff24c
+        {
43ff24c
+                _cleanup_free_ char *t = NULL;
43ff24c
+
43ff24c
+                r = get_status_field("/proc/sysinfo", "VM00 Control Program:", &t);
43ff24c
+                if (r >= 0) {
43ff24c
+                        if (streq(t, "z/VM"))
43ff24c
+                                _id = "zvm";
43ff24c
+                        else
43ff24c
+                                _id = "kvm";
43ff24c
+                        r = 1;
43ff24c
+
43ff24c
+                        goto finish;
43ff24c
+                }
43ff24c
+        }
43ff24c
+#endif
43ff24c
+
43ff24c
         r = 0;
43ff24c
 
43ff24c
 finish: