From aadb08d7ab259669346aabf0c7ea44d5a24691bc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 9 Aug 2022 09:48:43 +0100 Subject: [PATCH] Detect KVM on GCE and AWS Arm instances resolves: rhbz#2114997 --- ...baba-cloud-Make-the-test-more-robust.patch | 41 ++ ...sts-Add-test-for-Google-Cloud-Engine.patch | 426 ++++++++++++++++++ ...-Print-kvm-fact-on-aarch64-instances.patch | 63 +++ ...tect-AWS-arm-virtual-instance-as-kvm.patch | 59 +++ copy-patches.sh | 61 +++ virt-what.spec | 18 +- 6 files changed, 667 insertions(+), 1 deletion(-) create mode 100644 0001-alibaba-cloud-Make-the-test-more-robust.patch create mode 100644 0002-tests-Add-test-for-Google-Cloud-Engine.patch create mode 100644 0003-google-cloud-Print-kvm-fact-on-aarch64-instances.patch create mode 100644 0004-detect-AWS-arm-virtual-instance-as-kvm.patch create mode 100755 copy-patches.sh diff --git a/0001-alibaba-cloud-Make-the-test-more-robust.patch b/0001-alibaba-cloud-Make-the-test-more-robust.patch new file mode 100644 index 0000000..5a58033 --- /dev/null +++ b/0001-alibaba-cloud-Make-the-test-more-robust.patch @@ -0,0 +1,41 @@ +From 5ab6b37b29a482006aa5d9724a22be49e78e00aa Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 3 Aug 2022 17:37:23 +0000 +Subject: [PATCH] alibaba-cloud: Make the test more robust + +This test worked by trying to make an HTTP connection to a path under +100.100.100.200, which if successful would indicate that it's an +Alibaba cloud instance. We only try the connection if SM-BIOS +information indicates the hardware OEM is Alibaba. + +However 'make check' would hang if 100.100.100.200 doesn't immediately +reject the connection. I found that GCE is such an environment where +connecting to this address would hang rather than reject. GCE does +not have Alibaba hardware of course, but when doing 'make check' we +fake dmidecode data. + +Make the test more robust by only trying to connect when we know we're +not in 'make check'. + +Fixes: commit b7cc3d93a613ef6d0ac5ccd6e32cc3d66e057243 +(cherry picked from commit 26b2c9c5156e85a4d7b566c22cb8f13c741e3530) +--- + virt-what.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/virt-what.in b/virt-what.in +index d56c84f65..66b2d798d 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -116,7 +116,7 @@ arch=$(uname -m | sed -e 's/i.86/i386/' | sed -e 's/arm.*/arm/') + # Check for Alibaba Cloud + if echo "$dmi" | grep -q 'Manufacturer: Alibaba'; then + # Check for Alibaba Cloud ECS Bare Metal (EBM) Instance +- if ( { echo -e "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ) 2>/dev/null ; then ++ if [ "x$root" = "x" ] && ( { echo -e "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ) 2>/dev/null ; then + echo "alibaba_cloud-ebm" + else + echo "alibaba_cloud" +-- +2.31.1 + diff --git a/0002-tests-Add-test-for-Google-Cloud-Engine.patch b/0002-tests-Add-test-for-Google-Cloud-Engine.patch new file mode 100644 index 0000000..ea1ae0f --- /dev/null +++ b/0002-tests-Add-test-for-Google-Cloud-Engine.patch @@ -0,0 +1,426 @@ +From 28f07222812711c6a0d37d3ebd51dd1ff4561d04 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 3 Aug 2022 17:53:19 +0000 +Subject: [PATCH] tests: Add test for Google Cloud Engine + +This was actually a GCE aarch64 instance, but I believe the +architecture makes no difference as all we're looking for is the +characteristic string in dmidecode output. + +Thanks: Craig Donnelly +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2114997 +Updates: commit 8363fa9f0e2cbd970f34ffb7c7b23ed0ac2c374a +(cherry picked from commit 54b726fa7c9687b692162488e8934a426f9fa6c3) +--- + configure.ac | 2 + + tests/google-cloud/Makefile.am | 28 +++ + tests/google-cloud/proc/cpuinfo | 9 + + tests/google-cloud/proc/self/status | 57 ++++++ + tests/google-cloud/sbin/dmidecode | 186 ++++++++++++++++++ + tests/google-cloud/sbin/uname | 2 + + .../google-cloud/sbin/virt-what-cpuid-helper | 2 + + tests/google-cloud/test.sh | 32 +++ + virt-what.pod | 2 +- + 9 files changed, 319 insertions(+), 1 deletion(-) + create mode 100644 tests/google-cloud/Makefile.am + create mode 100644 tests/google-cloud/proc/cpuinfo + create mode 100644 tests/google-cloud/proc/self/status + create mode 100755 tests/google-cloud/sbin/dmidecode + create mode 100755 tests/google-cloud/sbin/uname + create mode 100755 tests/google-cloud/sbin/virt-what-cpuid-helper + create mode 100755 tests/google-cloud/test.sh + +diff --git a/configure.ac b/configure.ac +index ad481fcb3..f0be215a5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -44,6 +44,7 @@ tests="\ + docker \ + esx-arm \ + esx4.1 \ ++ google-cloud \ + hyperv \ + kvm \ + kvm-explicit-cpu \ +@@ -90,6 +91,7 @@ AC_CONFIG_FILES([Makefile + tests/docker/Makefile + tests/esx-arm/Makefile + tests/esx4.1/Makefile ++ tests/google-cloud/Makefile + tests/hyperv/Makefile + tests/kvm/Makefile + tests/kvm-explicit-cpu/Makefile +diff --git a/tests/google-cloud/Makefile.am b/tests/google-cloud/Makefile.am +new file mode 100644 +index 000000000..eabaa0108 +--- /dev/null ++++ b/tests/google-cloud/Makefile.am +@@ -0,0 +1,28 @@ ++# Makefile for virt-what ++# Copyright (C) 2008-2022 Red Hat Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ ++CLEANFILES = *~ ++ ++TESTS = test.sh ++ ++EXTRA_DIST = \ ++ test.sh \ ++ proc/cpuinfo \ ++ proc/self/status \ ++ sbin/dmidecode \ ++ sbin/uname \ ++ sbin/virt-what-cpuid-helper +diff --git a/tests/google-cloud/proc/cpuinfo b/tests/google-cloud/proc/cpuinfo +new file mode 100644 +index 000000000..801a7b5a7 +--- /dev/null ++++ b/tests/google-cloud/proc/cpuinfo +@@ -0,0 +1,9 @@ ++processor : 0 ++BogoMIPS : 50.00 ++Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs ++CPU implementer : 0x41 ++CPU architecture: 8 ++CPU variant : 0x3 ++CPU part : 0xd0c ++CPU revision : 1 ++ +diff --git a/tests/google-cloud/proc/self/status b/tests/google-cloud/proc/self/status +new file mode 100644 +index 000000000..686ccb9d9 +--- /dev/null ++++ b/tests/google-cloud/proc/self/status +@@ -0,0 +1,57 @@ ++Name: cat ++Umask: 0022 ++State: R (running) ++Tgid: 22886 ++Ngid: 0 ++Pid: 22886 ++PPid: 9416 ++TracerPid: 0 ++Uid: 1002 1002 1002 1002 ++Gid: 1003 1003 1003 1003 ++FDSize: 256 ++Groups: 1003 ++NStgid: 22886 ++NSpid: 22886 ++NSpgid: 22886 ++NSsid: 9416 ++VmPeak: 5288 kB ++VmSize: 5288 kB ++VmLck: 0 kB ++VmPin: 0 kB ++VmHWM: 816 kB ++VmRSS: 816 kB ++RssAnon: 80 kB ++RssFile: 736 kB ++RssShmem: 0 kB ++VmData: 348 kB ++VmStk: 132 kB ++VmExe: 24 kB ++VmLib: 1728 kB ++VmPTE: 56 kB ++VmSwap: 0 kB ++HugetlbPages: 0 kB ++CoreDumping: 0 ++THP_enabled: 1 ++Threads: 1 ++SigQ: 0/13683 ++SigPnd: 0000000000000000 ++ShdPnd: 0000000000000000 ++SigBlk: 0000000000000000 ++SigIgn: 0000000000000000 ++SigCgt: 0000000000000000 ++CapInh: 0000000000000000 ++CapPrm: 0000000000000000 ++CapEff: 0000000000000000 ++CapBnd: 000001ffffffffff ++CapAmb: 0000000000000000 ++NoNewPrivs: 0 ++Seccomp: 0 ++Seccomp_filters: 0 ++Speculation_Store_Bypass: thread vulnerable ++SpeculationIndirectBranch: unknown ++Cpus_allowed: 1 ++Cpus_allowed_list: 0 ++Mems_allowed: 00000000,00000001 ++Mems_allowed_list: 0 ++voluntary_ctxt_switches: 0 ++nonvoluntary_ctxt_switches: 0 +diff --git a/tests/google-cloud/sbin/dmidecode b/tests/google-cloud/sbin/dmidecode +new file mode 100755 +index 000000000..3fd64327b +--- /dev/null ++++ b/tests/google-cloud/sbin/dmidecode +@@ -0,0 +1,186 @@ ++#!/bin/sh - ++cat <<'EOF' ++# dmidecode 3.3 ++Getting SMBIOS data from sysfs. ++SMBIOS 2.4 present. ++16 structures occupying 588 bytes. ++Table at 0xFFFE0000. ++ ++Handle 0x0000, DMI type 0, 24 bytes ++BIOS Information ++ Vendor: Google ++ Version: Google ++ Release Date: 06/20/2022 ++ Address: 0xE8000 ++ Runtime Size: 96 kB ++ ROM Size: 64 kB ++ Characteristics: ++ BIOS characteristics not supported ++ Targeted content distribution is supported ++ BIOS Revision: 1.0 ++ ++Handle 0x0097, DMI type 1, 27 bytes ++System Information ++ Manufacturer: Google ++ Product Name: Google Compute Engine ++ Version: Not Specified ++ Serial Number: GoogleCloud-957EDC416C53B28F6DA35168B6F8648D ++ UUID: 957edc41-6c53-b28f-6da3-5168b6f8648d ++ Wake-up Type: Power Switch ++ SKU Number: Not Specified ++ Family: Not Specified ++ ++Handle 0x0098, DMI type 2, 15 bytes ++Base Board Information ++ Manufacturer: KVM ++ Product Name: Google Compute Engine ++ Version: Not Specified ++ Serial Number: Board-GoogleCloud-957EDC416C53B28F6DA35168B6F8648D ++ Asset Tag: 957EDC41-6C53-B28F-6DA3-5168B6F8648D ++ Features: ++ Board is a hosting board ++ Location In Chassis: Not Specified ++ Chassis Handle: 0x0099 ++ Type: Motherboard ++ Contained Object Handles: 0 ++ ++Handle 0x0099, DMI type 3, 20 bytes ++Chassis Information ++ Manufacturer: Google ++ Type: Other ++ Lock: Not Present ++ Version: Not Specified ++ Serial Number: Not Specified ++ Asset Tag: Not Specified ++ Boot-up State: Safe ++ Power Supply State: Safe ++ Thermal State: Safe ++ Security Status: Unknown ++ OEM Information: 0x00000000 ++ Height: Unspecified ++ Number Of Power Cords: Unspecified ++ ++Handle 0x3001, DMI type 7, 17 bytes ++Cache Information ++ Socket Designation: L1 Cache ++ Configuration: Disabled, Not Socketed, Level 1 ++ Operational Mode: Write Through ++ Location: Internal ++ Installed Size: 0 kB ++ Maximum Size: 1 kB ++ Supported SRAM Types: None ++ Installed SRAM Type: None ++ ++Handle 0x3002, DMI type 7, 17 bytes ++Cache Information ++ Socket Designation: L2 Cache ++ Configuration: Disabled, Not Socketed, Level 1 ++ Operational Mode: Write Back ++ Location: Internal ++ Installed Size: 0 kB ++ Maximum Size: 0 kB ++ Supported SRAM Types: None ++ Installed SRAM Type: None ++ ++Handle 0x3003, DMI type 7, 17 bytes ++Cache Information ++ Socket Designation: L3 Cache ++ Configuration: Disabled, Not Socketed, Level 1 ++ Operational Mode: Varies With Memory Address ++ Location: Internal ++ Installed Size: 256 kB ++ Maximum Size: 256 kB ++ Supported SRAM Types: None ++ Installed SRAM Type: None ++ ++Handle 0x1000, DMI type 4, 42 bytes ++Processor Information ++ Socket Designation: CPU 1 ++ Type: Central Processor ++ Family: ARMv8 ++ Manufacturer: Google ++ ID: 00 00 00 00 00 00 00 00 ++ Version: Not Specified ++ Voltage: Unknown ++ External Clock: Unknown ++ Max Speed: 3000 MHz ++ Current Speed: 3000 MHz ++ Status: Populated, Enabled ++ Upgrade: Other ++ L1 Cache Handle: 0x3001 ++ L2 Cache Handle: 0x3002 ++ L3 Cache Handle: 0x3003 ++ Serial Number: Not Specified ++ Asset Tag: Not Specified ++ Part Number: Not Specified ++ Core Count: 1 ++ Core Enabled: 1 ++ Thread Count: 1 ++ Characteristics: ++ 64-bit capable ++ ++Handle 0x0200, DMI type 16, 15 bytes ++Physical Memory Array ++ Location: Other ++ Use: System Memory ++ Error Correction Type: Multi-bit ECC ++ Maximum Capacity: 4 GB ++ Error Information Handle: Not Provided ++ Number Of Devices: 1 ++ ++Handle 0x7000, DMI type 17, 21 bytes ++Memory Device ++ Array Handle: 0x0200 ++ Error Information Handle: Not Provided ++ Total Width: 64 bits ++ Data Width: 64 bits ++ Size: 4 GB ++ Form Factor: DIMM ++ Set: None ++ Locator: DIMM 0 ++ Bank Locator: Not Specified ++ Type: RAM ++ Type Detail: Synchronous ++ ++Handle 0x0300, DMI type 19, 15 bytes ++Memory Array Mapped Address ++ Starting Address: 0x00000000000 ++ Ending Address: 0x000BFFFFFFF ++ Range Size: 3 GB ++ Physical Array Handle: 0x0200 ++ Partition Width: 1 ++ ++Handle 0x0301, DMI type 19, 15 bytes ++Memory Array Mapped Address ++ Starting Address: 0x00100000000 ++ Ending Address: 0x0013FFFFFFF ++ Range Size: 1 GB ++ Physical Array Handle: 0x0200 ++ Partition Width: 1 ++ ++Handle 0x4000, DMI type 20, 19 bytes ++Memory Device Mapped Address ++ Starting Address: 0x00000000000 ++ Ending Address: 0x000BFFFFFFF ++ Range Size: 3 GB ++ Physical Device Handle: 0x7000 ++ Memory Array Mapped Address Handle: 0x0300 ++ Partition Row Position: 1 ++ ++Handle 0x4001, DMI type 20, 19 bytes ++Memory Device Mapped Address ++ Starting Address: 0x00100000000 ++ Ending Address: 0x0013FFFFFFF ++ Range Size: 1 GB ++ Physical Device Handle: 0x7000 ++ Memory Array Mapped Address Handle: 0x0301 ++ Partition Row Position: 1 ++ ++Handle 0x0100, DMI type 32, 11 bytes ++System Boot Information ++ Status: No errors detected ++ ++Handle 0xFEFF, DMI type 127, 4 bytes ++End Of Table ++ ++EOF +diff --git a/tests/google-cloud/sbin/uname b/tests/google-cloud/sbin/uname +new file mode 100755 +index 000000000..bd33a2d73 +--- /dev/null ++++ b/tests/google-cloud/sbin/uname +@@ -0,0 +1,2 @@ ++#!/bin/sh - ++echo aarch64 +diff --git a/tests/google-cloud/sbin/virt-what-cpuid-helper b/tests/google-cloud/sbin/virt-what-cpuid-helper +new file mode 100755 +index 000000000..b4460095b +--- /dev/null ++++ b/tests/google-cloud/sbin/virt-what-cpuid-helper +@@ -0,0 +1,2 @@ ++#!/bin/sh - ++echo +diff --git a/tests/google-cloud/test.sh b/tests/google-cloud/test.sh +new file mode 100755 +index 000000000..39287a2e9 +--- /dev/null ++++ b/tests/google-cloud/test.sh +@@ -0,0 +1,32 @@ ++# Test for GCE ++# Copyright (C) 2008-2022 Red Hat Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ ++output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)" ++expected="google_cloud" ++ ++if [ "$output" != "$expected" ]; then ++ echo "$0: test failed because output did not match expected" ++ echo "Expected output was:" ++ echo "----------------------------------------" ++ echo "$expected" ++ echo "----------------------------------------" ++ echo "But the actual output of the program was:" ++ echo "----------------------------------------" ++ echo "$output" ++ echo "----------------------------------------" ++ exit 1 ++fi +diff --git a/virt-what.pod b/virt-what.pod +index 2bce5c811..56cee6c1b 100644 +--- a/virt-what.pod ++++ b/virt-what.pod +@@ -59,7 +59,7 @@ Status: confirmed by Charles Nguyen + + This is running on Google Cloud Platform / Google Compute Engine. + +-Status: not confirmed ++Status: confirmed by RWMJ + + =item B + +-- +2.31.1 + diff --git a/0003-google-cloud-Print-kvm-fact-on-aarch64-instances.patch b/0003-google-cloud-Print-kvm-fact-on-aarch64-instances.patch new file mode 100644 index 0000000..af7fcdb --- /dev/null +++ b/0003-google-cloud-Print-kvm-fact-on-aarch64-instances.patch @@ -0,0 +1,63 @@ +From 78aab247ccce47d62269ce24264688647c90a264 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 8 Aug 2022 12:13:11 -0400 +Subject: [PATCH] google-cloud: Print "kvm" fact on aarch64 instances + +GCE instances are KVM with a non-QEMU userspace. On x86-64 we should +recognize this from the CPUID information, but aarch64 has no +equivalent to this. /proc/device-tree/hypervisor/compatible contains +something but RHEL does not use device tree. However the SMBIOS +tables exported by GCE do contain: + + Manufacturer: KVM + +so we can use that. + + # uname -m + aarch64 + # virt-what + google_cloud + kvm + +This commit also updates the test. + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2114997 +Updates: commit 54b726fa7c9687b692162488e8934a426f9fa6c3 +Thanks: Eric Auger, Yongkui Guo +(cherry picked from commit da3568b25a582603ba15690793c8867cc7c5d2a8) +--- + tests/google-cloud/test.sh | 3 ++- + virt-what.in | 3 +++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/tests/google-cloud/test.sh b/tests/google-cloud/test.sh +index 39287a2e9..8cc69c564 100755 +--- a/tests/google-cloud/test.sh ++++ b/tests/google-cloud/test.sh +@@ -16,7 +16,8 @@ + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)" +-expected="google_cloud" ++expected="google_cloud ++kvm" + + if [ "$output" != "$expected" ]; then + echo "$0: test failed because output did not match expected" +diff --git a/virt-what.in b/virt-what.in +index 66b2d798d..a9ac0c396 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -319,6 +319,9 @@ if ! "$skip_qemu_kvm"; then + elif echo "$dmi" | grep -q 'Product Name: KVM'; then + echo kvm + skip_lkvm=true ++ elif echo "$dmi" | grep -q 'Manufacturer: KVM'; then ++ echo kvm ++ skip_lkvm=true + elif echo "$dmi" | grep -q 'Manufacturer: QEMU'; then + # The test for KVM above failed, so now we know we're + # not using KVM acceleration. +-- +2.31.1 + diff --git a/0004-detect-AWS-arm-virtual-instance-as-kvm.patch b/0004-detect-AWS-arm-virtual-instance-as-kvm.patch new file mode 100644 index 0000000..7ad732c --- /dev/null +++ b/0004-detect-AWS-arm-virtual-instance-as-kvm.patch @@ -0,0 +1,59 @@ +From d229e78df59c4eefb25bdd3d893fe3a3e389ee12 Mon Sep 17 00:00:00 2001 +From: Xiao Liang +Date: Tue, 24 May 2022 17:34:52 +0800 +Subject: [PATCH] detect AWS arm virtual instance as kvm + +AWS arm virtual instance is KVM based hypervisor. +With this patch: +$ sudo virt-what +kvm +aws +$ cat /sys/devices/virtual/dmi/id/product_name +t4g.small + +Without it: +$ sudo virt-what +aws + +Signed-off-by: Xiao Liang +(cherry picked from commit 39001e7c458d798225814c04e920583fa7e2a41c) +--- + tests/aws-kvm-arm/test.sh | 5 ++--- + virt-what.in | 5 +++++ + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/tests/aws-kvm-arm/test.sh b/tests/aws-kvm-arm/test.sh +index 5d31995f9..133ef1362 100755 +--- a/tests/aws-kvm-arm/test.sh ++++ b/tests/aws-kvm-arm/test.sh +@@ -16,9 +16,8 @@ + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + output="$(PATH=../..:$PATH virt-what --test-root=. 2>&1)" +-# XXX At the moment KVM cannot be detected on this platform. +-# We hope to fix that, but for now the only fact printed is "aws". +-expected="aws" ++expected="kvm ++aws" + + if [ "$output" != "$expected" ]; then + echo "$0: test failed because output did not match expected" +diff --git a/virt-what.in b/virt-what.in +index a9ac0c396..a3cc8940c 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -322,6 +322,11 @@ if ! "$skip_qemu_kvm"; then + elif echo "$dmi" | grep -q 'Manufacturer: KVM'; then + echo kvm + skip_lkvm=true ++ elif echo "$dmi" | grep -q 'Manufacturer: Amazon EC2' && ++ echo "$dmi" | grep -q 'System is a virtual machine'; then ++ # This is for AWS Graviton (Arm) systems which don't have CPUID. ++ echo kvm ++ skip_lkvm=true + elif echo "$dmi" | grep -q 'Manufacturer: QEMU'; then + # The test for KVM above failed, so now we know we're + # not using KVM acceleration. +-- +2.31.1 + diff --git a/copy-patches.sh b/copy-patches.sh new file mode 100755 index 0000000..af8f647 --- /dev/null +++ b/copy-patches.sh @@ -0,0 +1,61 @@ +#!/bin/bash - + +set -e + +# Maintainer script to copy patches from the git repo to the current +# directory. It's normally only used downstream (ie. in RHEL). Use +# it like this: +# ./copy-patches.sh + +project=virt-what +rhel_version=9.1 + +# Check we're in the right directory. +if [ ! -f $project.spec ]; then + echo "$0: run this from the directory containing '$project.spec'" + exit 1 +fi + +case `id -un` in + rjones) git_checkout=$HOME/d/$project-rhel-$rhel_version ;; + lacos) git_checkout=$HOME/src/v2v/$project ;; + *) git_checkout=$HOME/d/$project-rhel-$rhel_version ;; +esac +if [ ! -d $git_checkout ]; then + echo "$0: $git_checkout does not exist" + echo "This script is only for use by the maintainer when preparing a" + echo "$project release on RHEL." + exit 1 +fi + +# Get the base version of the project. +version=`grep '^Version:' $project.spec | awk '{print $2}'` +tag="v$version" + +# Remove any existing patches. +git rm -f [0-9]*.patch ||: +rm -f [0-9]*.patch + +# Get the patches. +(cd $git_checkout; rm -f [0-9]*.patch; git -c core.abbrev=9 format-patch -O/dev/null -N --submodule=diff $tag) +mv $git_checkout/[0-9]*.patch . + +# Remove any not to be applied. +rm -f *NOT-FOR-RPM*.patch + +# Add the patches. +git add [0-9]*.patch + +# Print out the patch lines. +echo +echo "--- Copy the following text into $project.spec file" +echo + +echo "# Patches." +for f in [0-9]*.patch; do + n=`echo $f | awk -F- '{print $1}'` + echo "Patch$n: $f" +done + +echo +echo "--- End of text" diff --git a/virt-what.spec b/virt-what.spec index 925b04d..c758b0e 100644 --- a/virt-what.spec +++ b/virt-what.spec @@ -1,12 +1,24 @@ Name: virt-what Version: 1.22 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Detect if we are running in a virtual machine License: GPLv2+ URL: http://people.redhat.com/~rjones/virt-what/ Source0: http://people.redhat.com/~rjones/virt-what/files/%{name}-%{version}.tar.gz +# Maintainer script which helps with handling patches. +Source1: copy-patches.sh + +# Patches are maintained in the following repository: +# http://git.annexia.org/?p=virt-what.git;a=shortlog;h=refs/heads/rhel-9.1 + +# Patches. +Patch0001: 0001-alibaba-cloud-Make-the-test-more-robust.patch +Patch0002: 0002-tests-Add-test-for-Google-Cloud-Engine.patch +Patch0003: 0003-google-cloud-Print-kvm-fact-on-aarch64-instances.patch +Patch0004: 0004-detect-AWS-arm-virtual-instance-as-kvm.patch + BuildRequires: make BuildRequires: git BuildRequires: autoconf, automake, libtool @@ -110,6 +122,10 @@ fi %changelog +* Tue Aug 09 2022 Richard W.M. Jones - 1.22-2 +- Detect KVM on GCE and AWS Arm instances + resolves: rhbz#2114997 + * Thu Apr 14 2022 Richard W.M. Jones - 1.22-1 - New upstream version 1.22. resolves: rhbz#2074476