[CRIU] [PATCH] log: write pidfile at logdir

Pavel Emelyanov xemul at parallels.com
Fri Nov 1 04:41:16 PDT 2013


On 11/01/2013 07:08 PM, Ruslan Kuprieiev wrote:
> Hi!
> 
> Now we're unable to use relative pidfile path with -d option, because
> criu chdir to /, before writing pidfile. So lets open pidfile at log dir.

Log dir?! Let's do another thing first -- get rid of 2 dirs -- log and img --
and make one -- working dir. Both, logs and images, should go into it.
And the pidfile as well.

> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  log.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/log.c b/log.c
> index 1e5fcad..5426297 100644
> --- a/log.c
> +++ b/log.c
> @@ -194,11 +194,17 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
>  
>  int write_pidfile(char *pfname, int pid)
>  {
> -	int fd;
> +	int dfd, fd;
>  
> -	fd = open(pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
> +	dfd = get_service_fd(LOG_DIR_FD_OFF);
> +	if (dfd < 0) {
> +		pr_perror("Can't get log directory fd");
> +		return -1;
> +	}
> +
> +	fd = openat(dfd, pfname, O_CREAT | O_TRUNC | O_WRONLY, 0600);
>  	if (fd == -1) {
> -		pr_perror("Can't open %s", pfname);
> +		pr_perror("Can't open pidfile %s", pfname);
>  		kill(pid, SIGKILL);
>  		return -1;
>  	}
> 




More information about the CRIU mailing list