1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Check for /dev/kvm instead of kvm-ok

Fix #411
This commit is contained in:
Julien Duponchelle 2016-01-26 13:57:55 +01:00
parent 425a05ecd8
commit ee2104ba35
2 changed files with 14 additions and 16 deletions

View File

@ -49,13 +49,9 @@ class Qemu(BaseManager):
"""
kvm = []
try:
process = yield from asyncio.create_subprocess_exec("kvm-ok")
yield from process.wait()
except OSError:
if not os.path.exists("/dev/kvm"):
return kvm
if process.returncode == 0:
arch = platform.machine()
if arch == "x86_64":
kvm.append("x86_64")

View File

@ -185,11 +185,13 @@ def test_get_kvm_archs_no_kvm(loop):
def test_get_kvm_archs_kvm_ok(loop):
process = MagicMock()
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
process.returncode = 0
with patch("os.path.exists", return_value=True):
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
if platform.machine() == 'x86_64':
assert archs == ['x86_64', 'i386']
else:
assert archs == platform.machine()
with patch("os.path.exists", return_value=False):
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
assert archs == []