From: xinhua.Cao Date: Mon, 23 Jul 2018 12:22:41 +0000 (+0800) Subject: libvirt_iohelper: record the libvirt_iohelper's error message at virFileWrapperFdFree X-Git-Tag: v4.7.0-rc1~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0c3e931804a86cd7146db0164ab4843039c410b;p=thirdparty%2Flibvirt.git 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 --- 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); }