From 1df728aa4b1d2814265f9c86494f7d55ee0cf9af Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Mon, 13 Apr 2020 21:41:30 +0000 Subject: [PATCH] Add podman support --- configure.ac | 2 ++ tests/podman/1/environ | Bin 0 -> 155 bytes tests/podman/Makefile.am | 29 ++++++++++++++++++++++++++++ tests/podman/proc/cpuinfo | 0 tests/podman/proc/self/cgroup | 10 ++++++++++ tests/podman/proc/self/status | 0 tests/podman/sbin/dmidecode | 6 ++++++ tests/podman/sbin/uname | 2 ++ tests/podman/sbin/virt-what-cpuid-helper | 2 ++ tests/podman/test.sh | 32 +++++++++++++++++++++++++++++++ virt-what.in | 10 +++++++++- virt-what.pod | 6 ++++++ 12 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/podman/1/environ create mode 100644 tests/podman/Makefile.am create mode 100644 tests/podman/proc/cpuinfo create mode 100644 tests/podman/proc/self/cgroup create mode 100644 tests/podman/proc/self/status create mode 100755 tests/podman/sbin/dmidecode create mode 100755 tests/podman/sbin/uname create mode 100755 tests/podman/sbin/virt-what-cpuid-helper create mode 100755 tests/podman/test.sh diff --git a/configure.ac b/configure.ac index 58b3d77..97d22bb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 0000000000000000000000000000000000000000..dd6f0d4d67a151ab7bab97565b0737b8dbf7db44 GIT binary patch literal 155 zcmYL>K?=hl5JhL*%XorW3^JI2CJ>u-F>Rni)ncUd_?@JS?B@UX=Ygfcpaw_1MfC|) zr4V1LmeOGMJmGP5qhtJ+`+g?F^0V`SgdCeIPY%CrtqJUC&fa%yMZLtVmasj+>YHQl YMd8IEi3Dr7m)t_kYsGhYq>$nA11>u+CjbBd literal 0 HcmV?d00001 diff --git a/tests/podman/Makefile.am b/tests/podman/Makefile.am new file mode 100644 index 0000000..a4c70ad --- /dev/null +++ b/tests/podman/Makefile.am @@ -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 index 0000000..e69de29 diff --git a/tests/podman/proc/self/cgroup b/tests/podman/proc/self/cgroup new file mode 100644 index 0000000..11fc74e --- /dev/null +++ b/tests/podman/proc/self/cgroup @@ -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 index 0000000..e69de29 diff --git a/tests/podman/sbin/dmidecode b/tests/podman/sbin/dmidecode new file mode 100755 index 0000000..d9992ad --- /dev/null +++ b/tests/podman/sbin/dmidecode @@ -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 index 0000000..ab0ec89 --- /dev/null +++ b/tests/podman/sbin/uname @@ -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 index 0000000..ad82504 --- /dev/null +++ b/tests/podman/sbin/virt-what-cpuid-helper @@ -0,0 +1,2 @@ +#!/bin/sh - +echo @ diff --git a/tests/podman/test.sh b/tests/podman/test.sh new file mode 100755 index 0000000..6db58e5 --- /dev/null +++ b/tests/podman/test.sh @@ -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 diff --git a/virt-what.in b/virt-what.in index d43916b..d52171c 100644 --- a/virt-what.in +++ b/virt-what.in @@ -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' diff --git a/virt-what.pod b/virt-what.pod index ea5cb77..405537b 100644 --- a/virt-what.pod +++ b/virt-what.pod @@ -204,6 +204,12 @@ The guest is running inside Parallels Virtual Platform Status: contributed by Justin Clift +=item B + +This is a Podman container. + +Status: contributed by Jordan Webb + =item B The guest is running inside IBM PowerVM Lx86 Linux/x86 emulator. -- 1.8.3.1