xl: close restore file fd when we're done with it
PATCH 1/1 xl: close restore file fd when we're done with it
And log if close fails.
Reported-by Andrew Armenia <[email protected]>
Signed-off-by Wei Liu <[email protected]>
---
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Andrew Armenia <[email protected]>
For 4.6, fix leaking fd to avoid holding on to restoring file.
This should also be backported to many versions that uses xl.
--- tools/libxl/xl_cmdimpl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/libxl/xl_cmdimpl.c +9 -0
@@ -2627,6 +2627,7 @@ static uint32_t create_domain(struct domain_create *dom_info)void *config_data =0 ;int config_len =0 ;int restore_fd =-1 ; +int restore_fd_to_close =-1 ;const libxl_asyncprogress_how *autoconnect_console_how;struct save_file_header hdr;
@@ -2650,6 +2651,7 @@ static uint32_t create_domain(struct domain_create *dom_info)fprintf (stderr,"Can't open restore file: %s\n" ,strerror (errno));return ERROR_INVAL ; } + restore_fd_to_close = restore_fd; rc =libxl_fd_set_cloexec (ctx, restore_fd,1 );if (rc)return rc; }
@@ -2851,6 +2853,13 @@ start:release_lock (); +if (restore_fd_to_close >=0 ) { +if (close (restore_fd_to_close)) +fprintf (stderr,"Failed to close restoring file, fd %d, errno %d\n" , + restore_fd_to_close, errno); + restore_fd_to_close =-1 ; + } +if (!paused)libxl_domain_unpause (ctx, domid);
Signature · 1 line
2.1.4
This patch is for 4.6. Forgot to extend the tag in subject line.
Quoted 5 lines · Wei Liu
And log if close fails.
Reported-by Andrew Armenia <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Acked-by Ian Campbell <[email protected]>
Ian Campbell
AppliedQuoted 8 lines · Ian Campbell
Quoted 5 lines · Wei Liu
And log if close fails.
Reported-by Andrew Armenia <[email protected]>Signed-off-by Wei Liu <[email protected]>---
Acked-by Ian Campbell <[email protected]>
Applied.