virt-what/0004-detect-AWS-arm-virtual-instance-as-kvm.patch

60 lines
1.8 KiB
Diff
Raw Normal View History

From d229e78df59c4eefb25bdd3d893fe3a3e389ee12 Mon Sep 17 00:00:00 2001
From: Xiao Liang <xiliang@redhat.com>
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 <xiliang@redhat.com>
(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