[PATCH virt-what] Add detection for systemd-nspawn instances

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also improve LXC/nspawn checks by not invoking `cat`

Co-authored-by: Elias Probst <e.probst@xxxxxxxxxxxxxxx>
Signed-off-by: Elias Probst <e.probst@xxxxxxxxxxxxxxx>
---
 virt-what.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/virt-what.in b/virt-what.in
index d090898..97aef3e 100644
--- a/virt-what.in
+++ b/virt-what.in
@@ -174,9 +174,12 @@ fi
 # http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface
 # Added by Marc Fournier

-if [ -e "${root}/proc/1/environ" ] &&
-    cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container=lxc'; then
-    echo lxc
+if [ -e "${root}/proc/1/environ" ]; then
+    if tr '\000' '\n' < "${root}/proc/1/environ" | grep -Eiq '^container=lxc'; then
+        echo lxc
+    elif tr '\000' '\n' < "${root}/proc/1/environ" | grep -Eiq '^container=systemd-nspawn'; then
+        echo systemd-nspawn
+    fi
 fi

 if [ -e "${root}/proc/1/environ" ] &&
--
2.34.1





[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux