From 54c2ad4a764658ec8a9aadc52c749eabf1de73a0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Jan 2023 12:34:02 +0000 Subject: [PATCH] Detect OCI containers Podman using OCI containers sets container=oci in PID 1's environment. Detect that and print "oci" fact. This patch was originally contributed by Alessandro Valentini. I modified it and added tests and documentation. Reported-by: Alessandro Valentini Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2155233 --- configure.ac | 2 + tests/oci/Makefile.am | 28 ++ tests/oci/proc/1/environ | Bin 0 -> 124 bytes tests/oci/proc/cpuinfo | 671 ++++++++++++++++++++++++++ tests/oci/sbin/dmidecode | 7 + tests/oci/sbin/uname | 2 + tests/oci/sbin/virt-what-cpuid-helper | 2 + tests/oci/test.sh | 32 ++ virt-what.in | 6 + virt-what.pod | 8 +- 10 files changed, 757 insertions(+), 1 deletion(-) create mode 100644 tests/oci/Makefile.am create mode 100644 tests/oci/proc/1/environ create mode 100644 tests/oci/proc/cpuinfo create mode 100755 tests/oci/sbin/dmidecode create mode 100755 tests/oci/sbin/uname create mode 100755 tests/oci/sbin/virt-what-cpuid-helper create mode 100755 tests/oci/test.sh diff --git a/configure.ac b/configure.ac index 8f808a38b..a80a4b6f0 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ tests="\ lx86 \ lxc \ nutanix-ahv \ + oci \ parallels-desktop \ podman \ ppc64-baremetal \ @@ -104,6 +105,7 @@ AC_CONFIG_FILES([Makefile tests/lx86/Makefile tests/lxc/Makefile tests/nutanix-ahv/Makefile + tests/oci/Makefile tests/parallels-desktop/Makefile tests/podman/Makefile tests/ppc64-baremetal/Makefile diff --git a/tests/oci/Makefile.am b/tests/oci/Makefile.am new file mode 100644 index 000000000..b2f6f2469 --- /dev/null +++ b/tests/oci/Makefile.am @@ -0,0 +1,28 @@ +# Makefile for virt-what +# Copyright (C) 2008-2023 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/1/environ \ + proc/cpuinfo \ + sbin/dmidecode \ + sbin/uname \ + sbin/virt-what-cpuid-helper diff --git a/tests/oci/proc/1/environ b/tests/oci/proc/1/environ new file mode 100644 index 0000000000000000000000000000000000000000..03d40a45377eaeccef15532734d2f5b7fd42234e GIT binary patch literal 124 zcmWG=4DqnlFD)+8&&f|t%+W7S%FMGu;={QJ39t}^3uH2cxCZ&!R+OX` + +The guest is running in an OCI container. + +Status: contributed by Alessandro Valentini, confirmed by RWMJ + =item B The guest appears to be running inside an OpenVZ or Virtuozzo @@ -226,7 +232,7 @@ Status: contributed by Justin Clift =item B -This is a Podman container. +This is a Podman container. (See also C above.) Status: contributed by Jordan Webb -- 2.43.0