]>
Commit | Line | Data |
---|---|---|
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 | ||
15 | import logging | |
16 | import os | |
17 | ||
18 | from . import qmp | |
19 | from . import machine | |
20 | ||
21 | LOG = logging.getLogger(__name__) | |
22 | ||
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 | } | |
29 | ||
30 | def 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) |