新增UEFI支持

This commit is contained in:
2023-08-10 13:21:30 +08:00
parent cd356e5f7f
commit 056a30c29d
13 changed files with 1570 additions and 375 deletions

View File

@@ -12,6 +12,7 @@
#include <QCoreApplication>
#include <infoutils.h>
#include "qemu.h"
#include <QProcess>
// 懒得用 QThread 了(要继承)
#include <thread>
using namespace std;
@@ -27,6 +28,37 @@ void buildvbox::CleanScreen(){
system("cls");
}
// 获取 CPU 个数
int buildvbox::GetCPUSocket(){
// 获取命令返回值
QProcess process;
process.start("bash", QStringList() << "-c" << "cat /proc/cpuinfo | grep \"cpu cores\" | uniq | wc -l");
process.waitForStarted();
process.waitForFinished();
int value = process.readAllStandardOutput().toInt();
process.close();
// 判断异常值,例如没挂载 /proc
if(value <= 0){
value = 1;
}
return value;
}
// 获取 CPU 核心数
int buildvbox::GetCPUCore(){
QProcess process;
process.start("bash", QStringList() << "-c" << "grep 'core id' /proc/cpuinfo | sort -u | wc -l");
process.waitForStarted();
process.waitForFinished();
int value = process.readAllStandardOutput().toInt();
process.close();
// 判断异常值,例如没挂载 /proc
if(value <= 0){
value = 1;
}
return value;
}
QString buildvbox::GetNet(){
QList<QNetworkInterface> netList = QNetworkInterface::allInterfaces();
foreach(QNetworkInterface net, netList){
@@ -82,7 +114,13 @@ buildvbox::buildvbox(QString isoPath, int id, int vm){
case 1:
vm.Create("Windows7_64");
break;
vm.Create("WindowsNT_64");
case 2:
vm.Create("WindowsNT_64");
break;
case 3:
vm.Create("WindowsNT_64");
vm.EnabledUEFI(true);
break;
}
vm.CreateDiskControl();
//vm.CreateDiskControl("storage_controller_2");
@@ -112,7 +150,7 @@ buildvbox::buildvbox(QString isoPath, int id, int vm){
vm.MountISO("/usr/share/virtualbox/VBoxGuestAdditions.iso", "storage_controller_1", 1, 1);
}*/
vm.SetCPU(get_nprocs());
vm.SetCPU(get_nprocs(), GetCPUSocket(), GetCPUCore());
long memory = 0;
long memoryAll = 0;
long swap = 0;
@@ -146,7 +184,13 @@ buildvbox::buildvbox(QString isoPath, int id, int vm){
case 1:
vm.Create("Windows7_64");
break;
vm.Create("WindowsNT_64");
case 2:
vm.Create("WindowsNT_64");
break;
case 3:
vm.Create("WindowsNT_64");
vm.EnabledUEFI(true);
break;
}
QDir dir("/home/gfdgd_xi/Qemu/Windows/");
dir.mkpath("/home/gfdgd_xi/Qemu/Windows/");
@@ -170,7 +214,7 @@ buildvbox::buildvbox(QString isoPath, int id, int vm){
vm.MountISO("/usr/share/virtualbox/VBoxGuestAdditions.iso", "storage_controller_1", 1, 1);
}
vm.SetCPU(get_nprocs_conf());
vm.SetCPU(get_nprocs(), GetCPUSocket(), GetCPUCore());
long memory = 0;
long memoryAll = 0;
long swap = 0;