acrn-hypervisor/misc/packaging/acrn-hypervisor.preinst
2021-11-25 13:56:21 +08:00

77 lines
1.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#* Copyright (c) 2020 Intel Corporation SPDX-License-Identifier: BSD-3-Clause
# preinst script for acrn-hypervisor
acrnnative=$(ls /sys/class/ |grep vhm || true)
if [ -z "$acrnnative" ]
then
echo "You are in ubuntu, let's pre-check whether fit acrn needs"
else
echo "You are in acrn already, no need pre-check "
exit 0
fi
#check mem/cpu
cpunumsexp=4
percode=$(lscpu |awk '$1 == "Thread(s)" {print $NF}')
cputotal=$(lscpu |awk '$1 == "CPU(s):" {print $NF}')
if [[ $cputotal -eq $cpunumsexp ]]
then
echo "CPU cores config is ok"
elif [[ $cputotal -gt $cpunumsexp ]]
then
echo "Error ! hyper-threading config is not correct!"
echo "CPU(s) $cputotal should be $cpunumsexpThread(s) per core is $percode, please disable hyper-threading in bios"
elif [[ $cputotal -lt $cpunumsexp ]]
then
echo "Error ! hyper threading config is incorrect!"
echo "CPU(s) $cputotal should be $cpunumsexpThread(s) per core is $percode, please enable hyper-threading in bios"
fi
#check vt
vtd=$(ls -al /sys/firmware/acpi/tables |grep DMAR || true)
if [ -z "$vtd" ]
then
echo "Error ! VT-d not enabled!"
echo "This CPU does not support VT-d or it's not enabled through BIOS settings"
fi
vtx=$(lscpu |grep VT-x)
if [ -z "$vtx" ]
then
echo "Error ! VT-x not enabled!"
echo "This CPU does not support VT-x or it's not enabled through BIOS settings"
fi
echo "VT-x/VT-d config is ok"
#check cpu
cputype=$(lscpu |awk '$1 == "Model"'|grep Core || true)
if [ -z "$cputype" ]
then
echo "CPU type not Core"
echo "Xeon Processors are not supported!"
echo "Warning ! ACRN may not support your hardware!"
else
echo "cpu type is ok"
fi
#check memory
totalmemry=200000000000
wholememory=$(cat /proc/meminfo |grep MemTotal:|awk '{print $2}')
if [[ $wholememory -gt $totalmemry ]]
then
echo "Warning ! memory is greater than 16G, please rebuild hypervisor"
echo "if you had rebuild version please ignore"
else
echo "memory is ok, $wholememory"
fi