I have an alternative patch which does this, I'll submit that instead.

Simon
________________________________
From: Michal Prívozník <mpriv...@redhat.com>
Sent: 20 August 2021 16:09
To: Simon Rowe <simon.r...@nutanix.com>; libvir-list@redhat.com 
<libvir-list@redhat.com>
Subject: Re: [PATCH 2/2] qemu: never unlink() the core dump output file

On 8/20/21 10:39 AM, Simon Rowe wrote:
> The comment above virQEMUFileOpenAs() implies any result should be
> left intact.
>
> Signed-off-by: Simon Rowe <simon.r...@nutanix.com>
> ---
>  src/qemu/qemu_driver.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f31e13889e..b1ac1cb73b 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3282,8 +3282,6 @@ doCoreDump(virQEMUDriver *driver,
>      if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0)
>          ret = -1;
>      virFileWrapperFdFree(wrapperFd);
> -    if (ret != 0)
> -        unlink(path);
>      return ret;
>  }
>
>

So the @path is opened using virQEMUFileOpenAs() which as the last
argument has @needUnlink which tells caller whether the file was created
by this call (true) or was already existing (false). But for some reason
doCoreDump() passes NULL and then unlinks the file unconditionally. I
think the proper fix would be to introduce a boolean, pass it instead of
NULL and then have:

 if (ret != 0 && needUnlink)
   unlink(path);

Michal

Reply via email to