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

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