static EmulatorConfigInfo _emul_info = {0,};
static EmulatorConfigState _emul_state;
--/* misc */
- const char *get_bin_path(void)
- {
- const char *bin_path = get_variable(KEYWORD_BIN_PATH);
- // guarantee bin_path is not NULL
- if (!bin_path) {
- bin_path = "";
- }
- return bin_path;
- }
-
- const char *get_log_path(void)
- {
- const char *log_path = get_variable("log_path");
-
- // 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) {
- // 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);
- }
-
- set_variable("log_path", log_path, false);
- }
-
- return log_path;
- }
-#ifdef SUPPORT_LEGACY_ARGS
-// for compatibility
-char log_path[PATH_MAX] = { 0, };
-#endif
--
/* sdl bits per pixel */
void set_emul_sdl_bpp(int bpp)
{
return false;
}
- /* VM ram size */
- void set_emul_ram_size(const char *size)
- {
- _emul_info.vm_ram_size = size;
- }
+ //
+ // cleaned-up
+ //
- const char* get_emul_ram_size(void)
+ // launch_conf_path
+ // only set by emulator.c when start up
+ const char *launch_conf_file = NULL;
+
+ // bin path
+ // only set by osutil-{OS}.c when start up
+ const char *bin_path = NULL;
+
+ const char *get_bin_path(void)
{
- return _emul_info.vm_ram_size;
+ if (bin_path) {
+ return bin_path;
+ }
+
+ return "";
}
- /* file sharing path */
- void set_emul_file_sharing_path(const char *path)
+ // emulator kernel log file
+ static const char *kernel_log_redirect_file = NULL;
+
+ const char *get_kernel_log_redirect_file(void)
{
- _emul_info.file_sharing_path = path;
+ // 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;
}
- const char* get_emul_file_sharing_path(void)
+ // emulator log file
+ static const char *log_redirect_file = NULL;
+
+ #ifdef CONFIG_WIN32
+ // for checking Windows version
+ extern OSVERSIONINFO osvi;
+ #endif
+
+ const char *get_log_redirect_file(void)
{
- return _emul_info.file_sharing_path;
- }
-#ifdef SUPPORT_LEGACY_ARGS
- if (log_path[0]) {
- return log_path;
- }
-#endif
+ int result = -1;
+ char log_filename[PATH_MAX];
- //
- // cleaned-up
- //
+ // 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)
+ # if WINVER >= 0x600
+ // works only vista or newer...
+ if (osvi.dwMajorVersion >= 6) {
+ char win32_log_filename_normalized[PATH_MAX];
+ HANDLE handle_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD ret = GetFinalPathNameByHandle(handle_stdout,
+ win32_log_filename_normalized,
+ PATH_MAX, FILE_NAME_NORMALIZED);
+ // strip "\\?\"
+ if (ret > 0) {
+ g_stpcpy(log_filename, win32_log_filename_normalized + 4);
+ result = 0;
+ } else {
+ result = -1;
+ }
+ }
+ # endif
+ #endif
+ if (log_redirect_file) {
+ g_free((void *)log_redirect_file);
+ }
- // launch_conf_path
- const char *launch_conf_file = NULL;
+ if (result >= 0) {
+ log_redirect_file = g_strdup(log_filename);
+ } else {
+ // fail safe
+ LOG_WARNING("Can not identify log redirection path, "
+ "We should assume it !!!\n");
+
+ 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.
+ log_redirect_file = g_strdup("");
+ }
+ else {
+ log_redirect_file =
+ g_strdup_printf("%s/%s/logs/emulator.log", vms_path, vm_name);
+ }
+ }
+
+ return log_redirect_file;
+ }
// drive image file
static const char *drive_image_file = NULL;
const char *get_profile_name(void)
{
- return vio_evdi->profile;
+ return get_variable("profile");
}
- /* GPU virtualization */
+ // host directory sharing path
+ const char* get_host_directory_sharing_path(void)
+ {
+ FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
+ const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL);
+
+ return sharing_path;
+ }
+
+ // GPU virtualization
static bool gpu_accel_enabled;
bool is_gpu_accel_enabled(void)