diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 93d550ab..d6441685 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -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"): diff --git a/gns3server/utils/interfaces.py b/gns3server/utils/interfaces.py index 541697b1..e39d6a3c 100644 --- a/gns3server/utils/interfaces.py +++ b/gns3server/utils/interfaces.py @@ -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() diff --git a/gns3server/utils/windows_service.py b/gns3server/utils/windows_service.py new file mode 100644 index 00000000..7b2e2310 --- /dev/null +++ b/gns3server/utils/windows_service.py @@ -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 . + +""" +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