summaryrefslogtreecommitdiffstats
path: root/storage-daemon/qemu-storage-daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage-daemon/qemu-storage-daemon.c')
-rw-r--r--storage-daemon/qemu-storage-daemon.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index b8e910f220..7718f6dcda 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -61,6 +61,7 @@
#include "trace/control.h"
static const char *pid_file;
+static char *pid_file_realpath;
static volatile bool exit_requested = false;
void qemu_system_killed(int signal, pid_t pid)
@@ -296,7 +297,11 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)
}
case OPTION_DAEMONIZE:
if (os_set_daemonize(true) < 0) {
- error_report("--daemonize not supported in this build");
+ /*
+ * --daemonize is parsed before monitor_init_globals_core(), so
+ * error_report() does not work yet
+ */
+ fprintf(stderr, "--daemonize not supported in this build\n");
exit(EXIT_FAILURE);
}
break;
@@ -359,7 +364,7 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)
static void pid_file_cleanup(void)
{
- unlink(pid_file);
+ unlink(pid_file_realpath);
}
static void pid_file_init(void)
@@ -375,6 +380,14 @@ static void pid_file_init(void)
exit(EXIT_FAILURE);
}
+ pid_file_realpath = g_malloc(PATH_MAX);
+ if (!realpath(pid_file, pid_file_realpath)) {
+ error_report("cannot resolve PID file path: %s: %s",
+ pid_file, strerror(errno));
+ unlink(pid_file);
+ exit(EXIT_FAILURE);
+ }
+
atexit(pid_file_cleanup);
}