On Tue, 8 Jul 2014, Lennart Poettering wrote:


PR/SM is the hypervisor, so it should be detected as *not*
virtualized, which mean that it does not get any _id string. For the
virtualized systems on top, yes, it'd be nice to be able to
distinguish them, iff there are clear and unamigous distinction
between virtualization approaches. So detecting one as "kvm" and the
other as z/something things sounds fine.

I agree. Except for one thing: I'd prefer if we could keep the
identifiers free of special chars. Hence "zsomethhing" rather than
"z/something", please...


Ok, thanks for the input.
Attached is the new patch.


Regards
Thomas
From f07e44eee266a997a62399290632a09fe4af92cf Mon Sep 17 00:00:00 2001
From: Thomas Blume <thomas.bl...@suse.com>
Date: Fri, 18 Jul 2014 11:15:59 +0200
Subject: [PATCH] detect s390 virtualization

Add kvm and z/VM virtualization detection on s390(x).
---
 man/systemd.unit.xml |  1 +
 src/shared/virt.c    | 21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 6447584..86a8cbb 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -996,6 +996,7 @@
                                 virtualization solution, or one of
                                 <varname>qemu</varname>,
                                 <varname>kvm</varname>,
+                                <varname>zvm</varname>,
                                 <varname>vmware</varname>,
                                 <varname>microsoft</varname>,
                                 <varname>oracle</varname>,
diff --git a/src/shared/virt.c b/src/shared/virt.c
index 20a8d7c..3b9b706 100644
--- a/src/shared/virt.c
+++ b/src/shared/virt.c
@@ -148,11 +148,11 @@ static int detect_vm_dmi(const char **_id) {
 
 /* Returns a short identifier for the various VM implementations */
 int detect_vm(const char **id) {
-        _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL;
+        _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL, *controlprogram = NULL;
         static thread_local int cached_found = -1;
         static thread_local const char *cached_id = NULL;
         const char *_id = NULL;
-        int r;
+        int r, s;
 
         if (_likely_(cached_found >= 0)) {
 
@@ -222,6 +222,23 @@ int detect_vm(const char **id) {
 
         r = 0;
 
+#if defined(__s390__)
+        r = 0;
+
+        s = get_status_field("/proc/sysinfo", "VM00 Control Program:", &controlprogram);
+        if (s >= 0) {
+           r = 1;
+
+           if (strcmp(controlprogram, "z/VM") == 0)
+              _id = "zvm";
+           else if (strcmp(controlprogram, "KVM/Linux") == 0)
+              _id = "kvm";
+
+        }
+
+        goto finish;
+#endif
+
 finish:
         cached_found = r;
 
-- 
1.8.4.5

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to