From b3cbfeddc8c64fa1a2865da7a9860315b0ae69f9 Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Fri, 4 May 2012 14:49:42 +0900 Subject: [PATCH] [Title] show one msgbox when kernel/bios/disk image exception [Type] enhancement [Module] Emulator [Priority] [Jira#] [Redmine#] [Problem] [Cause] error popup [Solution] [TestCase] --- blockdev.c | 20 +++++++++ hw/pc.c | 41 +++++++++++++++++++ .../tizen/emulator/skin/EmulatorSkinMain.java | 30 ++++++++++++++ tizen/src/skin/maruskin_client.c | 36 ++++++++++++---- tizen/src/skin/maruskin_client.h | 2 + vl.c | 9 ++++ 6 files changed, 131 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index 222818690d..d50765885e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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 0a7b597124..67e87bd426 100644 --- 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) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java index 874cfbe293..b13e45ae4e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java @@ -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++ ) { diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index b45ddce9af..458c6542d3 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -43,6 +43,10 @@ #include #endif +MULTI_DEBUG_CHANNEL(qemu, maruskin_client); + + + #define SKIN_SERVER_READY_TIME 3 // second #define SKIN_SERVER_SLEEP_TIME 10 // milli second @@ -55,14 +59,14 @@ #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; +} + diff --git a/tizen/src/skin/maruskin_client.h b/tizen/src/skin/maruskin_client.h index b8ace6435c..0b832d7d1f 100644 --- a/tizen/src/skin/maruskin_client.h +++ b/tizen/src/skin/maruskin_client.h @@ -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 505d41868a..303643fc50 100644 --- 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); -- 2.34.1