From 78de66961e7beaf4e47c2ccd200d9081f2669426 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 29 Jan 2024 15:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E5=9B=A0=E4=B8=BA=E4=BF=A1=E6=81=AF=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=9C=89=E8=AF=AF=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=90=AF=E5=8A=A8=E8=99=9A=E6=8B=9F=E6=9C=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StartVM.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/StartVM.sh b/StartVM.sh index a13023a..6611d2c 100755 --- a/StartVM.sh +++ b/StartVM.sh @@ -29,7 +29,16 @@ if [[ $? == 0 ]] && [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then CpuCoreNum=`grep 'core id' /proc/cpuinfo | sort -u | wc -l` # 查看逻辑CPU的个数 CpuCount=`cat /proc/cpuinfo| grep "processor"| wc -l` - + # 判断是否检测异常,如果异常则使用默认值 + if [[ $CpuSocketNum == 0 ]]; then + CpuSocketNum=1 + fi + if [[ $CpuCoreNum == 0 ]]; then + CpuCoreNum=1 + fi + if [[ $CpuCount == 0 ]]; then + CpuCount=2 + fi # 总内存大小GB MemTotal=`awk '($1 == "MemTotal:"){printf "%.2f\n",$2/1024/1024}' /proc/meminfo` use=$(echo "scale=4; $MemTotal / 3" | bc)