From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Daley Subject: [PATCH 20/29] xl: check for restore file open failure in create_domain Date: Wed, 30 Oct 2013 20:51:56 +1300 Message-ID: <1383119525-26033-21-git-send-email-mattjd@gmail.com> References: <1383119525-26033-1-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1383119525-26033-1-git-send-email-mattjd@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Matthew Daley , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org ...otherwise you get a less helpful error message. Coverity-ID: 1055569 Signed-off-by: Matthew Daley --- tools/libxl/xl_cmdimpl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 43d1519..a935a18 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1919,6 +1919,10 @@ static uint32_t create_domain(struct domain_create *dom_info) } else { restore_source = restore_file; restore_fd = open(restore_file, O_RDONLY); + if (restore_fd == -1) { + fprintf(stderr, "Can't open restore file: %s\n", strerror(errno)); + return ERROR_INVAL; + } rc = libxl_fd_set_cloexec(ctx, restore_fd, 1); if (rc) return rc; } -- 1.7.10.4