diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c55c81 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/virt-what-1.18.tar.gz diff --git a/.virt-what.metadata b/.virt-what.metadata new file mode 100644 index 0000000..6ee78eb --- /dev/null +++ b/.virt-what.metadata @@ -0,0 +1 @@ +cf60480c17be5350835a0b23dc82012ec711eea1 SOURCES/virt-what-1.18.tar.gz diff --git a/SOURCES/0001-Missing-have_cpuinfo-check.patch b/SOURCES/0001-Missing-have_cpuinfo-check.patch new file mode 100644 index 0000000..2c2216e --- /dev/null +++ b/SOURCES/0001-Missing-have_cpuinfo-check.patch @@ -0,0 +1,25 @@ +From eefc1e7e3dd8fb422baf0f13aec1df9880541b83 Mon Sep 17 00:00:00 2001 +From: Jasper Lievisse Adriaanse +Date: Thu, 10 Aug 2017 08:44:01 +0100 +Subject: [PATCH 1/4] Missing have_cpuinfo check. + +--- + virt-what.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/virt-what.in b/virt-what.in +index 8c27b11..9050035 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -308,7 +308,7 @@ if ! "$skip_qemu_kvm"; then + # option, since /proc/cpuinfo will not contain the QEMU + # string. QEMU 2.10 added a new CPUID leaf, so this + # problem only triggered for older QEMU +- if grep -q 'QEMU' "${root}/proc/cpuinfo"; then ++ if have_cpuinfo && grep -q 'QEMU' "${root}/proc/cpuinfo"; then + echo qemu + fi + fi +-- +2.13.2 + diff --git a/SOURCES/0002-Remove-bashisms.patch b/SOURCES/0002-Remove-bashisms.patch new file mode 100644 index 0000000..7b88642 --- /dev/null +++ b/SOURCES/0002-Remove-bashisms.patch @@ -0,0 +1,48 @@ +From 9d90704a05dee7704470eff818a1c44aeef6c880 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 4 Aug 2017 12:02:08 -0300 +Subject: [PATCH 2/4] Remove bashisms + +Use [ instead of [[ so we fall back to test if necessary: + + http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html + +Gbp-Pq: Name Remove-bashisms.patch +--- + virt-what.in | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/virt-what.in b/virt-what.in +index 9050035..a05e0db 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -360,20 +360,20 @@ if [ "$cpuid" = "OpenBSDVMM58" ]; then + fi + + # Check for LDoms +-if [[ "$arch" == sparc* && -e ${root}/dev/mdesc ]]; then ++if [ "${arch#sparc}" != "$arch" ] && [ -e "${root}/dev/mdesc" ]; then + echo ldoms +- if [[ -d ${root}/sys/class/vlds/ctrl && \ +- -d ${root}/sys/class/vlds/sp ]]; then ++ if [ -d "${root}/sys/class/vlds/ctrl" ] && \ ++ [ -d "${root}/sys/class/vlds/sp" ]; then + echo ldoms-control + else + echo ldoms-guest + fi + MDPROP="${root}/usr/lib/ldoms/mdprop.py" +- if [[ -x ${MDPROP} ]]; then +- if [[ -n $($MDPROP -v iodevice device-type=pciex) ]]; then ++ if [ -x "${MDPROP}" ]; then ++ if [ -n "$($MDPROP -v iodevice device-type=pciex)" ]; then + echo ldoms-root + echo ldoms-io +- elif [[ -n $($MDPROP -v iov-device vf-id=0) ]]; then ++ elif [ -n "$($MDPROP -v iov-device vf-id=0)" ]; then + echo ldoms-io + fi + fi +-- +2.13.2 + diff --git a/SOURCES/0003-As-xen-pv-guest-can-access-cpuid-from-Intel-CPUs-sta.patch b/SOURCES/0003-As-xen-pv-guest-can-access-cpuid-from-Intel-CPUs-sta.patch new file mode 100644 index 0000000..bd42694 --- /dev/null +++ b/SOURCES/0003-As-xen-pv-guest-can-access-cpuid-from-Intel-CPUs-sta.patch @@ -0,0 +1,35 @@ +From a821dc9961d457c086fffcc16a911cb6f9f8659a Mon Sep 17 00:00:00 2001 +From: xiliang +Date: Sun, 18 Jun 2017 00:33:28 +0800 +Subject: [PATCH 3/4] As xen pv guest can access cpuid from Intel CPUs started + IvyBridge onwards have CPUID Faulting, added one more check in virt-what. + +--- + virt-what.in | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/virt-what.in b/virt-what.in +index a05e0db..247348e 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -1,6 +1,6 @@ + #!/bin/sh - + # @configure_input@ +-# Copyright (C) 2008-2015 Red Hat Inc. ++# Copyright (C) 2008-2017 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 +@@ -223,7 +223,8 @@ fi + + # Check for Xen. + +-if [ "$cpuid" = "XenVMMXenVMM" ]; then ++if [ "$cpuid" = "XenVMMXenVMM" ] && ++ ! echo "$dmi" | grep -q 'No SMBIOS nor DMI entry point found, sorry'; then + echo xen; echo xen-hvm + # Check for AWS + if echo "$dmi" | grep -q 'Version: [0-9]\.[0-9]\.amazon'; then +-- +2.13.2 + diff --git a/SOURCES/0004-Recognize-ppc64le-little-endian-virtualization-RHBZ-.patch b/SOURCES/0004-Recognize-ppc64le-little-endian-virtualization-RHBZ-.patch new file mode 100644 index 0000000..98f0492 --- /dev/null +++ b/SOURCES/0004-Recognize-ppc64le-little-endian-virtualization-RHBZ-.patch @@ -0,0 +1,28 @@ +From 7db94c8fe63f2c7ec3ac27cc5ff54ec1e1686aeb Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 17 Oct 2017 14:47:09 +0100 +Subject: [PATCH 4/4] Recognize ppc64le (little endian) virtualization + (RHBZ#1147876). + +Tested by Laurent Vivier, see: +https://bugzilla.redhat.com/show_bug.cgi?id=1147876#c35 & ff. +--- + virt-what.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/virt-what.in b/virt-what.in +index 247348e..29b7b0d 100644 +--- a/virt-what.in ++++ b/virt-what.in +@@ -339,7 +339,7 @@ fi + # example /proc/ppc64/lparcfg systemtype line + # system_type=IBM pSeries (emulated by qemu) + +-if [ "$arch" = "ppc64" ]; then ++if [ "$arch" = "ppc64" ] || [ "$arch" = "ppc64le" ] ; then + if have_cpuinfo && grep -q 'platform.**pSeries' "${root}/proc/cpuinfo"; then + if grep -q 'model.*emulated by qemu' "${root}/proc/cpuinfo"; then + echo ibm_power-kvm +-- +2.13.2 + diff --git a/SPECS/virt-what.spec b/SPECS/virt-what.spec new file mode 100644 index 0000000..e304000 --- /dev/null +++ b/SPECS/virt-what.spec @@ -0,0 +1,221 @@ +Name: virt-what +Version: 1.18 +Release: 4%{?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 + +# Patches from upstream since 1.18 was released. +Patch0001: 0001-Missing-have_cpuinfo-check.patch +Patch0002: 0002-Remove-bashisms.patch +Patch0003: 0003-As-xen-pv-guest-can-access-cpuid-from-Intel-CPUs-sta.patch +Patch0004: 0004-Recognize-ppc64le-little-endian-virtualization-RHBZ-.patch + +# This is provided by the build root, but we make it explicit +# anyway in case this was dropped from the build root in future. +BuildRequires: /usr/bin/pod2man + +# Required at build time in order to do 'make check' (for getopt). +BuildRequires: util-linux + +# virt-what script uses dmidecode and getopt (from util-linux). +# RPM cannot detect this so make the dependencies explicit here. +%ifarch aarch64 %{ix86} x86_64 +Requires: dmidecode +%endif +Requires: util-linux + +# Runs the 'which' program to find the helper. +Requires: which + + +%description +virt-what is a shell script which can be used to detect if the program +is running in a virtual machine. + +The program prints out a list of "facts" about the virtual machine, +derived from heuristics. One fact is printed per line. + +If nothing is printed and the script exits with code 0 (no error), +then it can mean either that the program is running on bare-metal or +the program is running inside a type of virtual machine which we don't +know about or can't detect. + +Current types of virtualization detected: + + - aws Amazon Web Services cloud guest + - bhyve FreeBSD hypervisor + - docker Docker container + - hyperv Microsoft Hyper-V + - ibm_power-kvm + IBM POWER KVM + - ibm_power-lpar_shared + - ibm_power-lpar_dedicated + IBM POWER LPAR (hardware partition) + - ibm_systemz-* + IBM SystemZ Direct / LPAR / z/VM / KVM + - ldoms Oracle VM Server for SPARC Logical Domains + - linux_vserver + Linux VServer container + - lxc Linux LXC container + - kvm Linux Kernel Virtual Machine (KVM) + - lkvm LKVM / kvmtool + - openvz OpenVZ or Virtuozzo + - ovirt oVirt node + - parallels Parallels Virtual Platform + - powervm_lx86 IBM PowerVM Lx86 Linux/x86 emulator + - qemu QEMU (unaccelerated) + - rhev Red Hat Enterprise Virtualization + - uml User-Mode Linux (UML) + - virtage Hitachi Virtualization Manager (HVM) Virtage LPAR + - virtualbox VirtualBox + - virtualpc Microsoft VirtualPC + - vmm vmm OpenBSD hypervisor + - vmware VMware + - xen Xen + - xen-dom0 Xen dom0 (privileged domain) + - xen-domU Xen domU (paravirtualized guest domain) + - xen-hvm Xen guest fully virtualized (HVM) + + +%prep +%setup -q +%autopatch -p1 + + +%build +%configure +make + + +%install +make install DESTDIR=$RPM_BUILD_ROOT + + +%check +if ! make check ; then + cat test-suite.log + exit 1 +fi + +%files +%doc README COPYING +%{_sbindir}/virt-what +%{_libexecdir}/virt-what-cpuid-helper +%{_mandir}/man1/*.1* + + +%changelog +* Tue Oct 17 2017 Richard W.M. Jones - 1.18-4 +- Add patch to recognize ppc64le virtualization. + resolves: rhbz#1147876 + +* Tue Oct 17 2017 Richard W.M. Jones - 1.18-2 +- Rebase to Fedora Rawhide / upstream version. +- Include upstream patches since 1.18 was released. + resolves: rhbz#1476878 + +* Tue Mar 28 2017 Richard W.M. Jones - 1.13-10 +- Require 'which' program + resolves: rhbz#1433005 + +* Thu Feb 16 2017 Richard W.M. Jones - 1.13-9 +- Detect RHEV/oVirt (second fix) + resolves: rhbz#1249438 + +* Wed Jul 27 2016 Richard W.M. Jones - 1.13-8 +- Depend on dmidecode on aarch64 + resolves: rhbz#1360699 + +* Mon Jun 20 2016 Richard W.M. Jones - 1.13-7 +- Add support for detecting POWER KVM and LPAR + resolves: rhbz#1147876 +- Detect RHEV/oVirt + resolves: rhbz#1249438 +- Detect ACPI boot aarch64 guest + resolves: rhbz#1275349 +- Fix typo in manual page + resolves: rhbz#1099289 + +* Tue Apr 21 2015 Richard W.M. Jones - 1.13-6 +- Fix detection of aarch64 + resolves: rhbz#1201845 + Add all commits to version 1.15. + +* Fri Jan 24 2014 Daniel Mach - 1.13-5 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 1.13-4 +- Mass rebuild 2013-12-27 + +* Mon Oct 28 2013 Richard W.M. Jones - 1.13-3 +- Suppress warning message on Amazon EC2: + "grep: /proc/xen/capabilities: No such file or directory" + +* Wed Sep 11 2013 Richard W.M. Jones - 1.13-2 +- Include two upstream patches for detecting Xen and Linux VServer better + (RHBZ#973663). +- Modernize the spec file. + +* Mon Jul 29 2013 Richard W.M. Jones - 1.13-1 +- New upstream version 1.13. + +* Fri Feb 15 2013 Fedora Release Engineering - 1.12-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Sun Jul 22 2012 Fedora Release Engineering - 1.12-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Mar 17 2012 Richard W.M. Jones - 1.12-1 +- New upstream version 1.12. + +* Wed Feb 29 2012 Richard W.M. Jones - 1.11-3 +- Remove ExclusiveArch, but don't require dmidecode except on + i?86 and x86-64 (RHBZ#791370). + +* Sat Jan 14 2012 Fedora Release Engineering - 1.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Fri May 27 2011 Richard W.M. Jones - 1.11-1 +- New upstream version 1.11. + +* Wed May 25 2011 Richard W.M. Jones - 1.10-1 +- New upstream version 1.10. + +* Tue Mar 8 2011 Richard W.M. Jones - 1.9-1 +- New upstream version 1.9. + +* Mon Feb 07 2011 Fedora Release Engineering - 1.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Jan 31 2011 Richard W.M. Jones - 1.8-1 +- New upstream version 1.8. + +* Thu Jan 20 2011 Richard W.M. Jones - 1.7-1 +- New upstream version 1.7. + +* Wed Jan 19 2011 Richard W.M. Jones - 1.6-2 +- New upstream version 1.6. +- BuildRequires 'getopt' from util-linux-ng. + +* Tue Jan 18 2011 Richard W.M. Jones - 1.5-1 +- New upstream version 1.5. +- Add 'make check' section. + +* Tue Jan 18 2011 Richard W.M. Jones - 1.4-1 +- New upstream version 1.4. +- More hypervisor types detected. + +* Thu Oct 28 2010 Richard W.M. Jones - 1.3-4 +- Move configure into build (not prep). + +* Thu Oct 28 2010 Richard W.M. Jones - 1.3-3 +- Initial import into Fedora. + +* Tue Oct 19 2010 Richard W.M. Jones - 1.3-2 +- Make changes suggested by reviewer (RHBZ#644259). + +* Tue Oct 19 2010 Richard W.M. Jones - 1.3-1 +- Initial release.