启动器图标支持启动UEFI

This commit is contained in:
gfdgd xi 2023-08-10 14:36:41 +08:00
parent e642d17828
commit db622c93ba
6 changed files with 135 additions and 95 deletions

View File

@ -22,6 +22,17 @@ if [[ $? == 0 ]] && [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then
python3 ./VM/StartQemu.py
exit
fi
if [[ -f $HOME/.config/deepin-wine-runner/QEMU-EFI ]]; then
echo 使用 UEFI 启动
if [[ -f /usr/share/qemu/OVMF.fd ]]; then
qemuUEFI="--bios /usr/share/qemu/OVMF.fd"
else
if [[ -f `dirname $0`/VM/OVMF.fd ]]; then
qemuUEFI="--bios `dirname $0`/VM/OVMF.fd"
fi
fi
echo $qemuUEFI
fi
# 查看CPU个数
CpuSocketNum=`cat /proc/cpuinfo | grep "cpu cores" | uniq | wc -l`
# 查看CPU核心数
@ -34,11 +45,11 @@ if [[ $? == 0 ]] && [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then
use=$(echo "scale=4; $MemTotal / 3" | bc)
if [[ `arch` == "x86_64" ]]; then
echo X86 架构,使用 kvm 加速
kvm -cpu host --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount,sockets=$CpuSocketNum,cores=$(($CpuCoreNum / $CpuSocketNum)),threads=$(($CpuCount / $CpuCoreNum / $CpuSocketNum)) -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139
kvm -cpu host --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount,sockets=$CpuSocketNum,cores=$(($CpuCoreNum / $CpuSocketNum)),threads=$(($CpuCount / $CpuCoreNum / $CpuSocketNum)) -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139 $qemuUEFI
exit
fi
echo 非 X86 架构,不使用 kvm 加速
qemu-system-x86_64 --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount,sockets=$CpuSocketNum,cores=$(($CpuCoreNum / $CpuSocketNum)),threads=$(($CpuCount / $CpuCoreNum / $CpuSocketNum)) -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139
qemu-system-x86_64 --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount,sockets=$CpuSocketNum,cores=$(($CpuCoreNum / $CpuSocketNum)),threads=$(($CpuCount / $CpuCoreNum / $CpuSocketNum)) -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139 $qemuUEFI
exit
fi
zenity --question --no-wrap --text="检查到您未创建所指定的虚拟机,是否创建虚拟机并继续?\n如果不创建将无法使用"

View File

@ -7,7 +7,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -77,7 +77,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -147,7 +147,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -217,7 +217,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -287,7 +287,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -357,7 +357,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -427,7 +427,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -497,7 +497,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -567,7 +567,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -637,7 +637,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -707,7 +707,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -777,7 +777,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -847,7 +847,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -917,7 +917,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -987,7 +987,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -1057,77 +1057,7 @@
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"-nostdinc",
"-nostdinc++",
"-pipe",
"-std=gnu++11",
"-Wall",
"-Wextra",
"-D_REENTRANT",
"-fPIC",
"-fsyntax-only",
"-m64",
"--target=x86_64-linux-gnu",
"-DQ_CREATOR_RUN",
"-DQT_DEPRECATED_WARNINGS",
"-DQT_NO_DEBUG",
"-DQT_WIDGETS_LIB",
"-DQT_GUI_LIB",
"-DQT_NETWORK_LIB",
"-DQT_CORE_LIB",
"-I",
"/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source",
"-I",
"/usr/include/x86_64-linux-gnu/qt5",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtGui",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtNetwork",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
"-I",
"/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++",
"-isystem",
"/usr/include/c++/11",
"-isystem",
"/usr/include/x86_64-linux-gnu/c++/11",
"-isystem",
"/usr/include/c++/11/backward",
"-isystem",
"/usr/local/include",
"-isystem",
"/usr/lib/llvm-13/lib/clang/13.0.1/include",
"-isystem",
"/usr/include/x86_64-linux-gnu",
"-isystem",
"/usr/include",
"-fmessage-length=0",
"-fdiagnostics-show-note-include-stack",
"-fretain-comments-from-system-headers",
"-fmacro-backtrace-limit=0",
"-ferror-limit=1000",
"-x",
"c++-header",
"-Wno-unknown-pragmas",
"-Wno-unknown-warning-option",
"-Wno-documentation-unknown-command",
"/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/ui_qemusetting.h"
],
"directory": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/.qtc_clangd",
"file": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/ui_qemusetting.h"
},
{
"arguments": [
"clang",
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders",
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-xhHVIb/clang-uiheader-riAtqg",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
@ -1188,5 +1118,75 @@
],
"directory": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/.qtc_clangd",
"file": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/ui_mainwindow.h"
},
{
"arguments": [
"clang",
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders",
"-I",
"/usr/share/qtcreator/cplusplus/wrappedQtHeaders/QtCore",
"-I",
"/tmp/QtCreator-qyPOGG/clang-uiheader-fvNAaR",
"-nostdinc",
"-nostdinc++",
"-pipe",
"-std=gnu++11",
"-Wall",
"-Wextra",
"-D_REENTRANT",
"-fPIC",
"-fsyntax-only",
"-m64",
"--target=x86_64-linux-gnu",
"-DQ_CREATOR_RUN",
"-DQT_DEPRECATED_WARNINGS",
"-DQT_NO_DEBUG",
"-DQT_WIDGETS_LIB",
"-DQT_GUI_LIB",
"-DQT_NETWORK_LIB",
"-DQT_CORE_LIB",
"-I",
"/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source",
"-I",
"/usr/include/x86_64-linux-gnu/qt5",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtGui",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtNetwork",
"-I",
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
"-I",
"/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++",
"-isystem",
"/usr/include/c++/11",
"-isystem",
"/usr/include/x86_64-linux-gnu/c++/11",
"-isystem",
"/usr/include/c++/11/backward",
"-isystem",
"/usr/local/include",
"-isystem",
"/usr/lib/llvm-13/lib/clang/13.0.1/include",
"-isystem",
"/usr/include/x86_64-linux-gnu",
"-isystem",
"/usr/include",
"-fmessage-length=0",
"-fdiagnostics-show-note-include-stack",
"-fretain-comments-from-system-headers",
"-fmacro-backtrace-limit=0",
"-ferror-limit=1000",
"-x",
"c++-header",
"-Wno-unknown-pragmas",
"-Wno-unknown-warning-option",
"-Wno-documentation-unknown-command",
"/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/ui_qemusetting.h"
],
"directory": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/.qtc_clangd",
"file": "/home/gfdgd_xi/Desktop/deep-wine-runner/VM-source/ui_qemusetting.h"
}
]

View File

@ -177,13 +177,29 @@ void MainWindow::on_install_clicked()
}
break;
}
QFile file(QDir::homePath() + "/.config/deepin-wine-runner/QEMU-EFI");
QDir dir(QDir::homePath() + "/.config/deepin-wine-runner");
switch (ui->systemVersion->currentIndex()) {
case 3:
if(QFile::exists("/usr/share/qemu/OVMF.fd")){
if(!QFile::exists("/usr/share/qemu/OVMF.fd") && !QFile::exists(QCoreApplication::applicationDirPath() + "/OVMF.fd") && ui->vmChooser->currentIndex() == 0){
if(QMessageBox::question(this, "提示", "似乎无法找到 UEFI 固件,是否继续创建虚拟机?\nQemu 固件可以在“安装 Qemu”处安装") == QMessageBox::No){
return;
}
}
if(!dir.exists()){
dir.mkpath(QDir::homePath() + "/.config/deepin-wine-runner");
}
if(!QFile::exists(QDir::homePath() + "/.config/deepin-wine-runner/QEMU-EFI")){
// 写入用于识别的空文件
file.open(QIODevice::WriteOnly);
file.write("1");
file.close();
}
break;
default:
if(ui->vmChooser->currentIndex() == 0 && QFile::exists(QDir::homePath() + "/.config/deepin-wine-runner/QEMU-EFI")){
QFile::remove(QDir::homePath() + "/.config/deepin-wine-runner/QEMU-EFI");
}
}
buildvbox(ui->isoPath->text(), ui->systemVersion->currentIndex(), ui->vmChooser->currentIndex());
return;

View File

@ -86,12 +86,12 @@
</item>
<item>
<property name="text">
<string>其它 Windows 系统(不支持自动安装,传统启动)</string>
<string>其它 Windows 系统(不支持自动安装,传统启动,推荐 Windows 7 及以下</string>
</property>
</item>
<item>
<property name="text">
<string>其他 Windows 系统不支持自动安装UEFI 启动)</string>
<string>其他 Windows 系统不支持自动安装UEFI 启动,推荐 Windows 8 及以上</string>
</property>
</item>
</widget>

View File

@ -120,8 +120,16 @@ int qemu::OpenUSB(){
return 0;
}
int qemu::EnabledUEFI(bool status){
if(status){
commandOption += "--bios /usr/share/qemu/OVMF.fd ";
if(!status){
return 0;
}
return 0;
if(QFile::exists("/usr/share/qemu/OVMF.fd")){
commandOption += "--bios /usr/share/qemu/OVMF.fd ";
return 0;
}
if(QFile::exists(QCoreApplication::applicationDirPath() + "/OVMF.fd")){
commandOption += "--bios '" + QCoreApplication::applicationDirPath() + "/OVMF.fd' ";
return 0;
}
return 1;
}

View File

@ -13,7 +13,7 @@ def ReadTXT(file: str):
command = "qemu-system-x86_64"
#if "--kvm" in sys.argv:
# command = "kvm"
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
homePath = os.path.expanduser('~')
try:
setting = json.loads(ReadTXT(f"{homePath}/.config/deepin-wine-runner/QemuSetting.json"))
@ -30,4 +30,9 @@ if setting["EnableVNC"]:
option += f"-display gtk -display vnc=:{setting['VNC']} "
if setting["EnableSound"]:
option += "-soundhw all "
if os.path.exists(f"{homePath}/.config/deepin-wine-runner/QEMU-EFI"):
if os.path.exists("/usr/share/qemu/OVMF.fd"):
option += "--bios /usr/share/qemu/OVMF.fd "
elif os.path.exists(f"{programPath}/OVMF.fd"):
option += f"--bios {programPath}/OVMF.fd "
os.system(f"{command} {option}")