From 5347129708fc915ac9f6392b921c7312a21a9d0a Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Sun, 18 Oct 2015 20:28:15 +0900 Subject: [PATCH] hax: expand error popup cases We had only one popup "No accelerator found." when haxm had failed to load. It was not enough to describe why users could not launch emulator clearly. So I expand the error popup strings for some cases. This patch could help users to understand their status. Change-Id: Ie4818308255be4cb4c82e0b5f790cfe365f9e0d2 Signed-off-by: Sooyoung Ha --- target-i386/hax-all.c | 41 ++++++++++++++++++++++++++++--- tizen/src/util/exported_strings.h | 18 +++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index f91706c9e6..39d874d119 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -30,6 +30,8 @@ #include "sysemu/accel.h" #include "exec/address-spaces.h" #include "qemu/main-loop.h" +#include "qemu/error-report.h" +#include "tizen/src/util/exported_strings.h" #define HAX_EMUL_ONE 0x1 #define HAX_EMUL_REAL 0x2 @@ -55,6 +57,28 @@ int ug_support = 0; bool hax_allowed; +/* for error report */ +typedef enum enum_hax_error_code { + EHAXUNKNOWN = 0, + EHAXOPENFAIL, + EHAXVTXDISABLE, + EHAXNXDISABLE, + EHAXMEMEXCEED, + EHAXINCOMPAT, + EHAXCREATEFAIL, + EHAXENUMMAX +} HAX_ERROR_CODE; +static HAX_ERROR_CODE err_code = EHAXUNKNOWN; +static const char *err_string[EHAXENUMMAX] = { + HAX_UNKNOWN, + HAX_OPENFAIL, + HAX_VTXDISABLE, + HAX_NXDISABLE, + HAX_MEMEXCEED, + HAX_INCOMPAT, + HAX_CREATEFAIL +}; + /* Called after hax_init_internal */ int hax_ug_platform(void) { @@ -162,16 +186,22 @@ static int hax_get_capability(struct hax_state *hax) struct hax_capabilityinfo capinfo, *cap = &capinfo; ret = hax_capability(hax, cap); - if (ret) + if (ret) { + err_code = EHAXOPENFAIL; return ret; + } if ( ((cap->wstatus & HAX_CAP_WORKSTATUS_MASK) == HAX_CAP_STATUS_NOTWORKING )) { - if (cap->winfo & HAX_CAP_FAILREASON_VT) + if (cap->winfo & HAX_CAP_FAILREASON_VT) { dprint("VTX feature is not enabled. which will cause HAX driver not working.\n"); - else if (cap->winfo & HAX_CAP_FAILREASON_NX) + err_code = EHAXVTXDISABLE; + } + else if (cap->winfo & HAX_CAP_FAILREASON_NX) { dprint("NX feature is not enabled, which will cause HAX driver not working.\n"); + err_code = EHAXNXDISABLE; + } return -ENXIO; } @@ -183,6 +213,7 @@ static int hax_get_capability(struct hax_state *hax) if (cap->mem_quota < hax->mem_quota) { dprint("The memory needed by this VM exceeds the driver limit.\n"); + err_code = EHAXMEMEXCEED; return -ENOSPC; } } @@ -471,6 +502,7 @@ static int hax_init_internal(void) { hax->fd = 0; ret = -ENODEV; + err_code = EHAXOPENFAIL; goto error; } @@ -488,6 +520,7 @@ static int hax_init_internal(void) dprint("Incompat Hax version. Qemu current version %x ", hax_cur_version ); dprint("requires least HAX version %x\n", hax_lest_version); ret = -EINVAL; + err_code = EHAXINCOMPAT; goto error; } @@ -496,6 +529,7 @@ static int hax_init_internal(void) { dprint("Failed to create HAX VM\n"); ret = -EINVAL; + err_code = EHAXCREATEFAIL; goto error; } @@ -513,6 +547,7 @@ error: if (hax->fd) hax_mod_close(hax); + error_report("%s\n%s", CANNOT_INITIALIZE, err_string[err_code]); return ret; } diff --git a/tizen/src/util/exported_strings.h b/tizen/src/util/exported_strings.h index e29c77f067..8b1850dce0 100644 --- a/tizen/src/util/exported_strings.h +++ b/tizen/src/util/exported_strings.h @@ -30,8 +30,8 @@ */ -#ifndef __MARU_UTIL_STRINGS_H__ -#define __MARU_UTIL_STRINGS_H__ +#ifndef __MARU_EXPORTED_STRINGS_H__ +#define __MARU_EXPORTED_STRINGS_H__ #define FAILED_TO_ALLOCATE_MEMORY "Failed to allocate memory in qemu." #define FAILED_TO_LOAD_KERNEL "Failed to load a kernel file the following path." @@ -42,6 +42,18 @@ #define FAILED_TO_INSTALL_EXTRAPACKAGE_1 "Extra package installation is failed.\n" #define FAILED_TO_INSTALL_EXTRAPACKAGE_2 " must be installed MANUALLY!" #define EMULATOR_HAS_STOPPED "Emulator has stopped working.\nA problem caused the program to stop working correctly." + +/* hax error strings */ #define NO_ACCELERATOR_FOUND "No accelerator found." +#define CANNOT_INITIALIZE "Cannot initialize HAX." +#define HAX_UNKNOWN "See the emulator.log file for details." +#define HAX_OPENFAIL "Failed to open the HAX device. It might not be installed.\n"HAX_REINSTALL +#define HAX_VTXDISABLE "VT-x feature is not enabled.\n"HAX_CHECKBIOS +#define HAX_NXDISABLE "NX(Execute Disable Bit) feature is not enabled.\n"HAX_CHECKBIOS +#define HAX_CHECKBIOS "Please check your BIOS settings." +#define HAX_MEMEXCEED "The memory needed by this VM exceeds the driver limit." +#define HAX_INCOMPAT "Incompatible version of HAX is installed.\n"HAX_REINSTALL +#define HAX_CREATEFAIL "Failed to create HAX VM.\n"HAX_UNKNOWN +#define HAX_REINSTALL "Please try to install the latest Tizen HAX driver, again." -#endif /* __MARU_UTIL_STRINGS_H__ */ +#endif /* __MARU_EXPORTED_STRINGS_H__ */ -- 2.34.1