Check for /dev/kvm instead of kvm-ok

Fix #411
pull/412/head
Julien Duponchelle 8 years ago
parent 425a05ecd8
commit ee2104ba35

@ -49,21 +49,17 @@ 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")
kvm.append("i386")
elif arch == "i386":
kvm.append("i386")
else:
kvm.append(platform.machine())
arch = platform.machine()
if arch == "x86_64":
kvm.append("x86_64")
kvm.append("i386")
elif arch == "i386":
kvm.append("i386")
else:
kvm.append(platform.machine())
return kvm
@staticmethod

@ -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 == []

Loading…
Cancel
Save