修复QEMU安装XP无网络的问题

This commit is contained in:
gfdgd xi 2023-04-29 08:57:35 +08:00
parent 0d3e798644
commit 5443654791
4 changed files with 7 additions and 7 deletions

View File

@ -29,11 +29,11 @@ if [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then
use=$(echo "scale=4; $MemTotal / 3" | bc) use=$(echo "scale=4; $MemTotal / 3" | bc)
if [[ `arch` == "x86_64" ]]; then if [[ `arch` == "x86_64" ]]; then
echo X86 架构,使用 kvm 加速 echo X86 架构,使用 kvm 加速
kvm --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb kvm --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139
exit exit
fi fi
echo 非 X86 架构,不使用 kvm 加速 echo 非 X86 架构,不使用 kvm 加速
qemu-system-x86_64 --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb qemu-system-x86_64 --hda "$HOME/Qemu/Windows/Windows.qcow2" -soundhw all -smp $CpuCount -m ${use}G -net user,hostfwd=tcp::3389-:3389 -display vnc=:5 -display gtk -usb -nic model=rtl8139
exit exit
fi fi
zenity --question --no-wrap --text="检查到您未创建所指定的虚拟机,是否创建虚拟机并继续?\n如果不创建将无法使用" zenity --question --no-wrap --text="检查到您未创建所指定的虚拟机,是否创建虚拟机并继续?\n如果不创建将无法使用"
@ -42,4 +42,4 @@ if [[ 1 == $? ]]; then
exit exit
fi fi
cd `dirname $0` cd `dirname $0`
./VM/VirtualMachine ./VM/VirtualMachine

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2023-04-22T21:23:25. --> <!-- Written by QtCreator 4.8.2, 2023-04-28T23:27:18. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -72,7 +72,7 @@ int qemu::Start(bool unShown){
if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "x86_64"){ if(Command().GetCommand("arch").replace("\n", "").replace(" ", "") == "x86_64"){
return system(("kvm " + commandOption + " &").toLatin1()); return system(("kvm " + commandOption + " &").toLatin1());
} }
return system(("qemu-system-x86_64 " + commandOption + " &").toLatin1()); return system(("qemu-system-x86_64 -nic model=rtl8139 " + commandOption + " &").toLatin1());
} }
int qemu::Stop(){ int qemu::Stop(){
system("killall qemu-system-x86_64 -9"); system("killall qemu-system-x86_64 -9");

View File

@ -21,7 +21,7 @@ except:
print("无法读取配置") print("无法读取配置")
traceback.print_exc() traceback.print_exc()
sys.exit(1) sys.exit(1)
option = f"--hda \"$HOME/Qemu/Windows/Windows.qcow2\" -usb -m {setting['Memory']}M -smp {setting['CPU']} " option = f"-nic model=rtl8139 --hda \"$HOME/Qemu/Windows/Windows.qcow2\" -usb -m {setting['Memory']}M -smp {setting['CPU']} "
if setting["EnableKVM"]: if setting["EnableKVM"]:
command = "kvm" command = "kvm"
if setting["EnableRDP"]: if setting["EnableRDP"]:
@ -30,4 +30,4 @@ if setting["EnableVNC"]:
option += f"-display gtk -display vnc=:{setting['VNC']} " option += f"-display gtk -display vnc=:{setting['VNC']} "
if setting["EnableSound"]: if setting["EnableSound"]:
option += "-soundhw all " option += "-soundhw all "
os.system(f"{command} {option}") os.system(f"{command} {option}")