lacking /proc, allow using sysctl on OpenBSD.
currently used to detect 'SmartDC HVM'
This commit is contained in:
parent
d8f3773e22
commit
3ffc381fcb
@ -1,8 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2017/08/10 12:23:28 jasper Exp $
|
||||
# $OpenBSD: Makefile,v 1.2 2018/04/25 14:36:40 jasper Exp $
|
||||
|
||||
COMMENT = detect if we are running in a virtual machine
|
||||
|
||||
DISTNAME = virt-what-1.18
|
||||
REVISION = 0
|
||||
CATEGORIES = sysutils
|
||||
|
||||
HOMEPAGE = https://people.redhat.com/~rjones/virt-what/
|
||||
|
@ -1,4 +1,6 @@
|
||||
$OpenBSD: patch-virt-what_in,v 1.2 2017/08/10 13:32:55 jasper Exp $
|
||||
$OpenBSD: patch-virt-what_in,v 1.3 2018/04/25 14:36:40 jasper Exp $
|
||||
|
||||
Use sysctl on OpenBSD -- use this to recognize SmartOS KVM
|
||||
|
||||
From eefc1e7e3dd8fb422baf0f13aec1df9880541b83 Mon Sep 17 00:00:00 2001
|
||||
From: Jasper Lievisse Adriaanse <bug@jasper.la>
|
||||
@ -8,7 +10,32 @@ Subject: [PATCH] Missing have_cpuinfo check.
|
||||
Index: virt-what.in
|
||||
--- virt-what.in.orig
|
||||
+++ virt-what.in
|
||||
@@ -308,7 +308,7 @@ if ! "$skip_qemu_kvm"; then
|
||||
@@ -38,6 +38,13 @@ have_cpuinfo () {
|
||||
test -e "${root}/proc/cpuinfo"
|
||||
}
|
||||
|
||||
+use_sysctl() {
|
||||
+ # Lacking /proc, on some systems sysctl can be used instead.
|
||||
+ OS=$(uname) || fail "failed to get operating system name"
|
||||
+
|
||||
+ [ "$OS" == "OpenBSD" ]
|
||||
+}
|
||||
+
|
||||
fail () {
|
||||
echo "virt-what: $1" >&2
|
||||
exit 1
|
||||
@@ -303,12 +310,18 @@ if ! "$skip_qemu_kvm"; then
|
||||
# We are running as a spapr KVM guest on ppc64
|
||||
echo kvm
|
||||
skip_lkvm=true
|
||||
+ elif use_sysctl; then
|
||||
+ # SmartOS KVM
|
||||
+ product=$(sysctl -n hw.product)
|
||||
+ if echo "$product" | grep -q 'SmartDC HVM'; then
|
||||
+ echo kvm
|
||||
+ fi
|
||||
else
|
||||
# This is known to fail for qemu with the explicit -cpu
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user