]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt_iohelper: record the libvirt_iohelper's error message at virFileWrapperFdFree
authorxinhua.Cao <caoxinhua@huawei.com>
Mon, 23 Jul 2018 12:22:41 +0000 (20:22 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 Aug 2018 14:00:25 +0000 (16:00 +0200)
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 <caoxinhua@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virfile.c

index 1faeebbdb5b324ab4b175f81d66ed6d13e4c79ac..01ebdb6f49303c439a32d625f04f7bc05464307d 100644 (file)
@@ -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);
 }