]>
Commit | Line | Data |
---|---|---|
66613974 DB |
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 | ||
4738b0a8 | 15 | import logging |
66613974 | 16 | import os |
66613974 | 17 | |
8f8fd9ed | 18 | from . import qmp |
abf0bf99 | 19 | from . import machine |
66613974 | 20 | |
4738b0a8 AP |
21 | LOG = logging.getLogger(__name__) |
22 | ||
2d4e4c01 AB |
23 | # Mapping host architecture to any additional architectures it can |
24 | # support which often includes its 32 bit cousin. | |
25 | ADDITIONAL_ARCHES = { | |
26 | "x86_64" : "i386", | |
27 | "aarch64" : "armhf" | |
28 | } | |
4738b0a8 | 29 | |
b59b82ed | 30 | def kvm_available(target_arch=None): |
2d4e4c01 AB |
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 | |
b59b82ed | 35 | return os.access("/dev/kvm", os.R_OK | os.W_OK) |