1# QEMU library 2# 3# Copyright (C) 2015-2016 Red Hat Inc. 4# Copyright (C) 2012 IBM Corp. 5# 6# Authors: 7# Fam Zheng <famz@redhat.com> 8# 9# This work is licensed under the terms of the GNU GPL, version 2. See 10# the COPYING file in the top-level directory. 11# 12# Based on qmp.py. 13# 14 15import logging 16import os 17 18from . import qmp 19from . import machine 20 21LOG = logging.getLogger(__name__) 22 23# Mapping host architecture to any additional architectures it can 24# support which often includes its 32 bit cousin. 25ADDITIONAL_ARCHES = { 26 "x86_64" : "i386", 27 "aarch64" : "armhf" 28} 29 30def kvm_available(target_arch=None): 31 host_arch = os.uname()[4] 32 if target_arch and target_arch != host_arch: 33 if target_arch != ADDITIONAL_ARCHES.get(host_arch): 34 return False 35 return os.access("/dev/kvm", os.R_OK | os.W_OK) 36