]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Report error in virFileWrapperFdClose()
authorAndrea Bolognani <abologna@redhat.com>
Tue, 19 Feb 2019 16:20:41 +0000 (17:20 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 25 Feb 2019 15:34:37 +0000 (16:34 +0100)
libvirt_iohelper is used internally by the virFileWrapperFd APIs;
more specifically, in the QEMU driver we have the doCoreDump() and
qemuDomainSaveMemory() helper functions as users, and those in turn
end up being called by the implementation of several driver APIs.

By calling virReportError() if libvirt_iohelper has failed, we
overwrite whatever generic error message QEMU might have raised
with the more useful one generated by the helper program.

After this commit, the user will be able to see the error directly
instead of having to dig in the journal or libvirtd log.

https://bugzilla.redhat.com/show_bug.cgi?id=1578741

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virfile.c

index d35206b0ddd8611d964ae1e17b95eb8bdac3b7cb..31030c7b34903872d32f7c96361af169b95b08dc 100644 (file)
@@ -337,8 +337,14 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
 
     ret = virCommandWait(wfd->cmd, NULL);
 
-    if (wfd->err_msg && *wfd->err_msg)
-        VIR_WARN("iohelper reports: %s", wfd->err_msg);
+    /* If the command used to process I/O has failed and produced some
+     * messages on stderr, it's fair to assume those will be more
+     * relevant to the user than whatever eg. QEMU can figure out on its
+     * own having no knowledge of the fact a command is handling its I/O
+     * in the first place, so it's okay if we end up discarding an
+     * existing error here */
+    if (ret < 0 && wfd->err_msg && *wfd->err_msg)
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg);
 
     wfd->closed = true;