Add podman support
authorJordan Webb <jordemort@github.com>
Mon, 13 Apr 2020 21:41:30 +0000 (21:41 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 7 Jul 2020 15:02:50 +0000 (16:02 +0100)
12 files changed:
configure.ac
tests/podman/1/environ [new file with mode: 0644]
tests/podman/Makefile.am [new file with mode: 0644]
tests/podman/proc/cpuinfo [new file with mode: 0644]
tests/podman/proc/self/cgroup [new file with mode: 0644]
tests/podman/proc/self/status [new file with mode: 0644]
tests/podman/sbin/dmidecode [new file with mode: 0755]
tests/podman/sbin/uname [new file with mode: 0755]
tests/podman/sbin/virt-what-cpuid-helper [new file with mode: 0755]
tests/podman/test.sh [new file with mode: 0755]
virt-what.in
virt-what.pod

index 58b3d77..97d22bb 100644 (file)
@@ -53,6 +53,7 @@ tests="\
        lxc \
        nutanix-ahv \
        parallels-desktop \
+       podman \
        ppc64-baremetal \
        ppc64-kvm \
        ppc64-lpar-dedicated \
@@ -96,6 +97,7 @@ AC_CONFIG_FILES([Makefile
                 tests/lxc/Makefile
                 tests/nutanix-ahv/Makefile
                 tests/parallels-desktop/Makefile
+                tests/podman/Makefile
                 tests/ppc64-baremetal/Makefile
                 tests/ppc64-kvm/Makefile
                 tests/ppc64-lpar-dedicated/Makefile
diff --git a/tests/podman/1/environ b/tests/podman/1/environ
new file mode 100644 (file)
index 0000000..dd6f0d4
Binary files /dev/null and b/tests/podman/1/environ differ
diff --git a/tests/podman/Makefile.am b/tests/podman/Makefile.am
new file mode 100644 (file)
index 0000000..a4c70ad
--- /dev/null
@@ -0,0 +1,29 @@
+# Makefile for virt-what
+# Copyright (C) 2008-2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+CLEANFILES = *~
+
+TESTS = test.sh
+
+EXTRA_DIST = \
+       test.sh \
+       proc/cpuinfo \
+       proc/self/cgroup \
+       proc/self/status \
+       sbin/dmidecode \
+       sbin/uname \
+       sbin/virt-what-cpuid-helper
diff --git a/tests/podman/proc/cpuinfo b/tests/podman/proc/cpuinfo
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/podman/proc/self/cgroup b/tests/podman/proc/self/cgroup
new file mode 100644 (file)
index 0000000..11fc74e
--- /dev/null
@@ -0,0 +1,10 @@
+11:perf_event:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+10:devices:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+8:pids:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+7:blkio:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+6:cpu,cpuacct:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+5:net_cls,net_prio:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+4:freezer:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+3:cpuset:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+2:memory:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
+1:name=systemd:/machine.slice/libpod-2ed85a65b4d6aedbf4e6bd1bb2d29e6d7778791bd02532788eb16954cebf01da.scope
diff --git a/tests/podman/proc/self/status b/tests/podman/proc/self/status
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/podman/sbin/dmidecode b/tests/podman/sbin/dmidecode
new file mode 100755 (executable)
index 0000000..d9992ad
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh -
+cat <<'EOF'
+# dmidecode 2.11
+/dev/mem: Operation not permitted
+EOF
+exit 1
diff --git a/tests/podman/sbin/uname b/tests/podman/sbin/uname
new file mode 100755 (executable)
index 0000000..ab0ec89
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh -
+echo x86_64
diff --git a/tests/podman/sbin/virt-what-cpuid-helper b/tests/podman/sbin/virt-what-cpuid-helper
new file mode 100755 (executable)
index 0000000..ad82504
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh -
+echo @
diff --git a/tests/podman/test.sh b/tests/podman/test.sh
new file mode 100755 (executable)
index 0000000..6db58e5
--- /dev/null
@@ -0,0 +1,32 @@
+# Test for Podman
+# Copyright (C) 2008-2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)"
+expected="podman"
+
+if [ "$output" != "$expected" ]; then
+    echo "$0: test failed because output did not match expected"
+    echo "Expected output was:"
+    echo "----------------------------------------"
+    echo "$expected"
+    echo "----------------------------------------"
+    echo "But the actual output of the program was:"
+    echo "----------------------------------------"
+    echo "$output"
+    echo "----------------------------------------"
+    exit 1
+fi
index d43916b..d52171c 100644 (file)
@@ -165,7 +165,7 @@ fi
 # Added by Marc Fournier
 
 if [ -e "${root}/proc/1/environ" ] &&
-    cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container='; then
+    cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container=lxc'; then
     echo lxc
 fi
 
@@ -350,6 +350,14 @@ if [ -f "${root}/.dockerenv" ] || [ -f "${root}/.dockerinit" ] || \
     echo docker
 fi
 
+# Check for Podman.
+if [ -e "${root}/proc/1/environ" ] &&
+    cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container=podman'; then
+    echo podman
+elif grep -qF /libpod- "${root}/proc/self/cgroup" 2>/dev/null; then
+    echo podman
+fi
+
 # Check ppc64 lpar, kvm or powerkvm
 
 # example /proc/cpuinfo line indicating 'not baremetal'
index ea5cb77..405537b 100644 (file)
@@ -204,6 +204,12 @@ The guest is running inside Parallels Virtual Platform
 
 Status: contributed by Justin Clift
 
+=item B<podman>
+
+This is a Podman container.
+
+Status: contributed by Jordan Webb
+
 =item B<powervm_lx86>
 
 The guest is running inside IBM PowerVM Lx86 Linux/x86 emulator.