Wainer dos Santos Moschetta | 8b272e0 | 2019-12-16 16:14:34 -0300 | [diff] [blame^] | 1 | """ |
| 2 | QEMU accel module: |
| 3 | |
| 4 | This module provides utilities for discover and check the availability of |
| 5 | accelerators. |
| 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 | |
| 17 | import os |
| 18 | |
| 19 | # Mapping host architecture to any additional architectures it can |
| 20 | # support which often includes its 32 bit cousin. |
| 21 | ADDITIONAL_ARCHES = { |
| 22 | "x86_64" : "i386", |
| 23 | "aarch64" : "armhf" |
| 24 | } |
| 25 | |
| 26 | def 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) |