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

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