From: Munkyu Im Date: Tue, 1 Nov 2016 07:09:12 +0000 (+0900) Subject: emulator: modify VM lock X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~20^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffdc326b70237b660ac9a6a7cea3117d6c0f249f;p=sdk%2Femulator%2Fqemu.git emulator: modify VM lock check whether vm_launch.conf file exist. skip making lock file if it's failed to create. Change-Id: I2073d752e7fca9dfcce137b6ac0b6ecffcc0d05d Signed-off-by: Munkyu Im --- diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index e4a170754b..b63d020518 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -317,6 +317,11 @@ static int emulator_main(int argc, char *argv[], char **envp) set_bin_path_os(_qemu_argv[0]); if (launch_conf_file) { + if (!g_file_test(launch_conf_file, G_FILE_TEST_EXISTS)) { + fprintf(stderr, "conf_file(%s) does not exist.\n", launch_conf_file); + return -1; + } + make_vm_lock_os(g_path_get_dirname(launch_conf_file)); if (!load_conf(launch_conf_file)) { return -1; diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index f733aedc67..48220da10c 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -94,6 +94,10 @@ void make_vm_lock_os(gchar *vms_path) if (g_mkdir_with_parents(g_path_get_dirname(lock_filename), 0777)) { LOG_WARNING("Can not create directory for lock file: %ld\n", GetLastError()); + // do not create the lock file. + g_free(lock_filename); + lock_filename = NULL; + return; } lock_file = CreateFile(lock_filename, GENERIC_READ | GENERIC_WRITE, @@ -107,6 +111,8 @@ void make_vm_lock_os(gchar *vms_path) // On Windows, the file opened by CreateFile has exclusive lock // naturally unless FILE_SHARE_* attribute is set. if (error == ERROR_SHARING_VIOLATION) { + g_free(lock_filename); + lock_filename = NULL; error_report("Can not execute this VM. " "The same VM may be running now."); exit(1); diff --git a/tizen/src/util/osutil.c b/tizen/src/util/osutil.c index de78c53d42..540579381b 100644 --- a/tizen/src/util/osutil.c +++ b/tizen/src/util/osutil.c @@ -145,9 +145,10 @@ retry: error = errno; LOG_WARNING("Failed to open file for lock(%d): %s\n", error, strerror(error)); - error_report("Can not execute this VM. " - "The same VM may be running now."); - exit(1); + // do not create the lock file. + g_free(lock_filename); + lock_filename = NULL; + return; } if (fd_lock(lock_file) == -1) { @@ -165,10 +166,7 @@ retry: exit(1); } - LOG_WARNING("Failed to lock image file: %s\n", strerror(error)); - close(lock_file); - lock_file = -1; - return; + LOG_WARNING("Failed to lock file: %s\n", strerror(error)); } emulator_add_exit_notifier(&remove_lock);