Allow using sysctl, for example when /proc isn't available
authorJasper Lievisse Adriaanse <jasper@humppa.nl>
Wed, 25 Apr 2018 14:41:32 +0000 (16:41 +0200)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 3 May 2018 11:35:55 +0000 (12:35 +0100)
virt-what.in

index 2011ff4..d037a99 100644 (file)
@@ -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
@@ -304,6 +311,12 @@ 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