virt-what: recognize OpenBSD vmm
authorJasper Lievisse Adriaanse <bug@jasper.la>
Sat, 1 Jul 2017 11:12:46 +0000 (13:12 +0200)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 18 Jul 2017 13:06:05 +0000 (14:06 +0100)
Hi,

Please find attached a patch for virt-what to recognize the OpenBSD VMM
hypervisor.

For more information on vmm, please refer to:
- http://man.openbsd.org/vmm.4
- https://www.openbsd.org/papers/asiabsdcon2017-vmm-slides.pdf

>From 837390b5afbb9253a62b15208d6fb4cbbbecabf1 Mon Sep 17 00:00:00 2001
From: Jasper Lievisse Adriaanse <j@jasper.la>
Date: Sat, 17 Jun 2017 21:17:39 +0200
Subject: [PATCH] vmm detection (OpenBSD hypervisor)

Makefile.am
tests/test-vmm.sh [new file with mode: 0755]
tests/vmm/proc/cpuinfo [new file with mode: 0644]
tests/vmm/sbin/dmidecode [new file with mode: 0755]
tests/vmm/sbin/uname [new file with mode: 0755]
tests/vmm/sbin/virt-what-cpuid-helper [new file with mode: 0755]
virt-what.in
virt-what.pod

index e32c07c..5cdb943 100644 (file)
@@ -65,6 +65,7 @@ TESTS = \
        tests/test-rhel5-xen-domU-hvm-ia64.sh \
        tests/test-rhel5-xen-domU-pv.sh \
        tests/test-rhev.sh \
+       tests/test-vmm.sh \
        tests/test-xen-arm.sh \
        tests/test-zvm.sh
 
@@ -244,6 +245,12 @@ EXTRA_DIST = \
        tests/rhev/sbin/dmidecode \
        tests/rhev/sbin/uname \
        tests/rhev/sbin/virt-what-cpuid-helper \
+       tests/vmm/proc/cpuinfo \
+       tests/vvm/proc/self/status \
+       tests/vvm/proc/sysinfo \
+       tests/vvm/sbin/dmidecode \
+       tests/vvm/sbin/uname \
+       tests/vvm/sbin/virt-what-cpuid-helper \
        tests/xen-arm/proc/cpuinfo \
        tests/xen-arm/proc/device-tree/hypervisor/compatible \
        tests/xen-arm/proc/self/status \
diff --git a/tests/test-vmm.sh b/tests/test-vmm.sh
new file mode 100755 (executable)
index 0000000..e1de60a
--- /dev/null
@@ -0,0 +1,34 @@
+# Test for vmm
+# Copyright (C) 2008-2011 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.
+
+root=tests/vmm
+
+output="$(./virt-what --test-root=$root 2>&1)"
+expected="vmm"
+
+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/tests/vmm/proc/cpuinfo b/tests/vmm/proc/cpuinfo
new file mode 100644 (file)
index 0000000..77e142c
--- /dev/null
@@ -0,0 +1,25 @@
+processor      : 0
+vendor_id      : GenuineIntel
+cpu family     : 6
+model          : 61
+model name     : Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
+stepping       : 4
+cache size     : 3072 KB
+physical id    : 0
+siblings       : 1
+core id                : 0
+cpu cores      : 1
+apicid         : 0
+initial apicid : 0
+fpu            : yes
+fpu_exception  : yes
+cpuid level    : 13
+wp             : yes
+flags          : fpu vme de pse msr pae mce cx8 sep pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx pdpe1gb lm constant_tsc nopl eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap
+bugs           :
+bogomips       : 11431.11
+clflush size   : 64
+cache_alignment        : 64
+address sizes  : 36 bits physical, 48 bits virtual
+power management:
+
diff --git a/tests/vmm/sbin/dmidecode b/tests/vmm/sbin/dmidecode
new file mode 100755 (executable)
index 0000000..c10a540
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh -
+cat <<'EOF'
+# dmidecode 3.1
+Scanning /dev/mem for entry point.
+# No SMBIOS nor DMI entry point found, sorry.
+
+EOF
diff --git a/tests/vmm/sbin/uname b/tests/vmm/sbin/uname
new file mode 100755 (executable)
index 0000000..ab0ec89
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh -
+echo x86_64
diff --git a/tests/vmm/sbin/virt-what-cpuid-helper b/tests/vmm/sbin/virt-what-cpuid-helper
new file mode 100755 (executable)
index 0000000..bbf0530
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo 'OpenBSDVMM58'
index 5f9edd7..4c416fb 100644 (file)
@@ -349,3 +349,8 @@ if [ "$arch" = "ppc64" ]; then
         fi
     fi
 fi
+
+# Check for OpenBSD/VMM
+if [ "$cpuid" = "OpenBSDVMM58" ]; then
+        echo vmm
+fi
index 2c087bf..d8b8ba9 100644 (file)
@@ -213,6 +213,12 @@ The guest appears to be running on Microsoft VirtualPC.
 
 Status: not confirmed
 
+=item B<vmm>
+
+This is a vmm (OpenBSD hypervisor) guest.
+
+Status: contributed by Jasper Lievisse Adriaanse.
+
 =item B<vmware>
 
 The guest appears to be running on VMware hypervisor.