[PATCH] Detect SmartOS LX virtualization

Steve Mokris smokris at softpixel.com
Tue May 10 20:58:06 UTC 2022


SmartOS is an Illumos kernel with isolated zones and a Linux syscall emulation layer ("LX").

Currently, virt-what outputs nothing when run inside SmartOS LX.  This patch enables virt-what to detect SmartOS LX virtualization.

Before:
        # virt-what
        (no output)

After:
        # virt-what
        smartos-lx

Additional info requested in the README:

  (1) /proc/cpuinfo
        processor       : 0
        vendor_id       : GenuineIntel
        cpu family      : 6
        model           : 26
        model name      : Intel(r) Xeon(r) CPU           E5506  @ 2.13GHz
        stepping        : 5
        cpu MHz         : 1599.986
        cache size      : 0 KB
        physical id     : 0
        siblings        : 4
        fdiv_bug        : no
        hlt_bug         : no
        f00f_bug        : no
        coma_bug        : no
        fpu             : yes
        fpu_exception   : yes
        cpuid level     : 11
        flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm

        processor       : 1
        ...

  (2) dmidecode
        (no output)

  (3) /usr/libexec/virt-what-cpuid-helper
        (no output)

  (4) Any other /proc and /sys files that may be related to the hypervisor.
        # cat /proc/1/environ
        container=zone
        # cat /proc/version
        Linux version 3.16.0 (gcc version 7.5.0) BrandZ virtual linux
        # uname -a
        Linux test 3.16.0 BrandZ virtual linux x86_64 x86_64 x86_64 GNU/Linux

  (5) Name of the virtualization system, version, host or guest, and as much other information as possible.
        SmartOS LX zone
        tested with SmartOS platform image 20220421T000508Z
        guest
        https://wiki.smartos.org/zones/
        https://wiki.smartos.org/illumos-and-smartos-basics/glossary/#lx
        https://en.wikipedia.org/wiki/SmartOS#LX_(Linux_Emulation)

---
 configure.ac                    |   2 ++
 tests/smartos-lx/proc/1/environ | Bin 0 -> 15 bytes
 tests/smartos-lx/proc/version   |   1 +
 tests/smartos-lx/test.sh        |  32 ++++++++++++++++++++++++++++++++
 virt-what.in                    |   7 +++++++
 virt-what.pod                   |   7 +++++++
 6 files changed, 49 insertions(+)
 create mode 100644 tests/smartos-lx/proc/1/environ
 create mode 100644 tests/smartos-lx/proc/version
 create mode 100755 tests/smartos-lx/test.sh

diff --git a/configure.ac b/configure.ac
index ad481fc..51d16bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,7 @@ tests="\
 	rhel5-xen-domU-hvm-ia64 \
 	rhel5-xen-domU-pv \
 	rhev \
+	smartos-lx \
 	vmm \
 	xen-arm \
 	zvm \
@@ -115,6 +116,7 @@ AC_CONFIG_FILES([Makefile
 	         tests/rhel5-xen-domU-hvm-ia64/Makefile
 	         tests/rhel5-xen-domU-pv/Makefile
 	         tests/rhev/Makefile
+	         tests/smartos-lx/Makefile
 	         tests/vmm/Makefile
 	         tests/xen-arm/Makefile
 	         tests/zvm/Makefile
diff --git a/tests/smartos-lx/proc/1/environ b/tests/smartos-lx/proc/1/environ
new file mode 100644
index 0000000000000000000000000000000000000000..42ec275a5b7959d3d7c36f73bc81a57eba19c23c
GIT binary patch
literal 15
WcmYe!&nrpH%u6k at t;)|!WdHy${RO=M

literal 0
HcmV?d00001

diff --git a/tests/smartos-lx/proc/version b/tests/smartos-lx/proc/version
new file mode 100644
index 0000000..986628f
--- /dev/null
+++ b/tests/smartos-lx/proc/version
@@ -0,0 +1 @@
+Linux version 3.16.0 (gcc version 7.5.0) BrandZ virtual linux
diff --git a/tests/smartos-lx/test.sh b/tests/smartos-lx/test.sh
new file mode 100755
index 0000000..8f408b0
--- /dev/null
+++ b/tests/smartos-lx/test.sh
@@ -0,0 +1,32 @@
+# Test for smartos-lx
+# Copyright (C) 2022 Steve Mokris
+#
+# 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="smartos-lx"
+
+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 d56c84f..b10283b 100644
--- a/virt-what.in
+++ b/virt-what.in
@@ -179,6 +179,13 @@ if [ -e "${root}/proc/1/environ" ] &&
     echo lxc
 fi
 
+if [ -e "${root}/proc/1/environ" ] &&
+    cat "${root}/proc/1/environ" | tr '\000' '\n' | grep -q '^container=zone$' &&
+    [ -e "${root}/proc/version" ] &&
+    cat "${root}/proc/version" | grep -q 'BrandZ virtual linux'; then
+    echo smartos-lx
+fi
+
 # Check for Linux-VServer
 if test -e "${root}/proc/self/status" \
    && cat "${root}/proc/self/status" | grep -q "VxID: [0-9]*"; then
diff --git a/virt-what.pod b/virt-what.pod
index 2bce5c8..31f8944 100644
--- a/virt-what.pod
+++ b/virt-what.pod
@@ -252,6 +252,13 @@ The guest is running on the Red Hat hypervisor.
 
 Status: confirmed by RWMJ
 
+=item B<smartos-lx>
+
+The guest is running on SmartOS LX (Illumos kernel with isolated zones
+and a Linux syscall emulation layer).
+
+Status: contributed by Steve Mokris
+
 =item B<uml>
 
 This is a User-Mode Linux (UML) guest.
-- 
2.31.1



More information about the virt-tools-list mailing list