Blame SOURCES/0019-Add-QEMU-KVM-detection-for-ACPI-boot-ARM.patch

f83e65
From c722083f37e514f4d8b9f9470536dcbae428631a Mon Sep 17 00:00:00 2001
f83e65
From: Andrew Jones <drjones@redhat.com>
f83e65
Date: Tue, 22 Sep 2015 15:54:55 +0200
f83e65
Subject: [PATCH 19/26] Add QEMU/KVM detection for ACPI-boot ARM
f83e65
f83e65
Detect QEMU/KVM on ARM guests that have been boot with ACPI, i.e.
f83e65
without device tree. When boot with ACPI SMBIOS is populated, so we
f83e65
can use dmidecode.
f83e65
f83e65
Signed-off-by: Andrew Jones <drjones@redhat.com>
f83e65
---
f83e65
 Makefile.am                                     |   6 +
f83e65
 tests/qemu-arm-acpi/proc/cpuinfo                |  63 +++++++++++
f83e65
 tests/qemu-arm-acpi/proc/self/status            |  41 +++++++
f83e65
 tests/qemu-arm-acpi/sbin/dmidecode              | 141 ++++++++++++++++++++++++
f83e65
 tests/qemu-arm-acpi/sbin/uname                  |   2 +
f83e65
 tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper |   2 +
f83e65
 tests/test-qemu-arm-acpi.sh                     |  34 ++++++
f83e65
 virt-what.in                                    |   5 +
f83e65
 8 files changed, 294 insertions(+)
f83e65
 create mode 100644 tests/qemu-arm-acpi/proc/cpuinfo
f83e65
 create mode 100644 tests/qemu-arm-acpi/proc/self/status
f83e65
 create mode 100755 tests/qemu-arm-acpi/sbin/dmidecode
f83e65
 create mode 100755 tests/qemu-arm-acpi/sbin/uname
f83e65
 create mode 100755 tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper
f83e65
 create mode 100755 tests/test-qemu-arm-acpi.sh
f83e65
f83e65
diff --git a/Makefile.am b/Makefile.am
f83e65
index 8a47e96..2c958ca 100644
f83e65
--- a/Makefile.am
f83e65
+++ b/Makefile.am
f83e65
@@ -53,6 +53,7 @@ TESTS = \
f83e65
 	tests/test-parallels-desktop.sh \
f83e65
 	tests/test-qemu.sh \
f83e65
 	tests/test-qemu-arm.sh \
f83e65
+	tests/test-qemu-arm-acpi.sh \
f83e65
 	tests/test-rhel5-xen-dom0.sh \
f83e65
 	tests/test-rhel5-xen-domU-hvm.sh \
f83e65
 	tests/test-rhel5-xen-domU-hvm-ia64.sh \
f83e65
@@ -137,6 +138,11 @@ EXTRA_DIST = \
f83e65
 	tests/qemu-arm/sbin/dmidecode \
f83e65
 	tests/qemu-arm/sbin/uname \
f83e65
 	tests/qemu-arm/sbin/virt-what-cpuid-helper \
f83e65
+	tests/qemu-arm-acpi/proc/cpuinfo \
f83e65
+	tests/qemu-arm-acpi/proc/self/status \
f83e65
+	tests/qemu-arm-acpi/sbin/dmidecode \
f83e65
+	tests/qemu-arm-acpi/sbin/uname \
f83e65
+	tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper \
f83e65
 	tests/rhel5-xen-dom0/proc/cpuinfo \
f83e65
 	tests/rhel5-xen-dom0/proc/self/status \
f83e65
 	tests/rhel5-xen-dom0/proc/xen/balloon \
f83e65
diff --git a/tests/qemu-arm-acpi/proc/cpuinfo b/tests/qemu-arm-acpi/proc/cpuinfo
f83e65
new file mode 100644
f83e65
index 0000000..b83a182
f83e65
--- /dev/null
f83e65
+++ b/tests/qemu-arm-acpi/proc/cpuinfo
f83e65
@@ -0,0 +1,63 @@
f83e65
+processor	: 0
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 1
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 2
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 3
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 4
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 5
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 6
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
+
f83e65
+processor	: 7
f83e65
+Features	: fp asimd evtstrm
f83e65
+CPU implementer	: 0x50
f83e65
+CPU architecture: 8
f83e65
+CPU variant	: 0x0
f83e65
+CPU part	: 0x000
f83e65
+CPU revision	: 0
f83e65
diff --git a/tests/qemu-arm-acpi/proc/self/status b/tests/qemu-arm-acpi/proc/self/status
f83e65
new file mode 100644
f83e65
index 0000000..751f5e7
f83e65
--- /dev/null
f83e65
+++ b/tests/qemu-arm-acpi/proc/self/status
f83e65
@@ -0,0 +1,41 @@
f83e65
+Name:	cat
f83e65
+State:	R (running)
f83e65
+Tgid:	8307
f83e65
+Ngid:	0
f83e65
+Pid:	8307
f83e65
+PPid:	1415
f83e65
+TracerPid:	0
f83e65
+Uid:	0	0	0	0
f83e65
+Gid:	0	0	0	0
f83e65
+FDSize:	256
f83e65
+Groups:	
f83e65
+VmPeak:	  109696 kB
f83e65
+VmSize:	  109696 kB
f83e65
+VmLck:	       0 kB
f83e65
+VmPin:	       0 kB
f83e65
+VmHWM:	     832 kB
f83e65
+VmRSS:	     832 kB
f83e65
+VmData:	     320 kB
f83e65
+VmStk:	     256 kB
f83e65
+VmExe:	      64 kB
f83e65
+VmLib:	    1536 kB
f83e65
+VmPTE:	     192 kB
f83e65
+VmSwap:	       0 kB
f83e65
+Threads:	1
f83e65
+SigQ:	0/5821
f83e65
+SigPnd:	0000000000000000
f83e65
+ShdPnd:	0000000000000000
f83e65
+SigBlk:	0000000000000000
f83e65
+SigIgn:	0000000000000000
f83e65
+SigCgt:	0000000000000000
f83e65
+CapInh:	0000000000000000
f83e65
+CapPrm:	0000003fffffffff
f83e65
+CapEff:	0000003fffffffff
f83e65
+CapBnd:	0000003fffffffff
f83e65
+Seccomp:	0
f83e65
+Cpus_allowed:	ff
f83e65
+Cpus_allowed_list:	0-7
f83e65
+Mems_allowed:	1
f83e65
+Mems_allowed_list:	0
f83e65
+voluntary_ctxt_switches:	1
f83e65
+nonvoluntary_ctxt_switches:	1
f83e65
diff --git a/tests/qemu-arm-acpi/sbin/dmidecode b/tests/qemu-arm-acpi/sbin/dmidecode
f83e65
new file mode 100755
f83e65
index 0000000..f7ffd4b
f83e65
--- /dev/null
f83e65
+++ b/tests/qemu-arm-acpi/sbin/dmidecode
f83e65
@@ -0,0 +1,141 @@
f83e65
+#!/bin/sh -
f83e65
+cat <<'EOF'
f83e65
+# dmidecode 3.0
f83e65
+Getting SMBIOS data from sysfs.
f83e65
+SMBIOS 3.0.0 present.
f83e65
+Table at 0x136650000.
f83e65
+
f83e65
+Handle 0x0100, DMI type 1, 27 bytes
f83e65
+System Information
f83e65
+	Manufacturer: QEMU
f83e65
+	Product Name: QEMU Virtual Machine
f83e65
+	Version: 1.0
f83e65
+	Serial Number: Not Specified
f83e65
+	UUID: 6EB70381-DF9C-4407-B6AB-9FA4452117EA
f83e65
+	Wake-up Type: Power Switch
f83e65
+	SKU Number: Not Specified
f83e65
+	Family: Red Hat Enterprise Linux
f83e65
+
f83e65
+Handle 0x0300, DMI type 3, 21 bytes
f83e65
+Chassis Information
f83e65
+	Manufacturer: QEMU
f83e65
+	Type: Other
f83e65
+	Lock: Not Present
f83e65
+	Version: 1.0
f83e65
+	Serial Number: Not Specified
f83e65
+	Asset Tag: Not Specified
f83e65
+	Boot-up State: Safe
f83e65
+	Power Supply State: Safe
f83e65
+	Thermal State: Safe
f83e65
+	Security Status: Unknown
f83e65
+	OEM Information: 0x00000000
f83e65
+	Height: Unspecified
f83e65
+	Number Of Power Cords: Unspecified
f83e65
+	Contained Elements: 0
f83e65
+
f83e65
+Handle 0x0400, DMI type 4, 42 bytes
f83e65
+Processor Information
f83e65
+	Socket Designation: CPU 0
f83e65
+	Type: Central Processor
f83e65
+	Family: Other
f83e65
+	Manufacturer: QEMU
f83e65
+	ID: 00 00 00 00 00 00 00 00
f83e65
+	Version: 1.0
f83e65
+	Voltage: Unknown
f83e65
+	External Clock: Unknown
f83e65
+	Max Speed: 2000 MHz
f83e65
+	Current Speed: 2000 MHz
f83e65
+	Status: Populated, Enabled
f83e65
+	Upgrade: Other
f83e65
+	L1 Cache Handle: Not Provided
f83e65
+	L2 Cache Handle: Not Provided
f83e65
+	L3 Cache Handle: Not Provided
f83e65
+	Serial Number: Not Specified
f83e65
+	Asset Tag: Not Specified
f83e65
+	Part Number: Not Specified
f83e65
+	Core Count: 1
f83e65
+	Core Enabled: 1
f83e65
+	Thread Count: 1
f83e65
+	Characteristics: None
f83e65
+
f83e65
+Handle 0x0401, DMI type 4, 42 bytes
f83e65
+Processor Information
f83e65
+	Socket Designation: CPU 1
f83e65
+	Type: Central Processor
f83e65
+	Family: Other
f83e65
+	Manufacturer: QEMU
f83e65
+	ID: 00 00 00 00 00 00 00 00
f83e65
+	Version: 1.0
f83e65
+	Voltage: Unknown
f83e65
+	External Clock: Unknown
f83e65
+	Max Speed: 2000 MHz
f83e65
+	Current Speed: 2000 MHz
f83e65
+	Status: Populated, Enabled
f83e65
+	Upgrade: Other
f83e65
+	L1 Cache Handle: Not Provided
f83e65
+	L2 Cache Handle: Not Provided
f83e65
+	L3 Cache Handle: Not Provided
f83e65
+	Serial Number: Not Specified
f83e65
+	Asset Tag: Not Specified
f83e65
+	Part Number: Not Specified
f83e65
+	Core Count: 1
f83e65
+	Core Enabled: 1
f83e65
+	Thread Count: 1
f83e65
+	Characteristics: None
f83e65
+
f83e65
+Handle 0x1000, DMI type 16, 23 bytes
f83e65
+Physical Memory Array
f83e65
+	Location: Other
f83e65
+	Use: System Memory
f83e65
+	Error Correction Type: Multi-bit ECC
f83e65
+	Maximum Capacity: 4 GB
f83e65
+	Error Information Handle: Not Provided
f83e65
+	Number Of Devices: 1
f83e65
+
f83e65
+Handle 0x1100, DMI type 17, 40 bytes
f83e65
+Memory Device
f83e65
+	Array Handle: 0x1000
f83e65
+	Error Information Handle: Not Provided
f83e65
+	Total Width: Unknown
f83e65
+	Data Width: Unknown
f83e65
+	Size: 4096 MB
f83e65
+	Form Factor: DIMM
f83e65
+	Set: None
f83e65
+	Locator: DIMM 0
f83e65
+	Bank Locator: Not Specified
f83e65
+	Type: RAM
f83e65
+	Type Detail: Other
f83e65
+	Speed: Unknown
f83e65
+	Manufacturer: QEMU
f83e65
+	Serial Number: Not Specified
f83e65
+	Asset Tag: Not Specified
f83e65
+	Part Number: Not Specified
f83e65
+	Rank: Unknown
f83e65
+	Configured Clock Speed: Unknown
f83e65
+	Minimum Voltage: Unknown
f83e65
+	Maximum Voltage: Unknown
f83e65
+	Configured Voltage: Unknown
f83e65
+
f83e65
+Handle 0x2000, DMI type 32, 11 bytes
f83e65
+System Boot Information
f83e65
+	Status: No errors detected
f83e65
+
f83e65
+Handle 0x0000, DMI type 0, 24 bytes
f83e65
+BIOS Information
f83e65
+	Vendor: EFI Development Kit II / OVMF
f83e65
+	Version: 0.0.0
f83e65
+	Release Date: 02/06/2015
f83e65
+	Address: 0xE8000
f83e65
+	Runtime Size: 96 kB
f83e65
+	ROM Size: 64 kB
f83e65
+	Characteristics:
f83e65
+		BIOS characteristics not supported
f83e65
+		Targeted content distribution is supported
f83e65
+		UEFI is supported
f83e65
+		System is a virtual machine
f83e65
+	BIOS Revision: 0.0
f83e65
+
f83e65
+Handle 0xFEFF, DMI type 127, 4 bytes
f83e65
+End Of Table
f83e65
+
f83e65
+EOF
f83e65
diff --git a/tests/qemu-arm-acpi/sbin/uname b/tests/qemu-arm-acpi/sbin/uname
f83e65
new file mode 100755
f83e65
index 0000000..bd33a2d
f83e65
--- /dev/null
f83e65
+++ b/tests/qemu-arm-acpi/sbin/uname
f83e65
@@ -0,0 +1,2 @@
f83e65
+#!/bin/sh -
f83e65
+echo aarch64
f83e65
diff --git a/tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper b/tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper
f83e65
new file mode 100755
f83e65
index 0000000..77a6692
f83e65
--- /dev/null
f83e65
+++ b/tests/qemu-arm-acpi/sbin/virt-what-cpuid-helper
f83e65
@@ -0,0 +1,2 @@
f83e65
+#!/bin/sh -
f83e65
+# nothing
f83e65
diff --git a/tests/test-qemu-arm-acpi.sh b/tests/test-qemu-arm-acpi.sh
f83e65
new file mode 100755
f83e65
index 0000000..64db9eb
f83e65
--- /dev/null
f83e65
+++ b/tests/test-qemu-arm-acpi.sh
f83e65
@@ -0,0 +1,34 @@
f83e65
+# Test for qemu on ARM
f83e65
+# Copyright (C) 2015 Red Hat Inc.
f83e65
+#
f83e65
+# This program is free software; you can redistribute it and/or modify
f83e65
+# it under the terms of the GNU General Public License as published by
f83e65
+# the Free Software Foundation; either version 2 of the License, or
f83e65
+# (at your option) any later version.
f83e65
+#
f83e65
+# This program is distributed in the hope that it will be useful,
f83e65
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f83e65
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f83e65
+# GNU General Public License for more details.
f83e65
+#
f83e65
+# You should have received a copy of the GNU General Public License
f83e65
+# along with this program; if not, write to the Free Software
f83e65
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
f83e65
+
f83e65
+root=tests/qemu-arm-acpi
f83e65
+
f83e65
+output="$(./virt-what --test-root=$root 2>&1)"
f83e65
+expected="qemu"
f83e65
+
f83e65
+if [ "$output" != "$expected" ]; then
f83e65
+    echo "$0: test failed because output did not match expected"
f83e65
+    echo "Expected output was:"
f83e65
+    echo "----------------------------------------"
f83e65
+    echo "$expected"
f83e65
+    echo "----------------------------------------"
f83e65
+    echo "But the actual output of the program was:"
f83e65
+    echo "----------------------------------------"
f83e65
+    echo "$output"
f83e65
+    echo "----------------------------------------"
f83e65
+    exit 1
f83e65
+fi
f83e65
diff --git a/virt-what.in b/virt-what.in
f83e65
index 6daba34..697595c 100644
f83e65
--- a/virt-what.in
f83e65
+++ b/virt-what.in
f83e65
@@ -264,6 +264,11 @@ if ! "$skip_qemu_kvm"; then
f83e65
             # using KVM acceleration or not.
f83e65
             echo qemu
f83e65
             skip_lkvm=true
f83e65
+        elif echo "$dmi" | grep -q 'Manufacturer: QEMU'; then
f83e65
+            # We don't have enough information to determine if we're
f83e65
+            # using KVM acceleration or not.
f83e65
+            echo qemu
f83e65
+            skip_lkvm=true
f83e65
         fi
f83e65
     else
f83e65
         # XXX This is known to fail for qemu with the explicit -cpu
f83e65
-- 
f83e65
1.8.3.1
f83e65