[Title] show one msgbox when kernel/bios/disk image exception
authorgiwoong.kim <giwoong.kim@samsung.com>
Fri, 4 May 2012 05:49:42 +0000 (14:49 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 4 May 2012 05:49:42 +0000 (14:49 +0900)
[Type] enhancement
[Module] Emulator
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause] error popup
[Solution]
[TestCase]

blockdev.c
hw/pc.c
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/maruskin_client.c
tizen/src/skin/maruskin_client.h
vl.c

index 222818690daa0279885b0e18a477f0d58ed9da97..d50765885e7273baa60e2530a9b48f79e4d27fcb 100644 (file)
@@ -216,6 +216,10 @@ static int parse_block_error_action(const char *buf, int is_read)
     }
 }
 
+#ifdef CONFIG_MARU
+extern int start_simple_client(char* msg);
+#endif
+
 DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
 {
     const char *buf;
@@ -518,6 +522,22 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     if (ret < 0) {
         error_report("could not open disk image %s: %s",
                      file, strerror(-ret));
+
+#ifdef CONFIG_MARU
+        const char _msg[] = "Disk image file could not load from following path\n";
+        char* current_path = (char *)g_get_current_dir();
+
+        int len = strlen(_msg) + strlen(current_path) + strlen(file) + 3;
+
+        char* error_msg = g_malloc0(len * sizeof(char));
+        snprintf(error_msg, len - 1, "%s%s/%s", _msg, current_path, file);
+
+        start_simple_client(error_msg);
+
+        g_free(current_path);
+        g_free(error_msg);
+#endif
+
         goto err;
     }
 
diff --git a/hw/pc.c b/hw/pc.c
index 0a7b5971240bc19c85c144dbae382757701c25cb..67e87bd4267a72d2222cedddc3f6bc3618479c70 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -662,6 +662,10 @@ static long get_file_size(FILE *f)
     return size;
 }
 
+#ifdef CONFIG_MARU
+extern int start_simple_client(char* msg);
+#endif
+
 static void load_linux(void *fw_cfg,
                        const char *kernel_filename,
                       const char *initrd_filename,
@@ -686,6 +690,22 @@ static void load_linux(void *fw_cfg,
        MIN(ARRAY_SIZE(header), kernel_size)) {
        fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
                kernel_filename, strerror(errno));
+
+#ifdef CONFIG_MARU
+    const char _msg[] = "Kernel image file could not load from following path\n";
+    char* current_path = (char *)g_get_current_dir();
+
+    int len = strlen(_msg) + strlen(current_path) + strlen(kernel_filename) + 3;
+
+    char* error_msg = g_malloc0(len * sizeof(char));
+    snprintf(error_msg, len - 1, "%s%s/%s", _msg, current_path, kernel_filename);
+
+    start_simple_client(error_msg);
+
+    g_free(current_path);
+    g_free(error_msg);
+#endif
+
        exit(1);
     }
 
@@ -969,6 +989,10 @@ void pc_cpus_init(const char *cpu_model)
     }
 }
 
+#ifdef CONFIG_MARU
+extern char* qemu_get_data_dir(void);
+#endif
+
 void pc_memory_init(MemoryRegion *system_memory,
                     const char *kernel_filename,
                     const char *kernel_cmdline,
@@ -1027,6 +1051,23 @@ void pc_memory_init(MemoryRegion *system_memory,
     if (ret != 0) {
     bios_error:
         fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
+
+#ifdef CONFIG_MARU
+        const char _msg[] = "Bios image file could not load from following path\n";
+        char* current_path = (char *)g_get_current_dir();
+        const char* _path = qemu_get_data_dir();
+
+        int len = strlen(_msg) + strlen(current_path) + strlen(_path) + strlen(bios_name) + 4;
+
+        char* error_msg = g_malloc0(len * sizeof(char));
+        snprintf(error_msg, len - 1, "%s%s/%s/%s", _msg, current_path, _path, bios_name);
+
+        start_simple_client(error_msg);
+
+        g_free(current_path);
+        g_free(error_msg);
+#endif
+
         exit(1);
     }
     if (filename) {
index 874cfbe293cd38d6657c4e71217bbf1fc877ee12..b13e45ae4e1350bf8975c9388953bcb55bb31d9a 100644 (file)
@@ -73,6 +73,19 @@ public class EmulatorSkinMain {
         * @param args
         */
        public static void main( String[] args ) {
+
+               String simpleMsg = getSimpleMsg(args);
+               if (simpleMsg != null) {
+                       /* just show one message box. that's all. */
+                       Shell temp = new Shell(Display.getDefault());
+                       MessageBox messageBox = new MessageBox(temp, SWT.ICON_ERROR);
+                       messageBox.setText("Emulator");
+                       messageBox.setMessage(simpleMsg);
+                       messageBox.open();
+                       temp.dispose();
+
+                       System.exit(-1);
+               }
                
                SocketCommunicator communicator = null;
                
@@ -238,6 +251,23 @@ public class EmulatorSkinMain {
                
        }
 
+       private static String getSimpleMsg( String[] args ) {
+
+               for ( int i = 0; i < args.length; i++ ) {
+                       final String simple = "simple.msg";
+                       String arg = args[i];
+                       String[] split = arg.split( "=" );
+                       if ( 1 < split.length ) {
+                               if ( simple.equals( split[0].trim() ) ) {
+                                       return split[1].trim();
+                               }
+                       }
+               }
+
+               return null;
+
+       }
+
        private static String getVmPath( String[] args ) {
 
                for ( int i = 0; i < args.length; i++ ) {
index b45ddce9af98ae6cfa3b9a90aba2c4cecc0194e9..458c6542d3a829ea9ebbffb6b975dd9797473b2c 100644 (file)
 #include <windows.h>
 #endif
 
+MULTI_DEBUG_CHANNEL(qemu, maruskin_client);
+
+
+
 #define SKIN_SERVER_READY_TIME 3 // second
 #define SKIN_SERVER_SLEEP_TIME 10 // milli second
 
 #define OPT_VM_PATH "vm.path"
 #define OPT_NET_BASE_PORT "net.baseport"
 
-MULTI_DEBUG_CHANNEL( qemu, maruskin_client );
+#define MAX_COMMAND 512
 
 static int skin_argc;
 static char** skin_argv;
 
 static void* run_skin_client(void* arg)
 {
-    char cmd[512] = {0};
+    char cmd[MAX_COMMAND] = {0};
     char argv[256] = {0};
 
     INFO("run skin client\n");
@@ -75,7 +79,7 @@ static void* run_skin_client(void* arg)
 
     int skin_server_port = get_skin_server_port();
 
-    srand( time( NULL ) );
+    //srand( time( NULL ) );
     int uid = 0; //rand();
     //INFO( "generated skin uid:%d\n", uid );
 
@@ -91,9 +95,7 @@ static void* run_skin_client(void* arg)
     INFO( "command for swt : %s\n", cmd );
 
 #ifdef _WIN32
-#if 0
-    WinExec( cmd, SW_SHOW );
-#else
+    //WinExec( cmd, SW_SHOW );
     {
         STARTUPINFO sti = { 0 };
         PROCESS_INFORMATION pi = { 0 };
@@ -145,7 +147,6 @@ static void* run_skin_client(void* arg)
         }
     }
 
-#endif
 #else //ifndef _WIN32
     int ret = system(cmd);
 
@@ -214,3 +215,24 @@ int start_skin_client(int argc, char* argv[])
     return 1;
 }
 
+
+int start_simple_client(char* msg) {
+    int ret = 0;
+    char cmd[MAX_COMMAND] = {0};
+
+    INFO("run simple client\n");
+
+    sprintf(cmd, "%s %s %s %s=\"%s\"", JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAR_SKINFILE_PATH, "simple.msg", msg);
+    INFO("command for swt : %s\n", cmd);
+
+#ifdef __WIN32
+    ret = WinExec(cmd, SW_SHOW);
+#else
+    ret = system(cmd);
+#endif
+
+    INFO("child return value : %d\n", ret);
+
+    return 1;
+}
+
index b8ace6435c3aed2be91a467ecd1625580c8a812a..0b832d7d1ffa5c2d822853fa6b03bfbcf6cc8c0a 100644 (file)
@@ -31,5 +31,7 @@
 #define MARUSKIN_CLIENT_H_
 
 int start_skin_client(int argc, char* argv[]);
+int start_simple_client(char* msg);
+
 
 #endif /* MARUSKIN_CLIENT_H_ */
diff --git a/vl.c b/vl.c
index 505d41868a7e39e0ada0fde823cce73fadd86b5a..303643fc507db64d93db6db522402b01dc0ffb9d 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1772,6 +1772,15 @@ char *qemu_find_file(int type, const char *name)
     return buf;
 }
 
+#ifdef CONFIG_MARU
+const char *qemu_get_data_dir(void);
+
+const char *qemu_get_data_dir(void)
+{
+    return data_dir;
+}
+#endif
+
 static int device_help_func(QemuOpts *opts, void *opaque)
 {
     return qdev_device_help(opts);