From df05d3d38c91b8865f7ba6dc828dc4e96623da54 Mon Sep 17 00:00:00 2001 From: SeokYeon Hwang Date: Mon, 17 Aug 2015 15:42:15 +0900 Subject: [PATCH] emul_state: divided up log path "emulator log path" and "kernel log path" can be different. So we divided up log path and dealed with log file instead of log path. Change-Id: I23b28d6132790b4774291810e09f95cdb5f4a633 Signed-off-by: SeokYeon Hwang --- tizen/src/emul_state.c | 50 +++++++++++++++++++----- tizen/src/emul_state.h | 6 +-- tizen/src/skin/maruskin_operation.c | 4 +- tizen/src/ui/menu/detailedinfodialog.cpp | 16 +++++--- tizen/src/ui/resource/ui_strings.h | 3 +- 5 files changed, 60 insertions(+), 19 deletions(-) diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 974ccd9b2a..42d0afaac9 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -366,15 +366,40 @@ const char *get_bin_path(void) return bin_path; } -// log path -static const char *log_redirect_path; +// emulator kernel log file +static const char *kernel_log_redirect_file; + +const char *get_kernel_log_redirect_file(void) +{ + // TODO: kernel log path should be aquired from char device. + if (kernel_log_redirect_file) { + return kernel_log_redirect_file; + } + + char *vms_path = get_variable("vms_path"); + char *vm_name = get_variable("vm_name"); + if (!vms_path || !vm_name) { + // we can not specify log path. + // emulator may not be launched from emulator-manager. + kernel_log_redirect_file = g_strdup(""); + } + else { + kernel_log_redirect_file = + g_strdup_printf("%s/%s/logs/emulator.klog", vms_path, vm_name); + } + + return kernel_log_redirect_file; +} + +// emulator log file +static const char *log_redirect_file; #ifdef CONFIG_WIN32 -// for Windows version +// for checking Windows version extern OSVERSIONINFO osvi; #endif -const char *get_log_redirect_path(void) +const char *get_log_redirect_file(void) { #ifdef SUPPORT_LEGACY_ARGS if (log_path[0]) { @@ -387,6 +412,9 @@ const char *get_log_redirect_path(void) // should we compare stdout(fd/1) and stderr(fd/2) ?? #if defined(CONFIG_LINUX) result = readlink("/proc/self/fd/1", log_filename, PATH_MAX); + if (result >= 0) { + log_filename[result] = '\0'; + } #elif defined(CONFIG_DARWIN) result = fcntl(STDOUT_FILENO, F_GETPATH, log_filename); #elif defined(CONFIG_WIN32) @@ -408,8 +436,12 @@ const char *get_log_redirect_path(void) } # endif #endif + if (log_redirect_file) { + g_free((void *)log_redirect_file); + } + if (result >= 0) { - log_redirect_path = g_path_get_dirname(log_filename); + log_redirect_file = g_strdup(log_filename); } else { // fail safe LOG_WARNING("Can not identify log redirection path, " @@ -420,15 +452,15 @@ const char *get_log_redirect_path(void) if (!vms_path || !vm_name) { // we can not specify log path. // emulator may not be launched from emulator-manager. - log_redirect_path = ""; + log_redirect_file = g_strdup(""); } else { - log_redirect_path = g_strdup_printf("%s/%s/logs", - vms_path, vm_name); + log_redirect_file = + g_strdup_printf("%s/%s/logs/emulator.log", vms_path, vm_name); } } - return log_redirect_path; + return log_redirect_file; } diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 8f108a823c..45bbdae3a5 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -126,9 +126,6 @@ typedef struct EmulatorConfigState { extern char log_path[]; #endif -char const *get_bin_path(void); -char const *get_log_redirect_path(void); - /* setter */ void set_emul_win_scale(double scale); void set_emul_sdl_bpp(int bpp); @@ -180,6 +177,9 @@ extern const char *bin_path; extern int initial_resolution_width; extern int initial_resolution_height; +char const *get_bin_path(void); +char const *get_log_redirect_file(void); +char const *get_kernel_log_redirect_file(void); const char *get_drive_image_file(void); const char *get_http_proxy_addr(void); const char *get_vm_name(void); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 7245c175e7..10033ba576 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -381,7 +381,7 @@ DetailInfo* get_detail_info(int qemu_argc, char** qemu_argv) /* collect log path information */ #define LOGPATH_TEXT "log_path=" - const char* log_path = get_log_redirect_path(); + char* log_path = g_path_get_dirname(get_log_redirect_file()); int log_path_len = strlen(LOGPATH_TEXT) + strlen(log_path) + delimiter_len; total_len += (log_path_len + 1); @@ -418,6 +418,8 @@ DetailInfo* get_detail_info(int qemu_argc, char** qemu_argv) detail_info->data = info_data; detail_info->data_length = total_len; + g_free(log_path); + return detail_info; } diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 0f4f9c055f..bf7e81f60f 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -149,8 +149,13 @@ QTableWidget *DetailedInfoDialog::createVmInfoTable() QString(imagePathList[i])); } - insertTableRow(vmInfoTable, QString(DETAILED_INFO_LOG_PATH), - QString(get_log_redirect_path()), QString(get_log_redirect_path())); + QString log_redirect_file(get_log_redirect_file()); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_LOG_FILE), + log_redirect_file, log_redirect_file); + + QString kernel_log_redirect_file(get_kernel_log_redirect_file()); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_KERNEL_LOG_FILE), + kernel_log_redirect_file, kernel_log_redirect_file); #if 0 insertTableRow(vmInfoTable, DETAILED_INFO_TELNET_PORT, @@ -350,13 +355,14 @@ void DetailedInfoDialog::slotCellOpen(int nRow, int nCol) QTableWidgetItem *item = vmInfoTable->item(nRow, 0); qDebug() << item->text() << "item was double clicked"; - if (item->text().compare(DETAILED_INFO_HDS_PATH, Qt::CaseInsensitive) == 0 || - item->text().compare(DETAILED_INFO_LOG_PATH, Qt::CaseInsensitive) == 0 || + if (item->text().compare(DETAILED_INFO_HDS_PATH) == 0 || + item->text().compare(DETAILED_INFO_LOG_FILE) == 0 || + item->text().compare(DETAILED_INFO_KERNEL_LOG_FILE) == 0 || item->text().startsWith(DETAILED_INFO_IMAGE_PATH) == true) { /* get path item */ item = vmInfoTable->item(nRow, nCol); - if (item->text().compare(GENERIC_TEXT_NONE, Qt::CaseInsensitive) == 0 || + if (item->text().compare(GENERIC_TEXT_NONE) == 0 || item->text().isEmpty() == true) { /* ignore this event */ return; diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index 496730dd6f..9c20669f83 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -96,7 +96,8 @@ #define DETAILED_INFO_CPU_VT "CPU Virtualization" #define DETAILED_INFO_GPU_VT "GPU Virtualization" #define DETAILED_INFO_IMAGE_PATH "Image Path" -#define DETAILED_INFO_LOG_PATH "Log Path" +#define DETAILED_INFO_LOG_FILE "Emulator Log File" +#define DETAILED_INFO_KERNEL_LOG_FILE "Kernel Log File" #define DETAILED_INFO_TELNET_PORT "Logging Telnet Port" /* screen shot dialog */ -- 2.34.1