blob: cbeac10dd1f8da169b0c19b6a8c8b7d4e7a39893 [file] [log] [blame]
Wainer dos Santos Moschetta8b272e02019-12-16 16:14:34 -03001"""
2QEMU accel module:
3
4This module provides utilities for discover and check the availability of
5accelerators.
6"""
7# Copyright (C) 2015-2016 Red Hat Inc.
8# Copyright (C) 2012 IBM Corp.
9#
10# Authors:
11# Fam Zheng <famz@redhat.com>
12#
13# This work is licensed under the terms of the GNU GPL, version 2. See
14# the COPYING file in the top-level directory.
15#
16
17import os
18
19# Mapping host architecture to any additional architectures it can
20# support which often includes its 32 bit cousin.
21ADDITIONAL_ARCHES = {
22 "x86_64" : "i386",
23 "aarch64" : "armhf"
24}
25
26def kvm_available(target_arch=None):
27 host_arch = os.uname()[4]
28 if target_arch and target_arch != host_arch:
29 if target_arch != ADDITIONAL_ARCHES.get(host_arch):
30 return False
31 return os.access("/dev/kvm", os.R_OK | os.W_OK)