Fix Key Error "vendor_id" is missing when configuring GNS3 VM with VirtualBox. Fixes https://github.com/GNS3/gns3-gui/issues/3018

This commit is contained in:
grossmj 2020-07-10 17:44:38 +09:30
parent c40651b53e
commit 99128e7713
3 changed files with 11 additions and 2 deletions

View File

@ -92,7 +92,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
raise VirtualBoxError("Can't access to VirtualBox API version:\n{}".format(self._system_properties))
from cpuinfo import get_cpu_info
cpu_info = await wait_run_in_executor(get_cpu_info)
vendor_id = cpu_info['vendor_id']
vendor_id = cpu_info.get('vendor_id_raw')
if vendor_id == "GenuineIntel":
if parse_version(self._system_properties["API version"]) < parse_version("6_1"):
raise VirtualBoxError("VirtualBox version 6.1 or above is required to run the GNS3 VM with nested virtualization enabled on Intel processors")

View File

@ -7,4 +7,4 @@ sentry-sdk>=0.14.4
psutil==5.7.0
async-timeout==3.0.1
distro>=1.3.0
py-cpuinfo==6.0.0
py-cpuinfo==7.0.0

View File

@ -19,6 +19,7 @@ import pytest
import asyncio
from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.utils.asyncio import wait_run_in_executor
from unittest.mock import patch
from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM
@ -65,3 +66,11 @@ GuestMemoryBalloon=0
# res = await gns3vm._look_for_interface("dummy")
# assert mock.called
# assert res == -1
async def test_cpu_vendor_id(gns3vm):
from cpuinfo import get_cpu_info
cpu_info = await wait_run_in_executor(get_cpu_info)
vendor_id = cpu_info.get('vendor_id_raw')
assert vendor_id # vendor id should not be empty