qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* oslib-posix:Fix handle fd leak in qemu_write_pidfile()
@ 2020-08-26 10:14 AlexChen
  2020-08-26 10:18 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: AlexChen @ 2020-08-26 10:14 UTC (permalink / raw)
  To: pbonzini; +Cc: zhengchuan, qemu-devel, zhang.zhanghailiang

From: alexchen <alex.chen@huawei.com>

The fd will leak when (a.st_ino == b.st_ino) is true, fix it.

Signed-off-by: AlexChen <alex.chen@huawei.com>
---
 util/oslib-posix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index ad8001a4ad..74cf5e9c73 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -176,6 +176,7 @@ bool qemu_write_pidfile(const char *path, Error **errp)
         goto fail_unlink;
     }

+    close(fd);
     return true;

 fail_unlink:
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: oslib-posix:Fix handle fd leak in qemu_write_pidfile()
  2020-08-26 10:14 oslib-posix:Fix handle fd leak in qemu_write_pidfile() AlexChen
@ 2020-08-26 10:18 ` Daniel P. Berrangé
  2020-08-27  2:40   ` AlexChen
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2020-08-26 10:18 UTC (permalink / raw)
  To: AlexChen; +Cc: zhengchuan, pbonzini, qemu-devel, zhang.zhanghailiang

On Wed, Aug 26, 2020 at 06:14:48PM +0800, AlexChen wrote:
> From: alexchen <alex.chen@huawei.com>
> 
> The fd will leak when (a.st_ino == b.st_ino) is true, fix it.

That is *INTENTIONAL*.  We're holding a lock on the file and the
lock exists only while the FD is open.  When QEMU exists, the FD
is closed and the lock is released. There is no leak.

> Signed-off-by: AlexChen <alex.chen@huawei.com>
> ---
>  util/oslib-posix.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index ad8001a4ad..74cf5e9c73 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -176,6 +176,7 @@ bool qemu_write_pidfile(const char *path, Error **errp)
>          goto fail_unlink;
>      }
> 
> +    close(fd);
>      return true;
> 
>  fail_unlink:
> -- 
> 2.19.1
> 
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: oslib-posix:Fix handle fd leak in qemu_write_pidfile()
  2020-08-26 10:18 ` Daniel P. Berrangé
@ 2020-08-27  2:40   ` AlexChen
  0 siblings, 0 replies; 3+ messages in thread
From: AlexChen @ 2020-08-27  2:40 UTC (permalink / raw)
  To: "Daniel P. Berrangé"
  Cc: zhengchuan, pbonzini, qemu-devel, zhang.zhanghailiang

On 2020/8/26 18:18, Daniel P. Berrangé wrote:
> On Wed, Aug 26, 2020 at 06:14:48PM +0800, AlexChen wrote:
>> > From: alexchen <alex.chen@huawei.com>
>> > 
>> > The fd will leak when (a.st_ino == b.st_ino) is true, fix it.
> That is *INTENTIONAL*.  We're holding a lock on the file and the
> lock exists only while the FD is open.  When QEMU exists, the FD
> is closed and the lock is released. There is no leak.
> 
OK, I got it, thanks.

Thanks
Alex



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-27  2:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-26 10:14 oslib-posix:Fix handle fd leak in qemu_write_pidfile() AlexChen
2020-08-26 10:18 ` Daniel P. Berrangé
2020-08-27  2:40   ` AlexChen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).