mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 15:33:49 +02:00
Tweaks to support Qemu on Windows.
This commit is contained in:
parent
aca9e0de56
commit
e7141685cc
@ -19,6 +19,7 @@
|
|||||||
QEMU server module.
|
QEMU server module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import shutil
|
import shutil
|
||||||
@ -43,15 +44,6 @@ from .schemas import QEMU_ALLOCATE_UDP_PORT_SCHEMA
|
|||||||
from .schemas import QEMU_ADD_NIO_SCHEMA
|
from .schemas import QEMU_ADD_NIO_SCHEMA
|
||||||
from .schemas import QEMU_DELETE_NIO_SCHEMA
|
from .schemas import QEMU_DELETE_NIO_SCHEMA
|
||||||
|
|
||||||
QEMU_BINARIES = ["qemu.exe",
|
|
||||||
"qemu-system-arm",
|
|
||||||
"qemu-system-mips",
|
|
||||||
"qemu-system-ppc",
|
|
||||||
"qemu-system-sparc",
|
|
||||||
"qemu-system-x86",
|
|
||||||
"qemu-system-i386",
|
|
||||||
"qemu-system-x86_64"]
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -603,6 +595,8 @@ class Qemu(IModule):
|
|||||||
:param qemu_path: path to Qemu
|
:param qemu_path: path to Qemu
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
return ""
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output([qemu_path, "--version"])
|
output = subprocess.check_output([qemu_path, "--version"])
|
||||||
match = re.search("QEMU emulator version ([0-9a-z\-\.]+)", output.decode("utf-8"))
|
match = re.search("QEMU emulator version ([0-9a-z\-\.]+)", output.decode("utf-8"))
|
||||||
@ -627,11 +621,18 @@ class Qemu(IModule):
|
|||||||
qemus = []
|
qemus = []
|
||||||
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
||||||
# look for Qemu binaries in the current working directory and $PATH
|
# look for Qemu binaries in the current working directory and $PATH
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
# add specific Windows paths
|
||||||
|
paths.append(os.path.join(os.getcwd(), "qemu"))
|
||||||
|
if "PROGRAMFILES(X86)" in os.environ and os.path.exists(os.environ["PROGRAMFILES(X86)"]):
|
||||||
|
paths.append(os.path.join(os.environ["PROGRAMFILES(X86)"], "qemu"))
|
||||||
|
if "PROGRAMFILES" in os.environ and os.path.exists(os.environ["PROGRAMFILES"]):
|
||||||
|
paths.append(os.path.join(os.environ["PROGRAMFILES"], "qemu"))
|
||||||
for path in paths:
|
for path in paths:
|
||||||
for qemu_binary in QEMU_BINARIES:
|
|
||||||
try:
|
try:
|
||||||
if qemu_binary in os.listdir(path) and os.access(os.path.join(path, qemu_binary), os.X_OK):
|
for f in os.listdir(path):
|
||||||
qemu_path = os.path.join(path, qemu_binary)
|
if f.startswith("qemu-system") and os.access(os.path.join(path, f), os.X_OK):
|
||||||
|
qemu_path = os.path.join(path, f)
|
||||||
version = self._get_qemu_version(qemu_path)
|
version = self._get_qemu_version(qemu_path)
|
||||||
qemus.append({"path": qemu_path, "version": version})
|
qemus.append({"path": qemu_path, "version": version})
|
||||||
except OSError:
|
except OSError:
|
||||||
|
Loading…
Reference in New Issue
Block a user