diff --git a/InstallRuntime/amd64.sh b/InstallRuntime/amd64.sh index 19fa97e..f912f54 100755 --- a/InstallRuntime/amd64.sh +++ b/InstallRuntime/amd64.sh @@ -16,5 +16,6 @@ fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update sudo dpkg -i /tmp/$fileName +sudo apt install qemu-user qemu-user-static binfmt-support -y echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/InstallRuntime/arm64.sh b/InstallRuntime/arm64.sh index df208d7..1395b93 100755 --- a/InstallRuntime/arm64.sh +++ b/InstallRuntime/arm64.sh @@ -15,6 +15,7 @@ if [[ -f /tmp/$fileName ]]; then fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update +sudo apt install qemu-user qemu-user-static binfmt-support -y sudo dpkg -i /tmp/$fileName echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/InstallRuntime/armhf.sh b/InstallRuntime/armhf.sh index 015e39b..8b06e95 100755 --- a/InstallRuntime/armhf.sh +++ b/InstallRuntime/armhf.sh @@ -15,6 +15,7 @@ if [[ -f /tmp/$fileName ]]; then fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update +sudo apt install qemu-user qemu-user-static binfmt-support -y sudo dpkg -i /tmp/$fileName echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/InstallRuntime/i386.sh b/InstallRuntime/i386.sh index 4b22eb2..9d5fa9a 100755 --- a/InstallRuntime/i386.sh +++ b/InstallRuntime/i386.sh @@ -15,6 +15,7 @@ if [[ -f /tmp/$fileName ]]; then fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update +sudo apt install qemu-user qemu-user-static binfmt-support -y sudo dpkg -i /tmp/$fileName echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/InstallRuntime/mips64el.sh b/InstallRuntime/mips64el.sh index 56c6eae..fb439a2 100755 --- a/InstallRuntime/mips64el.sh +++ b/InstallRuntime/mips64el.sh @@ -15,6 +15,7 @@ if [[ -f /tmp/$fileName ]]; then fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update +sudo apt install qemu-user qemu-user-static binfmt-support -y sudo dpkg -i /tmp/$fileName echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/InstallRuntime/ppc64el.sh b/InstallRuntime/ppc64el.sh index 78abc01..346a355 100755 --- a/InstallRuntime/ppc64el.sh +++ b/InstallRuntime/ppc64el.sh @@ -15,6 +15,7 @@ if [[ -f /tmp/$fileName ]]; then fi aria2c -x 16 -s 16 -c $url -d /tmp -o $fileName sudo apt update +sudo apt install qemu-user qemu-user-static binfmt-support -y sudo dpkg -i /tmp/$fileName echo 安装完成,按回车键退出 -read \ No newline at end of file +read diff --git a/StartVM.sh b/StartVM.sh index d1a7c77..1f00e03 100755 --- a/StartVM.sh +++ b/StartVM.sh @@ -8,13 +8,30 @@ # 基于 Python3 的 tkinter 构建 ########################################################################################### VBoxManage showvminfo Windows -if test 0 == $?; then +if [[ 0 == $? ]]; then # 检测到虚拟机存在,启动虚拟机 VBoxManage startvm Windows exit fi +# 检查是否有 QEMU +if [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then + # 查看逻辑CPU的个数 + CpuCount=`cat /proc/cpuinfo| grep "processor"| wc -l` + + # 总内存大小GB + MemTotal=`awk '($1 == "MemTotal:"){printf "%.2f\n",$2/1024/1024}' /proc/meminfo` + use=$(echo "scale=4; $MemTotal / 3" | bc) + if [[ `arch` != "x86_64" ]]; then + echo X86 架构,使用 kvm 加速 + kvm --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G + exit + fi + echo 非 X86 架构,不使用 kvm 加速 + qemu-system-x86_64 --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G + exit +fi zenity --question --no-wrap --text="检查到您未创建所指定的虚拟机,是否创建虚拟机并继续?\n如果不创建将无法使用" -if test 1 == $?; then +if [[ 1 == $? ]]; then # 用户不想创建虚拟机,结束 exit fi diff --git a/VM-source/Makefile b/VM-source/Makefile index 21f37b8..5275064 100755 --- a/VM-source/Makefile +++ b/VM-source/Makefile @@ -221,7 +221,6 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ - .qmake.stash \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ @@ -414,7 +413,6 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ - .qmake.stash \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf \ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ @@ -587,7 +585,6 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf: -.qmake.stash: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf: diff --git a/VM/VirtualMachine b/VM/VirtualMachine new file mode 100644 index 0000000..c5bb472 --- /dev/null +++ b/VM/VirtualMachine @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +import os +import subprocess +programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string +arch = subprocess.getoutput("arch").replace(" ", "").replace("\n", "") +if os.path.exists(f"{programPath}/VirtualMachine-{arch}"): + os.system(f"{programPath}/VirtualMachine-{arch}") + exit() +# 只能使用 Qemu User 运行程序 +if os.path.exists("/usr/lib/x86_64-linux-gnu/") and not os.system("which qemu-x86_64"): + os.system(f"qemu-x86_64 '{programPath}/VirtualMachine-x86_64'") + exit() +print("未安装环境,立即安装!") +os.system(f"python3 '{programPath}/../RunCommandWithTerminal.py' '{programPath}/../InstallRuntime/amd64.sh'") \ No newline at end of file