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

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