summaryrefslogtreecommitdiffstats
path: root/scsi
diff options
context:
space:
mode:
authorMichal Privoznik2018-04-03 15:12:15 +0200
committerPaolo Bonzini2018-04-09 16:36:40 +0200
commitbd6b1c8324171e26eb2ce23d5a832bc8c4cf941b (patch)
tree78e7f901aec9cbcb158ec9e50ce080481348f828 /scsi
parentqemu-pr-helper: Daemonize before dropping privileges (diff)
downloadqemu-bd6b1c8324171e26eb2ce23d5a832bc8c4cf941b.tar.gz
qemu-bd6b1c8324171e26eb2ce23d5a832bc8c4cf941b.tar.xz
qemu-bd6b1c8324171e26eb2ce23d5a832bc8c4cf941b.zip
qemu-pr-helper: Write pidfile more often
Let's write pidfile even if user did not request --daemon but they requested just --pidfile. Libvirt will use exactly this. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scsi')
-rw-r--r--scsi/qemu-pr-helper.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index eeff80acf2..d0f83176e1 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -924,6 +924,7 @@ int main(int argc, char **argv)
Error *local_err = NULL;
char *trace_file = NULL;
bool daemonize = false;
+ bool pidfile_specified = false;
unsigned socket_activation;
struct sigaction sa_sigterm;
@@ -954,6 +955,7 @@ int main(int argc, char **argv)
case 'f':
g_free(pidfile);
pidfile = g_strdup(optarg);
+ pidfile_specified = true;
break;
#ifdef CONFIG_LIBCAP
case 'u': {
@@ -1086,9 +1088,11 @@ int main(int argc, char **argv)
error_report("Failed to daemonize: %s", strerror(errno));
exit(EXIT_FAILURE);
}
- write_pidfile();
}
+ if (daemonize || pidfile_specified)
+ write_pidfile();
+
#ifdef CONFIG_LIBCAP
if (drop_privileges() < 0) {
error_report("Failed to drop privileges: %s", strerror(errno));