emul_state: added some preparations
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 28 May 2015 08:15:46 +0000 (17:15 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 28 May 2015 08:47:52 +0000 (17:47 +0900)
If emulator is launched without emulator-manager, some information can be missed.
So we should have some preparations.

Change-Id: I65573d2d551433ab813ed3d4fc8d6e92107f3c13
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emul_state.c
tizen/src/emul_state.h

index b65fc2c87f1dd110e83a1a3e74f654989fa98f4a..fc1d87f8d6e44d09bd2ff48f80b231d71d3dda20 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "emul_state.h"
 
+#include <libgen.h>
 #include "emulator_common.h"
 
 #if defined(CONFIG_LINUX)
@@ -78,14 +79,16 @@ const char *get_log_path(void)
         return log_path;
     }
 #endif
-    char *log_path = get_variable("log_path");
+    const char *log_path = get_variable("log_path");
 
-    // if "log_path" is not exist, make it first
+    // if "log_path" is not exist, make it first.
     if (!log_path) {
         char *vms_path = get_variable("vms_path");
         char *vm_name = get_variable("vm_name");
         if (!vms_path || !vm_name) {
-            log_path = NULL;
+            // we can not specify log path.
+            // emulator may not be launched from emulator-manager.
+            log_path = "";
         }
         else {
             log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name);
@@ -441,11 +444,18 @@ const char* get_drive_image_file(void)
 /* vm name */
 const char* get_emul_vm_name(void)
 {
-    if (!_emul_info.vm_name) {
-        _emul_info.vm_name = get_variable("vm_name");
+    const char *vm_name = get_variable("vm_name");
+
+    // if there is no "vm_name" we make it from drive image name.
+    if (!vm_name) {
+        char *drive_file = g_strdup(get_drive_image_file());
+        set_variable("vm_name", basename(drive_file), true);
+        g_free(drive_file);
+
+        vm_name = get_variable("vm_name");
     }
 
-    return _emul_info.vm_name;
+    return vm_name;
 }
 
 /* http proxy */
index a807b4c96c76aa735cb472221a26eb71820c5f61..e2b94f9d0ba999a8095a1c826888da6a62c3e892 100644 (file)
@@ -107,7 +107,6 @@ typedef  struct EmulatorConfigInfo {
     char host_ip[16];
 
     int spice_port;
-    const char *vm_name;
     const char *skin_path;
     bool gpu_accel_enable;
     const char *file_sharing_path;