From 20fc7f75f25ba194e1cdeb2b81ea7fd40cb6f778 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Wed, 19 Apr 2023 21:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E4=BA=8E=E7=94=9F?= =?UTF-8?q?=E6=95=88QEMU=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=B8=9C=E4=B8=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VM/StartQemu.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 VM/StartQemu.py diff --git a/VM/StartQemu.py b/VM/StartQemu.py new file mode 100644 index 0000000..732fd0e --- /dev/null +++ b/VM/StartQemu.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import os +import sys +import json +import traceback + +def ReadTXT(file: str): + with open(file, "r") as file: + things = file.read() + return things + +# 运行 +command = "qemu-system-x86_64" +#if "--kvm" in sys.argv: +# command = "kvm" + +homePath = os.path.expanduser('~') +try: + setting = json.loads(ReadTXT(f"{homePath}/.config/deepin-wine-runner/QemuSetting.json")) +except: + print("无法读取配置") + traceback.print_exc() + sys.exit(1) +option = f"--hda \"$HOME/Qemu/Windows/Windows.qcow2\" -usb -m {setting['Memory']}M -smp {setting['CPU']} " +if setting["EnableKVM"]: + command = "kvm" +if setting["EnableRDP"]: + option += "-net user,hostfwd=tcp::3389-:3389 " +if setting["EnableVNC"]: + option += f"-display gtk -display vnc=:{setting['VNC']} " +if setting["EnableSound"]: + option += "-soundhw all " +os.system(f"{command} {option}") \ No newline at end of file