Blame SOURCES/0022-Add-support-for-VMware-ESXi-on-ARM.patch

fcf72c
From 8640dad5eb60eced313359e7ecea19b07d77242f Mon Sep 17 00:00:00 2001
fcf72c
From: Razvan Corneliu <razvan.vilt@linux360.ro>
fcf72c
Date: Mon, 10 May 2021 21:02:27 +0100
fcf72c
Subject: [PATCH 22/22] Add support for VMware ESXi on ARM
fcf72c
fcf72c
Virt-what doesn't recognize VMware VMs for AARCH64/ARM (with licensing
fcf72c
implications in ESXi Fling for ARM and Fusion v.Next for ARM). I've
fcf72c
created and attached a patch that adds both support for recognizing
fcf72c
ESXi and the automated tests for it.
fcf72c
---
fcf72c
 configure.ac                                  |  2 +
fcf72c
 tests/esx-arm/Makefile.am                     | 30 ++++++++++
fcf72c
 tests/esx-arm/proc/cpuinfo                    | 18 ++++++
fcf72c
 .../proc/device-tree/hypervisor/compatible    |  1 +
fcf72c
 .../esx-arm/proc/device-tree/hypervisor/name  |  1 +
fcf72c
 tests/esx-arm/proc/self/status                | 55 +++++++++++++++++++
fcf72c
 tests/esx-arm/sbin/dmidecode                  |  2 +
fcf72c
 tests/esx-arm/sbin/uname                      |  2 +
fcf72c
 tests/esx-arm/sbin/virt-what-cpuid-helper     |  2 +
fcf72c
 tests/esx-arm/test.sh                         | 32 +++++++++++
fcf72c
 virt-what.in                                  |  4 ++
fcf72c
 11 files changed, 149 insertions(+)
fcf72c
 create mode 100644 tests/esx-arm/Makefile.am
fcf72c
 create mode 100644 tests/esx-arm/proc/cpuinfo
fcf72c
 create mode 100644 tests/esx-arm/proc/device-tree/hypervisor/compatible
fcf72c
 create mode 100644 tests/esx-arm/proc/device-tree/hypervisor/name
fcf72c
 create mode 100644 tests/esx-arm/proc/self/status
fcf72c
 create mode 100755 tests/esx-arm/sbin/dmidecode
fcf72c
 create mode 100755 tests/esx-arm/sbin/uname
fcf72c
 create mode 100755 tests/esx-arm/sbin/virt-what-cpuid-helper
fcf72c
 create mode 100755 tests/esx-arm/test.sh
fcf72c
fcf72c
diff --git a/configure.ac b/configure.ac
fcf72c
index f246e34..f9b3096 100644
fcf72c
--- a/configure.ac
fcf72c
+++ b/configure.ac
fcf72c
@@ -41,6 +41,7 @@ tests="\
fcf72c
 	baremetal \
fcf72c
 	bhyve \
fcf72c
 	docker \
fcf72c
+	esx-arm \
fcf72c
 	esx4.1 \
fcf72c
 	hyperv \
fcf72c
 	kvm \
fcf72c
@@ -84,6 +85,7 @@ AC_CONFIG_FILES([Makefile
fcf72c
 	         tests/baremetal/Makefile
fcf72c
 	         tests/bhyve/Makefile
fcf72c
 	         tests/docker/Makefile
fcf72c
+	         tests/esx-arm/Makefile
fcf72c
 	         tests/esx4.1/Makefile
fcf72c
 	         tests/hyperv/Makefile
fcf72c
 	         tests/kvm/Makefile
fcf72c
diff --git a/tests/esx-arm/Makefile.am b/tests/esx-arm/Makefile.am
fcf72c
new file mode 100644
fcf72c
index 0000000..b87ec83
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/Makefile.am
fcf72c
@@ -0,0 +1,30 @@
fcf72c
+# Makefile for virt-what
fcf72c
+# Copyright (C) 2008-2011 Red Hat Inc.
fcf72c
+#
fcf72c
+# This program is free software; you can redistribute it and/or modify
fcf72c
+# it under the terms of the GNU General Public License as published by
fcf72c
+# the Free Software Foundation; either version 2 of the License, or
fcf72c
+# (at your option) any later version.
fcf72c
+#
fcf72c
+# This program is distributed in the hope that it will be useful,
fcf72c
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
fcf72c
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fcf72c
+# GNU General Public License for more details.
fcf72c
+#
fcf72c
+# You should have received a copy of the GNU General Public License
fcf72c
+# along with this program; if not, write to the Free Software
fcf72c
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
fcf72c
+
fcf72c
+CLEANFILES = *~
fcf72c
+
fcf72c
+TESTS = test.sh
fcf72c
+
fcf72c
+EXTRA_DIST = \
fcf72c
+	test.sh \
fcf72c
+	proc/cpuinfo \
fcf72c
+	proc/device-tree/hypervisor/compatible \
fcf72c
+	proc/device-tree/hypervisor/name \
fcf72c
+	proc/self/status \
fcf72c
+	sbin/dmidecode \
fcf72c
+	sbin/uname \
fcf72c
+	sbin/virt-what-cpuid-helper
fcf72c
diff --git a/tests/esx-arm/proc/cpuinfo b/tests/esx-arm/proc/cpuinfo
fcf72c
new file mode 100644
fcf72c
index 0000000..246b574
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/proc/cpuinfo
fcf72c
@@ -0,0 +1,18 @@
fcf72c
+processor	: 0
fcf72c
+BogoMIPS	: 108.00
fcf72c
+Features	: fp asimd evtstrm crc32 cpuid
fcf72c
+CPU implementer	: 0x41
fcf72c
+CPU architecture: 8
fcf72c
+CPU variant	: 0x0
fcf72c
+CPU part	: 0xd08
fcf72c
+CPU revision	: 3
fcf72c
+
fcf72c
+processor	: 1
fcf72c
+BogoMIPS	: 108.00
fcf72c
+Features	: fp asimd evtstrm crc32 cpuid
fcf72c
+CPU implementer	: 0x41
fcf72c
+CPU architecture: 8
fcf72c
+CPU variant	: 0x0
fcf72c
+CPU part	: 0xd08
fcf72c
+CPU revision	: 3
fcf72c
+
fcf72c
diff --git a/tests/esx-arm/proc/device-tree/hypervisor/compatible b/tests/esx-arm/proc/device-tree/hypervisor/compatible
fcf72c
new file mode 100644
fcf72c
index 0000000..0554874
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/proc/device-tree/hypervisor/compatible
fcf72c
@@ -0,0 +1 @@
fcf72c
+vmware
fcf72c
diff --git a/tests/esx-arm/proc/device-tree/hypervisor/name b/tests/esx-arm/proc/device-tree/hypervisor/name
fcf72c
new file mode 100644
fcf72c
index 0000000..d508e44
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/proc/device-tree/hypervisor/name
fcf72c
@@ -0,0 +1 @@
fcf72c
+hypervisor
fcf72c
diff --git a/tests/esx-arm/proc/self/status b/tests/esx-arm/proc/self/status
fcf72c
new file mode 100644
fcf72c
index 0000000..13dd246
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/proc/self/status
fcf72c
@@ -0,0 +1,55 @@
fcf72c
+Name:	cat
fcf72c
+Umask:	0022
fcf72c
+State:	R (running)
fcf72c
+Tgid:	292937
fcf72c
+Ngid:	0
fcf72c
+Pid:	292937
fcf72c
+PPid:	10956
fcf72c
+TracerPid:	0
fcf72c
+Uid:	0	0	0	0
fcf72c
+Gid:	0	0	0	0
fcf72c
+FDSize:	256
fcf72c
+Groups:	0 
fcf72c
+NStgid:	292937
fcf72c
+NSpid:	292937
fcf72c
+NSpgid:	292937
fcf72c
+NSsid:	10956
fcf72c
+VmPeak:	    6400 kB
fcf72c
+VmSize:	    6400 kB
fcf72c
+VmLck:	       0 kB
fcf72c
+VmPin:	       0 kB
fcf72c
+VmHWM:	     960 kB
fcf72c
+VmRSS:	     960 kB
fcf72c
+RssAnon:	     448 kB
fcf72c
+RssFile:	     512 kB
fcf72c
+RssShmem:	       0 kB
fcf72c
+VmData:	     640 kB
fcf72c
+VmStk:	     192 kB
fcf72c
+VmExe:	      64 kB
fcf72c
+VmLib:	    1600 kB
fcf72c
+VmPTE:	     384 kB
fcf72c
+VmSwap:	       0 kB
fcf72c
+HugetlbPages:	       0 kB
fcf72c
+CoreDumping:	0
fcf72c
+THP_enabled:	1
fcf72c
+Threads:	1
fcf72c
+SigQ:	2/3947
fcf72c
+SigPnd:	0000000000000000
fcf72c
+ShdPnd:	0000000000000000
fcf72c
+SigBlk:	0000000000000000
fcf72c
+SigIgn:	0000000000000000
fcf72c
+SigCgt:	0000000000000000
fcf72c
+CapInh:	0000000000000000
fcf72c
+CapPrm:	0000003fffffffff
fcf72c
+CapEff:	0000003fffffffff
fcf72c
+CapBnd:	0000003fffffffff
fcf72c
+CapAmb:	0000000000000000
fcf72c
+NoNewPrivs:	0
fcf72c
+Seccomp:	0
fcf72c
+Speculation_Store_Bypass:	vulnerable
fcf72c
+Cpus_allowed:	3
fcf72c
+Cpus_allowed_list:	0-1
fcf72c
+Mems_allowed:	01
fcf72c
+Mems_allowed_list:	0
fcf72c
+voluntary_ctxt_switches:	1
fcf72c
+nonvoluntary_ctxt_switches:	0
fcf72c
diff --git a/tests/esx-arm/sbin/dmidecode b/tests/esx-arm/sbin/dmidecode
fcf72c
new file mode 100755
fcf72c
index 0000000..e53c12f
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/sbin/dmidecode
fcf72c
@@ -0,0 +1,2 @@
fcf72c
+#!/bin/sh -
fcf72c
+exit 1
fcf72c
diff --git a/tests/esx-arm/sbin/uname b/tests/esx-arm/sbin/uname
fcf72c
new file mode 100755
fcf72c
index 0000000..bd33a2d
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/sbin/uname
fcf72c
@@ -0,0 +1,2 @@
fcf72c
+#!/bin/sh -
fcf72c
+echo aarch64
fcf72c
diff --git a/tests/esx-arm/sbin/virt-what-cpuid-helper b/tests/esx-arm/sbin/virt-what-cpuid-helper
fcf72c
new file mode 100755
fcf72c
index 0000000..77a6692
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/sbin/virt-what-cpuid-helper
fcf72c
@@ -0,0 +1,2 @@
fcf72c
+#!/bin/sh -
fcf72c
+# nothing
fcf72c
diff --git a/tests/esx-arm/test.sh b/tests/esx-arm/test.sh
fcf72c
new file mode 100755
fcf72c
index 0000000..344afef
fcf72c
--- /dev/null
fcf72c
+++ b/tests/esx-arm/test.sh
fcf72c
@@ -0,0 +1,32 @@
fcf72c
+# Test for ESXi on ARM
fcf72c
+# Copyright (C) 2008-2011 Red Hat Inc.
fcf72c
+#
fcf72c
+# This program is free software; you can redistribute it and/or modify
fcf72c
+# it under the terms of the GNU General Public License as published by
fcf72c
+# the Free Software Foundation; either version 2 of the License, or
fcf72c
+# (at your option) any later version.
fcf72c
+#
fcf72c
+# This program is distributed in the hope that it will be useful,
fcf72c
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
fcf72c
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fcf72c
+# GNU General Public License for more details.
fcf72c
+#
fcf72c
+# You should have received a copy of the GNU General Public License
fcf72c
+# along with this program; if not, write to the Free Software
fcf72c
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
fcf72c
+
fcf72c
+output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)"
fcf72c
+expected="vmware"
fcf72c
+
fcf72c
+if [ "$output" != "$expected" ]; then
fcf72c
+    echo "$0: test failed because output did not match expected"
fcf72c
+    echo "Expected output was:"
fcf72c
+    echo "----------------------------------------"
fcf72c
+    echo "$expected"
fcf72c
+    echo "----------------------------------------"
fcf72c
+    echo "But the actual output of the program was:"
fcf72c
+    echo "----------------------------------------"
fcf72c
+    echo "$output"
fcf72c
+    echo "----------------------------------------"
fcf72c
+    exit 1
fcf72c
+fi
fcf72c
diff --git a/virt-what.in b/virt-what.in
fcf72c
index a61ce91..59743c3 100644
fcf72c
--- a/virt-what.in
fcf72c
+++ b/virt-what.in
fcf72c
@@ -264,6 +264,10 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "aarch64" ]; then
fcf72c
         echo xen
fcf72c
         skip_qemu_kvm=true
fcf72c
         skip_lkvm=true
fcf72c
+    elif [ -d "${root}/proc/device-tree/hypervisor" ] &&
fcf72c
+        grep -q "vmware" "${root}/proc/device-tree/hypervisor/compatible"; then
fcf72c
+        echo vmware
fcf72c
+        skip_lkvm=true
fcf72c
     fi
fcf72c
 elif [ "$arch" = "ia64" ]; then
fcf72c
     if [ -d "${root}/sys/bus/xen" -a ! -d "${root}/sys/bus/xen-backend" ]; then
fcf72c
-- 
fcf72c
2.32.0
fcf72c