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

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