[libvirt] [PATCH] util:Fix with process number and pid file do not match

dubo163 (1): util:Fix with process number and pid file do not match src/util/virpidfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 1.8.3.1

the libvirtd pid file is not match the os process pid number which is smaller than before. this would be exist if the libvirtd process coredump or the os process was killed which the next pid number is smaller. you can be also edit the pid file to write the longer number than before,then restart the libvirtd service. Signed-off-by: dubo163 <dubo163@126.com> --- src/util/virpidfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 58ab29f..1a85d43 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -446,6 +446,14 @@ int virPidFileAcquirePath(const char *path, snprintf(pidstr, sizeof(pidstr), "%lld", (long long) pid); + if (ftruncate(fd, 0) < 0) { + virReportSystemError(errno, + _("Failed to truncate pid file '%s'"), + path); + VIR_FORCE_CLOSE(fd); + return -1; + } + if (safewrite(fd, pidstr, strlen(pidstr)) < 0) { virReportSystemError(errno, _("Failed to write to pid file '%s'"), -- 1.8.3.1

On 07/03/2018 01:51 PM, dubo163 wrote:
the libvirtd pid file is not match the os process pid number which is smaller than before.
this would be exist if the libvirtd process coredump or the os process was killed which the next pid number is smaller.
you can be also edit the pid file to write the longer number than before,then restart the libvirtd service.
Signed-off-by: dubo163 <dubo163@126.com>
The patch looks good, but you need to use your real name for both patch authorship and S-o-b line. Michal
participants (2)
-
dubo163
-
Michal Prívozník