支持使用Qemu运行armhf、aarch64系统

This commit is contained in:
2023-11-11 20:53:27 +08:00
parent f5b2a3fd93
commit 47bdde1eb3
10 changed files with 239 additions and 197 deletions

View File

@@ -9,6 +9,8 @@
#include <QMessageBox>
#include <QProcess>
#include <QDebug>
#include <iostream>
using namespace std;
qemu::qemu(QString name, QString managerPath) {
if(!QFile::exists(name)){
@@ -72,11 +74,32 @@ int qemu::SetRemote(bool setting){
}
int qemu::SetRemoteConnectSetting(int port){
return 0;
}
int qemu::MountMainDisk(QString diskPath){
commandOption += " --hda '" + diskPath + "' ";
return 0;
}
int qemu::StartArmhf(){
qDebug() << commandOption;
if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "aarch64" && !system((QCoreApplication::applicationDirPath() + "/kvm-ok").toUtf8())){
return system(("qemu-system-arm --enable-kvm -cpu host -M virt " + commandOption + " -device virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
return system(("qemu-system-arm -cpu max -M virt " + commandOption + " -device virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
int qemu::StartAarch64(){
qDebug() << commandOption;
if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "aarch64" && !system((QCoreApplication::applicationDirPath() + "/kvm-ok").toUtf8())){
return system(("qemu-system-aarch64 --enable-kvm -cpu host -M virt " + commandOption + " -device virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
return system(("qemu-system-aarch64 -cpu max -M virt " + commandOption + " -device virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device usb-tablet,id=tablet,bus=xhci.0,port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
int qemu::StartLoong64(){
}
int qemu::Start(bool unShown){
qDebug() << commandOption;
if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "x86_64"){
return system(("kvm -cpu host " + commandOption + " > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "x86_64" && !system((QCoreApplication::applicationDirPath() + "/kvm-ok").toUtf8())){
return system(("qemu-system-x86_64 --enable-kvm -cpu host " + commandOption + " > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
return system(("qemu-system-x86_64 -nic model=rtl8139 " + commandOption + " > /tmp/windows-virtual-machine-installer-for-wine-runner-install.log 2>&1 &").toLatin1());
}
@@ -120,10 +143,26 @@ int qemu::OpenUSB(){
return 0;
}
int qemu::UseAarch64EFI(){
if(QFile::exists("/usr/share/qemu-efi-aarch64/QEMU_EFI.fd")){
commandOption += "--bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd ";
return 0;
}
if(QFile::exists(QCoreApplication::applicationDirPath() + "/QEMU_AARCH64_EFI.fd")){
commandOption += "--bios '" + QCoreApplication::applicationDirPath() + "/QEMU_AARCH64_EFI.fd' ";
return 0;
}
return 1;
}
int qemu::UseArmhfEFI(){
if(QFile::exists("/usr/share/AAVMF/AAVMF32_CODE.fd")){
commandOption += "--bios /usr/share/AAVMF/AAVMF32_CODE.fd ";
return 0;
}
if(QFile::exists(QCoreApplication::applicationDirPath() + "/AAVMF32_CODE.fd")){
commandOption += "--bios '" + QCoreApplication::applicationDirPath() + "/AAVMF32_CODE.fd' ";
return 0;
}
return 1;
}
int qemu::UseLoongarch64EFI(){