qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 3/3] Delete PID file on exit


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 3/3] Delete PID file on exit
Date: Tue, 11 Sep 2018 15:44:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 07/09/2018 14:13, Marc-André Lureau wrote:
> Register an exit notifier to remove the PID file. By the time atexit()
> is called, qemu_write_pidfile() guarantees QEMU owns the PID file,
> thus we could safely remove it when exiting.
> 
> Signed-off-by: Marc-André Lureau <address@hidden>

Queued this one, too.

Paolo

> ---
>  vl.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/vl.c b/vl.c
> index 0eaf948d32..51af016602 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2603,6 +2603,16 @@ static void qemu_run_exit_notifiers(void)
>      notifier_list_notify(&exit_notifiers, NULL);
>  }
>  
> +static const char *pid_file;
> +static Notifier qemu_unlink_pidfile_notifier;
> +
> +static void qemu_unlink_pidfile(Notifier *n, void *data)
> +{
> +    if (pid_file) {
> +        unlink(pid_file);
> +    }
> +}
> +
>  bool machine_init_done;
>  
>  void qemu_add_machine_init_done_notifier(Notifier *notify)
> @@ -2927,7 +2937,6 @@ int main(int argc, char **argv, char **envp)
>      const char *vga_model = NULL;
>      const char *qtest_chrdev = NULL;
>      const char *qtest_log = NULL;
> -    const char *pid_file = NULL;
>      const char *incoming = NULL;
>      bool userconfig = true;
>      bool nographic = false;
> @@ -4001,6 +4010,9 @@ int main(int argc, char **argv, char **envp)
>          exit(1);
>      }
>  
> +    qemu_unlink_pidfile_notifier.notify = qemu_unlink_pidfile;
> +    qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier);
> +
>      if (qemu_init_main_loop(&main_loop_err)) {
>          error_report_err(main_loop_err);
>          exit(1);
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]