From b0c3e931804a86cd7146db0164ab4843039c410b Mon Sep 17 00:00:00 2001 From: "xinhua.Cao" Date: Mon, 23 Jul 2018 20:22:41 +0800 Subject: [PATCH] libvirt_iohelper: record the libvirt_iohelper's error message at virFileWrapperFdFree Currently iohelper's error log is recorded in virFileWrapperFdClose. However, if something goes wrong the caller might not even get to calling virFileWrapperFdClose and call virFileWrapperFdFree directly. Therefore the error reporting should happen there. Signed-off-by: xinhua.Cao Signed-off-by: Michal Privoznik --- src/util/virfile.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 1faeebbdb5..01ebdb6f49 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -330,9 +330,6 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd) return 0; ret = virCommandWait(wfd->cmd, NULL); - if (wfd->err_msg && *wfd->err_msg) - VIR_WARN("iohelper reports: %s", wfd->err_msg); - return ret; } @@ -351,8 +348,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd) if (!wfd) return; - VIR_FREE(wfd->err_msg); + if (wfd->err_msg && *wfd->err_msg) + VIR_WARN("iohelper reports: %s", wfd->err_msg); + virCommandAbort(wfd->cmd); + + VIR_FREE(wfd->err_msg); virCommandFree(wfd->cmd); VIR_FREE(wfd); }