diff options
author | Jiang, Yunhong <yunhong.jiang@intel.com> | 2012-02-23 06:31:12 +0800 |
---|---|---|
committer | Jiang, Yunhong <yunhong.jiang@intel.com> | 2012-02-23 23:11:12 +0800 |
commit | 4a5a0efd49f100c7d53920807c83d9c74304ecd8 (patch) | |
tree | 44b171204d5d07b8ec4c2788cf107fa63fd4c211 /target-i386/hax-all.c | |
parent | a3338e7214cd0c69912866c6d71d8700c6ab35e2 (diff) | |
download | external_qemu-4a5a0efd49f100c7d53920807c83d9c74304ecd8.zip external_qemu-4a5a0efd49f100c7d53920807c83d9c74304ecd8.tar.gz external_qemu-4a5a0efd49f100c7d53920807c83d9c74304ecd8.tar.bz2 |
Check HAXM capability in QEMU
Checking HAXM capability to check if emulator can use HAXM virtalization.
Currently two possibility that HAXM not work. Firstly is VT/NX is not enabled
in the system, seconly is HAXM have used up the memory quota. See code comemnts
for the memry quota explaination.
Checking the capability in advance can give user more information that why HAXM
is not working and be more user friendly.
Change-Id: I13f73734cf783398f485fabd19cce43364b571c3
Signed-off-by: Xin, Xiaohui <xiaohui.xin@intel.com>
Signed-off-by: Gao, Fengqian <fengqian.gao@intel.com>
Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
Diffstat (limited to 'target-i386/hax-all.c')
-rw-r--r-- | target-i386/hax-all.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index 18d65d0..ac919c5 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -124,6 +124,37 @@ uint32_t hax_cur_version = 0x1; /* Least HAX kernel version */ uint32_t hax_lest_version = 0x1; +static int hax_get_capability(struct hax_state *hax) +{ + int ret; + struct hax_capabilityinfo capinfo, *cap = &capinfo; + + ret = hax_capability(hax, cap); + if (ret) + return -ENOSYS; + + if ( ((cap->wstatus & HAX_CAP_WORKSTATUS_MASK) == + HAX_CAP_STATUS_NOTWORKING )) + { + if (cap->winfo & HAX_CAP_FAILREASON_VT) + dprint("VT feature is not enabled, HAXM not working.\n"); + else if (cap->winfo & HAX_CAP_FAILREASON_NX) + dprint("NX feature is not enabled, HAXM not working.\n"); + return -ENXIO; + } + + if (cap->wstatus & HAX_CAP_MEMQUOTA) + { + if (cap->mem_quota < hax->mem_quota) + { + dprint("The memory needed by this VM exceeds the driver limit.\n"); + return -ENOSPC; + } + } + + return 0; +} + static int hax_version_support(struct hax_state *hax) { int ret; @@ -297,6 +328,16 @@ int hax_vm_destroy(struct hax_vm *vm) return 0; } +int hax_set_ramsize(uint64_t ramsize) +{ + struct hax_state *hax = &hax_global; + + memset(hax, 0, sizeof(struct hax_state)); + hax->mem_quota = ram_size; + + return 0; +} + int hax_init(int smp_cpus) { struct hax_state *hax = NULL; @@ -305,7 +346,6 @@ int hax_init(int smp_cpus) hax_support = 0; hax = &hax_global; - memset(hax, 0, sizeof(struct hax_state)); hax->fd = hax_mod_open(); if (hax_invalid_fd(hax->fd)) @@ -315,6 +355,14 @@ int hax_init(int smp_cpus) goto error; } + ret = hax_get_capability(hax); + /* In case HAXM have no such capability support */ + if (ret && (ret != -ENOSYS)) + { + ret = -EINVAL; + goto error; + } + if (!hax_version_support(hax)) { dprint("Incompatible HAX version. Qemu current version %x ", hax_cur_version ); |