diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2012-02-23 07:31:23 -0800 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-02-23 07:31:25 -0800 |
commit | 1991d8c2b6b85170ee1707ca19fe5c746187a77c (patch) | |
tree | bcbc52ee128f47fb1d05e200402e60f197a33e25 /target-i386/hax-all.c | |
parent | 1533b3ad6f215e3727ba081ebf6c170c22794c3c (diff) | |
parent | 4a5a0efd49f100c7d53920807c83d9c74304ecd8 (diff) | |
download | external_qemu-1991d8c2b6b85170ee1707ca19fe5c746187a77c.zip external_qemu-1991d8c2b6b85170ee1707ca19fe5c746187a77c.tar.gz external_qemu-1991d8c2b6b85170ee1707ca19fe5c746187a77c.tar.bz2 |
Merge "Check HAXM capability in QEMU"
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 c8f4cec..0c3b589 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; @@ -296,6 +327,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; @@ -304,7 +345,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)) @@ -314,6 +354,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 ); |