diff options
author | Munkyu Im <munkyu.im@samsung.com> | 2016-11-01 16:09:12 +0900 |
---|---|---|
committer | SeokYeon Hwang <syeon.hwang@samsung.com> | 2016-11-07 17:34:43 +0900 |
commit | ffdc326b70237b660ac9a6a7cea3117d6c0f249f (patch) | |
tree | c14c7cd3c2abaa742c97a1a0a7486aab2d659a1a | |
parent | 315fb3aca5b9eb6e7c79c103362dc8340590721d (diff) | |
download | qemu-ffdc326b70237b660ac9a6a7cea3117d6c0f249f.tar.gz qemu-ffdc326b70237b660ac9a6a7cea3117d6c0f249f.tar.bz2 qemu-ffdc326b70237b660ac9a6a7cea3117d6c0f249f.zip |
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 <munkyu.im@samsung.com>
-rw-r--r-- | tizen/src/emulator.c | 5 | ||||
-rw-r--r-- | tizen/src/util/osutil-win32.c | 6 | ||||
-rw-r--r-- | tizen/src/util/osutil.c | 12 |
3 files changed, 16 insertions, 7 deletions
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); |