mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
parent
425a05ecd8
commit
ee2104ba35
@ -49,21 +49,17 @@ class Qemu(BaseManager):
|
|||||||
"""
|
"""
|
||||||
kvm = []
|
kvm = []
|
||||||
|
|
||||||
try:
|
if not os.path.exists("/dev/kvm"):
|
||||||
process = yield from asyncio.create_subprocess_exec("kvm-ok")
|
|
||||||
yield from process.wait()
|
|
||||||
except OSError:
|
|
||||||
return kvm
|
return kvm
|
||||||
|
|
||||||
if process.returncode == 0:
|
arch = platform.machine()
|
||||||
arch = platform.machine()
|
if arch == "x86_64":
|
||||||
if arch == "x86_64":
|
kvm.append("x86_64")
|
||||||
kvm.append("x86_64")
|
kvm.append("i386")
|
||||||
kvm.append("i386")
|
elif arch == "i386":
|
||||||
elif arch == "i386":
|
kvm.append("i386")
|
||||||
kvm.append("i386")
|
else:
|
||||||
else:
|
kvm.append(platform.machine())
|
||||||
kvm.append(platform.machine())
|
|
||||||
return kvm
|
return kvm
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -185,11 +185,13 @@ def test_get_kvm_archs_no_kvm(loop):
|
|||||||
|
|
||||||
def test_get_kvm_archs_kvm_ok(loop):
|
def test_get_kvm_archs_kvm_ok(loop):
|
||||||
|
|
||||||
process = MagicMock()
|
with patch("os.path.exists", return_value=True):
|
||||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
|
|
||||||
process.returncode = 0
|
|
||||||
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
|
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
|
||||||
if platform.machine() == 'x86_64':
|
if platform.machine() == 'x86_64':
|
||||||
assert archs == ['x86_64', 'i386']
|
assert archs == ['x86_64', 'i386']
|
||||||
else:
|
else:
|
||||||
assert archs == platform.machine()
|
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 == []
|
||||||
|
Loading…
Reference in New Issue
Block a user