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>
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;
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,
// 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);
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) {
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);