Blame SOURCES/0005-Add-support-for-Alibaba-cloud-on-aarch64.patch

c0cff7
From 034981d94bf4ccac4159f013f2d4e2476a23d7e7 Mon Sep 17 00:00:00 2001
c0cff7
From: Yongkui Guo <yoguo@redhat.com>
c0cff7
Date: Mon, 30 Jan 2023 18:20:32 +0800
c0cff7
Subject: [PATCH] Add support for Alibaba cloud on aarch64
c0cff7
c0cff7
This assumes you are running RHEL or another tenant which supports
c0cff7
ACPI.  It probably won't work for guests using device tree.
c0cff7
c0cff7
Also we assume that the hypervisor is KVM.  Since the hypervisor
c0cff7
indicates that it is RHEL 7, this is very likely to be true, but hard
c0cff7
to prove since there is no CPUID on Arm.
c0cff7
c0cff7
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2165285
c0cff7
(cherry picked from commit 805604762468b754ea60e5dc176fa26f68d211b8)
c0cff7
---
c0cff7
 configure.ac                                  |   2 +
c0cff7
 tests/alibaba-cloud-arm/Makefile.am           |  28 +++++
c0cff7
 tests/alibaba-cloud-arm/proc/cpuinfo          |  18 +++
c0cff7
 tests/alibaba-cloud-arm/proc/self/status      |  57 +++++++++
c0cff7
 tests/alibaba-cloud-arm/sbin/dmidecode        | 116 ++++++++++++++++++
c0cff7
 tests/alibaba-cloud-arm/sbin/uname            |   2 +
c0cff7
 .../sbin/virt-what-cpuid-helper               |   3 +
c0cff7
 tests/alibaba-cloud-arm/test.sh               |  33 +++++
c0cff7
 virt-what.in                                  |   5 +
c0cff7
 9 files changed, 264 insertions(+)
c0cff7
 create mode 100644 tests/alibaba-cloud-arm/Makefile.am
c0cff7
 create mode 100644 tests/alibaba-cloud-arm/proc/cpuinfo
c0cff7
 create mode 100644 tests/alibaba-cloud-arm/proc/self/status
c0cff7
 create mode 100755 tests/alibaba-cloud-arm/sbin/dmidecode
c0cff7
 create mode 100755 tests/alibaba-cloud-arm/sbin/uname
c0cff7
 create mode 100755 tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c0cff7
 create mode 100755 tests/alibaba-cloud-arm/test.sh
c0cff7
c0cff7
diff --git a/configure.ac b/configure.ac
c0cff7
index a80a4b6f0..cfb7ca371 100644
c0cff7
--- a/configure.ac
c0cff7
+++ b/configure.ac
c0cff7
@@ -34,6 +34,7 @@ AM_CONDITIONAL([HOST_CPU_IA64], [ test "x$host_cpu" = "xia64" ])
c0cff7
 
c0cff7
 dnl List of tests.
c0cff7
 tests="\
c0cff7
+	alibaba-cloud-arm \
c0cff7
 	alibaba-cloud-x86 \
c0cff7
 	aws-baremetal-x86 \
c0cff7
 	aws-kvm-arm \
c0cff7
@@ -83,6 +84,7 @@ AC_CONFIG_HEADERS([config.h])
c0cff7
 AC_CONFIG_FILES([virt-what],[chmod +x virt-what])
c0cff7
 AC_CONFIG_FILES([Makefile
c0cff7
                  tests/Makefile
c0cff7
+                 tests/alibaba-cloud-arm/Makefile
c0cff7
                  tests/alibaba-cloud-x86/Makefile
c0cff7
 	         tests/aws-baremetal-x86/Makefile
c0cff7
 	         tests/aws-kvm-arm/Makefile
c0cff7
diff --git a/tests/alibaba-cloud-arm/Makefile.am b/tests/alibaba-cloud-arm/Makefile.am
c0cff7
new file mode 100644
c0cff7
index 000000000..09ce07861
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/Makefile.am
c0cff7
@@ -0,0 +1,28 @@
c0cff7
+# Makefile for virt-what
c0cff7
+# Copyright (C) 2008-2023 Red Hat Inc.
c0cff7
+#
c0cff7
+# This program is free software; you can redistribute it and/or modify
c0cff7
+# it under the terms of the GNU General Public License as published by
c0cff7
+# the Free Software Foundation; either version 2 of the License, or
c0cff7
+# (at your option) any later version.
c0cff7
+#
c0cff7
+# This program is distributed in the hope that it will be useful,
c0cff7
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c0cff7
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c0cff7
+# GNU General Public License for more details.
c0cff7
+#
c0cff7
+# You should have received a copy of the GNU General Public License
c0cff7
+# along with this program; if not, write to the Free Software
c0cff7
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c0cff7
+
c0cff7
+CLEANFILES = *~
c0cff7
+
c0cff7
+TESTS = test.sh
c0cff7
+
c0cff7
+EXTRA_DIST = \
c0cff7
+	test.sh \
c0cff7
+	proc/cpuinfo \
c0cff7
+	proc/self/status \
c0cff7
+	sbin/dmidecode \
c0cff7
+	sbin/uname \
c0cff7
+	sbin/virt-what-cpuid-helper
c0cff7
diff --git a/tests/alibaba-cloud-arm/proc/cpuinfo b/tests/alibaba-cloud-arm/proc/cpuinfo
c0cff7
new file mode 100644
c0cff7
index 000000000..03dbb22ab
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/proc/cpuinfo
c0cff7
@@ -0,0 +1,18 @@
c0cff7
+processor	: 0
c0cff7
+BogoMIPS	: 50.00
c0cff7
+Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
c0cff7
+CPU implementer	: 0x41
c0cff7
+CPU architecture: 8
c0cff7
+CPU variant	: 0x3
c0cff7
+CPU part	: 0xd0c
c0cff7
+CPU revision	: 1
c0cff7
+
c0cff7
+processor	: 1
c0cff7
+BogoMIPS	: 50.00
c0cff7
+Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
c0cff7
+CPU implementer	: 0x41
c0cff7
+CPU architecture: 8
c0cff7
+CPU variant	: 0x3
c0cff7
+CPU part	: 0xd0c
c0cff7
+CPU revision	: 1
c0cff7
+
c0cff7
diff --git a/tests/alibaba-cloud-arm/proc/self/status b/tests/alibaba-cloud-arm/proc/self/status
c0cff7
new file mode 100644
c0cff7
index 000000000..08c63e9cb
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/proc/self/status
c0cff7
@@ -0,0 +1,57 @@
c0cff7
+Name:	cat
c0cff7
+Umask:	0022
c0cff7
+State:	R (running)
c0cff7
+Tgid:	6341
c0cff7
+Ngid:	0
c0cff7
+Pid:	6341
c0cff7
+PPid:	1588
c0cff7
+TracerPid:	0
c0cff7
+Uid:	0	0	0	0
c0cff7
+Gid:	0	0	0	0
c0cff7
+FDSize:	256
c0cff7
+Groups:	0 
c0cff7
+NStgid:	6341
c0cff7
+NSpid:	6341
c0cff7
+NSpgid:	6341
c0cff7
+NSsid:	1588
c0cff7
+VmPeak:	    2352 kB
c0cff7
+VmSize:	    2352 kB
c0cff7
+VmLck:	       0 kB
c0cff7
+VmPin:	       0 kB
c0cff7
+VmHWM:	     768 kB
c0cff7
+VmRSS:	     768 kB
c0cff7
+RssAnon:	      80 kB
c0cff7
+RssFile:	     688 kB
c0cff7
+RssShmem:	       0 kB
c0cff7
+VmData:	     348 kB
c0cff7
+VmStk:	     132 kB
c0cff7
+VmExe:	      24 kB
c0cff7
+VmLib:	    1728 kB
c0cff7
+VmPTE:	      44 kB
c0cff7
+VmSwap:	       0 kB
c0cff7
+HugetlbPages:	       0 kB
c0cff7
+CoreDumping:	0
c0cff7
+THP_enabled:	1
c0cff7
+Threads:	1
c0cff7
+SigQ:	0/29002
c0cff7
+SigPnd:	0000000000000000
c0cff7
+ShdPnd:	0000000000000000
c0cff7
+SigBlk:	0000000000000000
c0cff7
+SigIgn:	0000000000000000
c0cff7
+SigCgt:	0000000000000000
c0cff7
+CapInh:	0000000000000000
c0cff7
+CapPrm:	000001ffffffffff
c0cff7
+CapEff:	000001ffffffffff
c0cff7
+CapBnd:	000001ffffffffff
c0cff7
+CapAmb:	0000000000000000
c0cff7
+NoNewPrivs:	0
c0cff7
+Seccomp:	0
c0cff7
+Seccomp_filters:	0
c0cff7
+Speculation_Store_Bypass:	thread vulnerable
c0cff7
+SpeculationIndirectBranch:	unknown
c0cff7
+Cpus_allowed:	3
c0cff7
+Cpus_allowed_list:	0-1
c0cff7
+Mems_allowed:	00000000,00000001
c0cff7
+Mems_allowed_list:	0
c0cff7
+voluntary_ctxt_switches:	0
c0cff7
+nonvoluntary_ctxt_switches:	0
c0cff7
diff --git a/tests/alibaba-cloud-arm/sbin/dmidecode b/tests/alibaba-cloud-arm/sbin/dmidecode
c0cff7
new file mode 100755
c0cff7
index 000000000..89fa9a34b
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/sbin/dmidecode
c0cff7
@@ -0,0 +1,116 @@
c0cff7
+#!/bin/sh -
c0cff7
+cat <<'EOF'
c0cff7
+# dmidecode 3.3
c0cff7
+Getting SMBIOS data from sysfs.
c0cff7
+SMBIOS 3.0.0 present.
c0cff7
+Table at 0x2348C0000.
c0cff7
+
c0cff7
+Handle 0x0100, DMI type 1, 27 bytes
c0cff7
+System Information
c0cff7
+	Manufacturer: Alibaba Cloud
c0cff7
+	Product Name: Alibaba Cloud ECS
c0cff7
+	Version: virt-rhel7.6.0
c0cff7
+	Serial Number: 8c43355a-242e-42c2-bdf7-9fae99316221
c0cff7
+	UUID: 8c43355a-242e-42c2-bdf7-9fae99316221
c0cff7
+	Wake-up Type: Power Switch
c0cff7
+	SKU Number: Not Specified
c0cff7
+	Family: Red Hat Enterprise Linux
c0cff7
+
c0cff7
+Handle 0x0300, DMI type 3, 21 bytes
c0cff7
+Chassis Information
c0cff7
+	Manufacturer: Alibaba Cloud
c0cff7
+	Type: Other
c0cff7
+	Lock: Not Present
c0cff7
+	Version: virt-rhel7.6.0
c0cff7
+	Serial Number: Not Specified
c0cff7
+	Asset Tag: Not Specified
c0cff7
+	Boot-up State: Safe
c0cff7
+	Power Supply State: Safe
c0cff7
+	Thermal State: Safe
c0cff7
+	Security Status: Unknown
c0cff7
+	OEM Information: 0x00000000
c0cff7
+	Height: Unspecified
c0cff7
+	Number Of Power Cords: Unspecified
c0cff7
+	Contained Elements: 0
c0cff7
+
c0cff7
+Handle 0x0400, DMI type 4, 42 bytes
c0cff7
+Processor Information
c0cff7
+	Socket Designation: CPU 0
c0cff7
+	Type: Central Processor
c0cff7
+	Family: Other
c0cff7
+	Manufacturer: Alibaba Cloud
c0cff7
+	ID: 00 00 00 00 00 00 00 00
c0cff7
+	Version: virt-rhel7.6.0
c0cff7
+	Voltage: Unknown
c0cff7
+	External Clock: Unknown
c0cff7
+	Max Speed: 2000 MHz
c0cff7
+	Current Speed: 2000 MHz
c0cff7
+	Status: Populated, Enabled
c0cff7
+	Upgrade: Other
c0cff7
+	L1 Cache Handle: Not Provided
c0cff7
+	L2 Cache Handle: Not Provided
c0cff7
+	L3 Cache Handle: Not Provided
c0cff7
+	Serial Number: Not Specified
c0cff7
+	Asset Tag: Not Specified
c0cff7
+	Part Number: Not Specified
c0cff7
+	Core Count: 2
c0cff7
+	Core Enabled: 2
c0cff7
+	Thread Count: 1
c0cff7
+	Characteristics: None
c0cff7
+
c0cff7
+Handle 0x1000, DMI type 16, 23 bytes
c0cff7
+Physical Memory Array
c0cff7
+	Location: Other
c0cff7
+	Use: System Memory
c0cff7
+	Error Correction Type: Multi-bit ECC
c0cff7
+	Maximum Capacity: 8 GB
c0cff7
+	Error Information Handle: Not Provided
c0cff7
+	Number Of Devices: 1
c0cff7
+
c0cff7
+Handle 0x1100, DMI type 17, 40 bytes
c0cff7
+Memory Device
c0cff7
+	Array Handle: 0x1000
c0cff7
+	Error Information Handle: Not Provided
c0cff7
+	Total Width: Unknown
c0cff7
+	Data Width: Unknown
c0cff7
+	Size: 8 GB
c0cff7
+	Form Factor: DIMM
c0cff7
+	Set: None
c0cff7
+	Locator: DIMM 0
c0cff7
+	Bank Locator: Not Specified
c0cff7
+	Type: RAM
c0cff7
+	Type Detail: Other
c0cff7
+	Speed: Unknown
c0cff7
+	Manufacturer: Alibaba Cloud
c0cff7
+	Serial Number: Not Specified
c0cff7
+	Asset Tag: Not Specified
c0cff7
+	Part Number: Not Specified
c0cff7
+	Rank: Unknown
c0cff7
+	Configured Memory Speed: Unknown
c0cff7
+	Minimum Voltage: Unknown
c0cff7
+	Maximum Voltage: Unknown
c0cff7
+	Configured Voltage: Unknown
c0cff7
+
c0cff7
+Handle 0x2000, DMI type 32, 11 bytes
c0cff7
+System Boot Information
c0cff7
+	Status: No errors detected
c0cff7
+
c0cff7
+Handle 0x0000, DMI type 0, 26 bytes
c0cff7
+BIOS Information
c0cff7
+	Vendor: EFI Development Kit II / OVMF
c0cff7
+	Version: 0.0.0
c0cff7
+	Release Date: 02/06/2015
c0cff7
+	Address: 0xE8000
c0cff7
+	Runtime Size: 96 kB
c0cff7
+	ROM Size: 64 kB
c0cff7
+	Characteristics:
c0cff7
+		BIOS characteristics not supported
c0cff7
+		Targeted content distribution is supported
c0cff7
+		UEFI is supported
c0cff7
+		System is a virtual machine
c0cff7
+	BIOS Revision: 0.0
c0cff7
+
c0cff7
+Handle 0xFEFF, DMI type 127, 4 bytes
c0cff7
+End Of Table
c0cff7
+
c0cff7
+EOF
c0cff7
diff --git a/tests/alibaba-cloud-arm/sbin/uname b/tests/alibaba-cloud-arm/sbin/uname
c0cff7
new file mode 100755
c0cff7
index 000000000..bd33a2d73
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/sbin/uname
c0cff7
@@ -0,0 +1,2 @@
c0cff7
+#!/bin/sh -
c0cff7
+echo aarch64
c0cff7
diff --git a/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper b/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c0cff7
new file mode 100755
c0cff7
index 000000000..08e293436
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/sbin/virt-what-cpuid-helper
c0cff7
@@ -0,0 +1,3 @@
c0cff7
+#!/bin/sh -
c0cff7
+# Arm, so no cpuid.
c0cff7
+# No output, exits with 0.
c0cff7
diff --git a/tests/alibaba-cloud-arm/test.sh b/tests/alibaba-cloud-arm/test.sh
c0cff7
new file mode 100755
c0cff7
index 000000000..1e7360931
c0cff7
--- /dev/null
c0cff7
+++ b/tests/alibaba-cloud-arm/test.sh
c0cff7
@@ -0,0 +1,33 @@
c0cff7
+# Test for Alibaba Cloud
c0cff7
+# Copyright (C) 2018-2023 Red Hat Inc.
c0cff7
+#
c0cff7
+# This program is free software; you can redistribute it and/or modify
c0cff7
+# it under the terms of the GNU General Public License as published by
c0cff7
+# the Free Software Foundation; either version 2 of the License, or
c0cff7
+# (at your option) any later version.
c0cff7
+#
c0cff7
+# This program is distributed in the hope that it will be useful,
c0cff7
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
c0cff7
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c0cff7
+# GNU General Public License for more details.
c0cff7
+#
c0cff7
+# You should have received a copy of the GNU General Public License
c0cff7
+# along with this program; if not, write to the Free Software
c0cff7
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
c0cff7
+
c0cff7
+output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)"
c0cff7
+expected="alibaba_cloud
c0cff7
+kvm"
c0cff7
+
c0cff7
+if [ "$output" != "$expected" ]; then
c0cff7
+    echo "$0: test failed because output did not match expected"
c0cff7
+    echo "Expected output was:"
c0cff7
+    echo "----------------------------------------"
c0cff7
+    echo "$expected"
c0cff7
+    echo "----------------------------------------"
c0cff7
+    echo "But the actual output of the program was:"
c0cff7
+    echo "----------------------------------------"
c0cff7
+    echo "$output"
c0cff7
+    echo "----------------------------------------"
c0cff7
+    exit 1
c0cff7
+fi
c0cff7
diff --git a/virt-what.in b/virt-what.in
c0cff7
index 102e23f67..fbf8c54c5 100644
c0cff7
--- a/virt-what.in
c0cff7
+++ b/virt-what.in
c0cff7
@@ -354,6 +354,11 @@ if ! "$skip_qemu_kvm"; then
c0cff7
         # This is for AWS Graviton (Arm) systems which don't have CPUID.
c0cff7
         echo kvm
c0cff7
         skip_lkvm=true
c0cff7
+    elif echo "$dmi" | grep -q 'Manufacturer: Alibaba Cloud' &&
c0cff7
+        echo "$dmi" | grep -q 'System is a virtual machine'; then
c0cff7
+        # This is for Alibaba Arm systems which don't have CPUID.
c0cff7
+        echo kvm
c0cff7
+        skip_lkvm=true
c0cff7
     elif echo "$dmi" | grep -q 'Manufacturer: QEMU'; then
c0cff7
         # The test for KVM above failed, so now we know we're
c0cff7
         # not using KVM acceleration.
c0cff7
-- 
c0cff7
2.31.1
c0cff7