mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
Prevent starting different hypervisors that leverage hardware virtualization (VT-x/AMD-V). Fixes #548.
This commit is contained in:
parent
eb5e019a26
commit
fcd4fda68e
@ -152,7 +152,7 @@ class QEMUHandler:
|
|||||||
and "-no-kvm" not in vm.options:
|
and "-no-kvm" not in vm.options:
|
||||||
pm = ProjectManager.instance()
|
pm = ProjectManager.instance()
|
||||||
if pm.check_hardware_virtualization(vm) is False:
|
if pm.check_hardware_virtualization(vm) is False:
|
||||||
raise HTTPConflict(text="Cannot start VM with KVM enabled because hardware virtualization is already used by another software like VMware or VirtualBox")
|
raise HTTPConflict(text="Cannot start VM with KVM enabled because hardware virtualization (VT-x/AMD-V) is already used by another software like VMware or VirtualBox")
|
||||||
yield from vm.start()
|
yield from vm.start()
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@ -192,10 +192,10 @@ class VirtualBoxHandler:
|
|||||||
|
|
||||||
vbox_manager = VirtualBox.instance()
|
vbox_manager = VirtualBox.instance()
|
||||||
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
||||||
if sys.platform.startswith("linux") and (yield from vm.check_hw_virtualization()):
|
if (yield from vm.check_hw_virtualization()):
|
||||||
pm = ProjectManager.instance()
|
pm = ProjectManager.instance()
|
||||||
if pm.check_hardware_virtualization(vm) is False:
|
if pm.check_hardware_virtualization(vm) is False:
|
||||||
raise HTTPConflict(text="Cannot start VM because KVM is being used by a Qemu VM")
|
raise HTTPConflict(text="Cannot start VM because hardware virtualization (VT-x/AMD-V) is already used by another software like VMware or KVM (on Linux)")
|
||||||
yield from vm.start()
|
yield from vm.start()
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@ -160,6 +160,10 @@ class VMwareHandler:
|
|||||||
|
|
||||||
vmware_manager = VMware.instance()
|
vmware_manager = VMware.instance()
|
||||||
vm = vmware_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
vm = vmware_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
||||||
|
if vm.check_hw_virtualization():
|
||||||
|
pm = ProjectManager.instance()
|
||||||
|
if pm.check_hardware_virtualization(vm) is False:
|
||||||
|
raise HTTPConflict(text="Cannot start VM because hardware virtualization (VT-x/AMD-V) is already used by another software like VirtualBox or KVM (on Linux)")
|
||||||
yield from vm.start()
|
yield from vm.start()
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@ -103,19 +103,10 @@ class ProjectManager:
|
|||||||
:returns: boolean
|
:returns: boolean
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .qemu import QemuVM
|
|
||||||
from .virtualbox import VirtualBoxVM
|
|
||||||
from .vmware import VMwareVM
|
|
||||||
for project in self._projects.values():
|
for project in self._projects.values():
|
||||||
for vm in project.vms:
|
for vm in project.vms:
|
||||||
if vm == source_vm:
|
if vm == source_vm:
|
||||||
continue
|
continue
|
||||||
if vm.hw_virtualization:
|
if vm.hw_virtualization and vm.__class__.__name__ != source_vm.__class__.__name__:
|
||||||
if isinstance(source_vm, QemuVM) and not isinstance(vm, QemuVM):
|
|
||||||
# A Qemu VM won't start if any other virtualization software uses hardware virtualization
|
|
||||||
return False
|
return False
|
||||||
elif isinstance(source_vm, VirtualBoxVM) and not isinstance(vm, VirtualBoxVM) and not isinstance(vm, VMwareVM):
|
|
||||||
# A VirtualBox VM won't start if KVM is being used
|
|
||||||
return False
|
|
||||||
# VMware doesn't seem to be bothered by any other virtualization software.
|
|
||||||
return True
|
return True
|
||||||
|
@ -344,6 +344,22 @@ class VMwareVM(BaseVM):
|
|||||||
if parse_version(self._ubridge_hypervisor.version) < parse_version('0.9.1'):
|
if parse_version(self._ubridge_hypervisor.version) < parse_version('0.9.1'):
|
||||||
raise VMwareError("uBridge version must be >= 0.9.1, detected version is {}".format(self._ubridge_hypervisor.version))
|
raise VMwareError("uBridge version must be >= 0.9.1, detected version is {}".format(self._ubridge_hypervisor.version))
|
||||||
|
|
||||||
|
def check_hw_virtualization(self):
|
||||||
|
"""
|
||||||
|
Returns either hardware virtualization is activated or not.
|
||||||
|
|
||||||
|
:returns: boolean
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._vmx_pairs = self.manager.parse_vmware_file(self._vmx_path)
|
||||||
|
except OSError as e:
|
||||||
|
raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._vmx_path, e))
|
||||||
|
|
||||||
|
if self._get_vmx_setting("vhv.enable", "TRUE"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user