[PATCH 2/2] qemu: never unlink() the core dump output file

Simon Rowe simon.rowe at nutanix.com
Fri Aug 20 15:58:31 UTC 2021


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

Simon
________________________________
From: Michal Prívozník <mprivozn at redhat.com>
Sent: 20 August 2021 16:09
To: Simon Rowe <simon.rowe at nutanix.com>; libvir-list at redhat.com <libvir-list at 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.rowe at 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210820/7dd3b565/attachment-0001.htm>


More information about the libvir-list mailing list