Blame SOURCES/0001-Differentiate-between-vserver-host-and-guest.patch

45b90b
From d409914d13b88541402fe871d70e3dff9d738455 Mon Sep 17 00:00:00 2001
45b90b
From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= <glen@pld-linux.org>
45b90b
Date: Mon, 2 Sep 2013 15:24:11 +0100
45b90b
Subject: [PATCH 1/2] Differentiate between vserver host and guest.
45b90b
45b90b
RWMJ: Update documentation and tests.
45b90b
---
45b90b
 tests/test-linux-vserver.sh |  3 ++-
45b90b
 virt-what.in                |  5 +++++
45b90b
 virt-what.pod               | 12 ++++++++++++
45b90b
 3 files changed, 19 insertions(+), 1 deletion(-)
45b90b
45b90b
diff --git a/tests/test-linux-vserver.sh b/tests/test-linux-vserver.sh
45b90b
index 40d75a5..7988f81 100755
45b90b
--- a/tests/test-linux-vserver.sh
45b90b
+++ b/tests/test-linux-vserver.sh
45b90b
@@ -19,7 +19,8 @@
45b90b
 root=tests/linux-vserver
45b90b
 
45b90b
 output="$(./virt-what --test-root=$root 2>&1)"
45b90b
-expected="linux_vserver"
45b90b
+expected="linux_vserver
45b90b
+linux_vserver-guest"
45b90b
 
45b90b
 if [ "$output" != "$expected" ]; then
45b90b
     echo "$0: test failed because output did not match expected"
45b90b
diff --git a/virt-what.in b/virt-what.in
45b90b
index f12c95b..422f6d0 100644
45b90b
--- a/virt-what.in
45b90b
+++ b/virt-what.in
45b90b
@@ -147,6 +147,11 @@ fi
45b90b
 # Check for Linux-VServer
45b90b
 if cat "${root}/proc/self/status" | grep -q "VxID: [0-9]*"; then
45b90b
     echo linux_vserver
45b90b
+    if grep -q "VxID: 0$" "${root}/proc/self/status"; then
45b90b
+        echo linux_vserver-host
45b90b
+    else
45b90b
+        echo linux_vserver-guest
45b90b
+    fi
45b90b
 fi
45b90b
 
45b90b
 # Check for UML.
45b90b
diff --git a/virt-what.pod b/virt-what.pod
45b90b
index 98cd4af..bff2998 100644
45b90b
--- a/virt-what.pod
45b90b
+++ b/virt-what.pod
45b90b
@@ -62,10 +62,22 @@ Status: confirmed by RWMJ using a Fedora guest running in z/VM
45b90b
 
45b90b
 =item B<linux_vserver>
45b90b
 
45b90b
+This is printed for backwards compatibility with older virt-what which
45b90b
+could not distinguish between a Linux VServer container guest and
45b90b
+host.
45b90b
+
45b90b
+=item B<linux_vserver-guest>
45b90b
+
45b90b
 This process is running in a Linux VServer container.
45b90b
 
45b90b
 Status: contributed by Barış Metin
45b90b
 
45b90b
+=item B<linux_vserver-host>
45b90b
+
45b90b
+This process is running as the Linux VServer host (VxID 0).
45b90b
+
45b90b
+Status: contributed by Barış Metin and Elan Ruusamäe
45b90b
+
45b90b
 =item B<lxc>
45b90b
 
45b90b
 This process is running in a Linux LXC container.
45b90b
-- 
45b90b
1.8.3.1
45b90b