新增虚拟机日志输出和读取功能(不使用安装器)

This commit is contained in:
gfdgd xi 2023-11-07 19:34:28 +08:00
parent 4853cafb67
commit 134fff9f17
5 changed files with 32 additions and 11 deletions

View File

@ -10,7 +10,7 @@
VBoxManage showvminfo Windows
if [[ 0 == $? ]]; then
# 检测到虚拟机存在,启动虚拟机
VBoxManage startvm Windows
VBoxManage startvm Windows > /tmp/windows-virtual-machine-installer-for-wine-runner-run.log 2>&1
exit
fi
# 检查是否有 QEMU
@ -45,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 $qemuUEFI
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 > /tmp/windows-virtual-machine-installer-for-wine-runner-run.log 2>&1
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 $qemuUEFI
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 > /tmp/windows-virtual-machine-installer-for-wine-runner-run.log 2>&1
exit
fi
zenity --question --no-wrap --text="检查到您未创建所指定的虚拟机,是否创建虚拟机并继续?\n如果不创建将无法使用"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 7.0.1, 2023-11-07T18:52:43. -->
<!-- Written by QtCreator 7.0.1, 2023-11-07T19:30:53. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -179,8 +179,8 @@
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/gfdgd_xi/Desktop/deep-wine-runner/build-VirtualMachine-unknown-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/gfdgd_xi/Desktop/deep-wine-runner/build-VirtualMachine-unknown-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/gfdgd_xi/Desktop/build-VirtualMachine-unknown-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/gfdgd_xi/Desktop/build-VirtualMachine-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -327,7 +327,7 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/gfdgd_xi/Desktop/deep-wine-runner/build-VirtualMachine-unknown-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/gfdgd_xi/Desktop/build-VirtualMachine-unknown-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@ -344,7 +344,20 @@ void MainWindow::on_actionVMLog_triggered()
return;
}
file.open(QIODevice::ReadOnly);
QInputDialog::getMultiLineText(this, "日志", "虚拟机日志",file.readAll());
QInputDialog::getMultiLineText(this, "安装日志", "虚拟机安装日志",file.readAll());
file.close();
}
void MainWindow::on_actionVMRunlLog_triggered()
{
QFile file("/tmp/windows-virtual-machine-installer-for-wine-runner-run.log");
if(!file.exists()){
QMessageBox::information(this, "提示", "没有日志文件");
return;
}
file.open(QIODevice::ReadOnly);
QInputDialog::getMultiLineText(this, "运行日志", "虚拟机运行日志",file.readAll());
file.close();
}

View File

@ -48,6 +48,8 @@ private slots:
void on_actionVMLog_triggered();
void on_actionVMRunlLog_triggered();
private:
bool stopShowTime = 0;
Ui::MainWindow *ui;

View File

@ -452,7 +452,8 @@ p, li { white-space: pre-wrap; }
<property name="title">
<string>虚拟机</string>
</property>
<addaction name="actionVMLog"/>
<addaction name="actionVMInstallLog"/>
<addaction name="actionVMRunlLog"/>
</widget>
<addaction name="menuVM"/>
</widget>
@ -476,9 +477,14 @@ p, li { white-space: pre-wrap; }
<string>导出</string>
</property>
</action>
<action name="actionVMLog">
<action name="actionVMInstallLog">
<property name="text">
<string>虚拟机日志</string>
<string>虚拟机安装日志</string>
</property>
</action>
<action name="actionVMRunlLog">
<property name="text">
<string>虚拟机运行日志</string>
</property>
</action>
</widget>