if execute qemu_open success, have no branch to free the fd,
so unlink it inadvance, let it free by process exit.

Signed-off-by: Jie Wang <wangji...@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 36820fec16..30bf39bf4f 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -131,6 +131,7 @@ bool qemu_write_pidfile(const char *path, Error **errp)
             error_setg_errno(errp, errno, "Cannot open pid file");
             return false;
         }
+       unlink(path);
 
         if (fstat(fd, &b) < 0) {
             error_setg_errno(errp, errno, "Cannot stat file");
-- 
2.23.0


Reply via email to