Blame SOURCES/0006-Allow-using-sysctl-for-example-when-proc-isn-t-avail.patch

e10a2d
From d7fd8a7843030d2b1719353edfcd49dba3000122 Mon Sep 17 00:00:00 2001
e10a2d
From: Jasper Lievisse Adriaanse <jasper@humppa.nl>
e10a2d
Date: Wed, 25 Apr 2018 16:41:32 +0200
e10a2d
Subject: [PATCH 06/21] Allow using sysctl, for example when /proc isn't
e10a2d
 available
e10a2d
e10a2d
---
e10a2d
 virt-what.in | 13 +++++++++++++
e10a2d
 1 file changed, 13 insertions(+)
e10a2d
e10a2d
diff --git a/virt-what.in b/virt-what.in
e10a2d
index 2011ff4..d037a99 100644
e10a2d
--- a/virt-what.in
e10a2d
+++ b/virt-what.in
e10a2d
@@ -38,6 +38,13 @@ have_cpuinfo () {
e10a2d
     test -e "${root}/proc/cpuinfo"
e10a2d
 }
e10a2d
 
e10a2d
+use_sysctl() {
e10a2d
+    # Lacking /proc, on some systems sysctl can be used instead.
e10a2d
+    OS=$(uname) || fail "failed to get operating system name"
e10a2d
+
e10a2d
+    [ "$OS" == "OpenBSD" ]
e10a2d
+}
e10a2d
+
e10a2d
 fail () {
e10a2d
     echo "virt-what: $1" >&2
e10a2d
     exit 1
e10a2d
@@ -304,6 +311,12 @@ if ! "$skip_qemu_kvm"; then
e10a2d
         # We are running as a spapr KVM guest on ppc64
e10a2d
         echo kvm
e10a2d
         skip_lkvm=true
e10a2d
+    elif use_sysctl; then
e10a2d
+        # SmartOS KVM
e10a2d
+        product=$(sysctl -n hw.product)
e10a2d
+        if echo "$product" | grep -q 'SmartDC HVM'; then
e10a2d
+            echo kvm
e10a2d
+        fi
e10a2d
     else
e10a2d
         # This is known to fail for qemu with the explicit -cpu
e10a2d
         # option, since /proc/cpuinfo will not contain the QEMU
e10a2d
-- 
e10a2d
2.23.0
e10a2d