hax: expand error popup cases
authorSooyoung Ha <yoosah.ha@samsung.com>
Sun, 18 Oct 2015 11:28:15 +0000 (20:28 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 27 Oct 2015 08:46:01 +0000 (17:46 +0900)
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 <yoosah.ha@samsung.com>
target-i386/hax-all.c
tizen/src/util/exported_strings.h

index f91706c9e6974a90c6525ec705aee55496f4bad2..39d874d1196230cc8eb00ff5d8bdc4ff60497433 100644 (file)
@@ -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;
 }
 
index e29c77f067ba975ac5638d13f431a426ec7557f8..8b1850dce01d63e9bdec6778e32bab2b7df64d71 100644 (file)
@@ -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."
 #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__ */