mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 21:07:57 +00:00
Check if the HAXM service is running when starting a Qemu VM with hardware acceleration. Ref #1242.
This commit is contained in:
parent
5d704aa478
commit
d419d3fa39
@ -1764,6 +1764,12 @@ class QemuVM(BaseNode):
|
||||
if version is None:
|
||||
raise QemuError("HAXM acceleration support is not installed on this host")
|
||||
log.info("HAXM support version {} detected".format(version))
|
||||
|
||||
# check if the HAXM service is running
|
||||
from gns3server.utils.windows_service import check_windows_service_is_running
|
||||
if not check_windows_service_is_running("intelhaxm"):
|
||||
raise QemuError("Intel HAXM service is not running on this host")
|
||||
|
||||
else:
|
||||
return False
|
||||
elif sys.platform.startswith("darwin"):
|
||||
|
@ -23,6 +23,7 @@ import socket
|
||||
import struct
|
||||
import psutil
|
||||
|
||||
from .windows_service import check_windows_service_is_running
|
||||
from gns3server.config import Config
|
||||
|
||||
if psutil.version_info < (3, 0, 0):
|
||||
@ -174,23 +175,6 @@ def is_interface_bridge(interface):
|
||||
return os.path.exists(os.path.join("/sys/class/net/", interface, "bridge"))
|
||||
|
||||
|
||||
def _check_windows_service(service_name):
|
||||
|
||||
import pywintypes
|
||||
import win32service
|
||||
import win32serviceutil
|
||||
|
||||
try:
|
||||
if win32serviceutil.QueryServiceStatus(service_name, None)[1] != win32service.SERVICE_RUNNING:
|
||||
return False
|
||||
except pywintypes.error as e:
|
||||
if e.winerror == 1060:
|
||||
return False
|
||||
else:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not check if the {} service is running: {}".format(service_name, e.strerror))
|
||||
return True
|
||||
|
||||
|
||||
def interfaces():
|
||||
"""
|
||||
Gets the network interfaces on this server.
|
||||
@ -231,7 +215,7 @@ def interfaces():
|
||||
else:
|
||||
try:
|
||||
service_installed = True
|
||||
if not _check_windows_service("npf") and not _check_windows_service("npcap"):
|
||||
if not check_windows_service_is_running("npf") and not check_windows_service_is_running("npcap"):
|
||||
service_installed = False
|
||||
else:
|
||||
results = get_windows_interfaces()
|
||||
|
39
gns3server/utils/windows_service.py
Normal file
39
gns3server/utils/windows_service.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2016 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
Check for Windows service.
|
||||
"""
|
||||
|
||||
import aiohttp
|
||||
|
||||
|
||||
def check_windows_service_is_running(service_name):
|
||||
|
||||
import pywintypes
|
||||
import win32service
|
||||
import win32serviceutil
|
||||
|
||||
try:
|
||||
if win32serviceutil.QueryServiceStatus(service_name, None)[1] != win32service.SERVICE_RUNNING:
|
||||
return False
|
||||
except pywintypes.error as e:
|
||||
if e.winerror == 1060:
|
||||
return False
|
||||
else:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not check if the {} service is running: {}".format(service_name, e.strerror))
|
||||
return True
|
Loading…
Reference in New Issue
Block a user