emul_state: divided up log path
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 17 Aug 2015 06:42:15 +0000 (15:42 +0900)
committerSangho Park <sangho.p@samsung.com>
Wed, 19 Aug 2015 01:15:58 +0000 (10:15 +0900)
"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 <syeon.hwang@samsung.com>
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/skin/maruskin_operation.c
tizen/src/ui/menu/detailedinfodialog.cpp
tizen/src/ui/resource/ui_strings.h

index 974ccd9b2a74ca60b2944db0fad46f75bc2098f1..42d0afaac9381777c0e041e302db3de8bc8c9af1 100644 (file)
@@ -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;
 }
 
 
index 8f108a823c4c868f1d834b69f6468bebd04e4ceb..45bbdae3a58e57d97bf0bebb33a68499e64a54ee 100644 (file)
@@ -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);
index 7245c175e736c72ff3b1d6232c429ebcc6ae88fc..10033ba57658c8dda29b4957ad8ad7b79051e8b5 100644 (file)
@@ -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;
 }
 
index 0f4f9c055f43c143fad8307e4cbdc67cc4934dae..bf7e81f60ff70b66e06bce62684cba5ed7e5db23 100644 (file)
@@ -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;
index 496730dd6f1e3ce05283c68b7b133d22acee66f2..9c20669f8310c136cd87094287be56bfb02c73f1 100644 (file)
@@ -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 */