[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 5/7] qemu: Catch stderr of image decompression binary



If a decompression binary prints something to stderr, currently
it is discarded. However, it can contain useful data from
debugging POV, so we should catch it.
---
 src/qemu/qemu_driver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 72907d2..adfa067 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4883,6 +4883,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
     virDomainEventPtr event;
     int intermediatefd = -1;
     virCommandPtr cmd = NULL;
+    char *errbuf = NULL;
 
     if (header->version == 2) {
         const char *prog = qemuSaveCompressionTypeToString(header->compressed);
@@ -4900,6 +4901,8 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
 
             virCommandSetInputFD(cmd, intermediatefd);
             virCommandSetOutputFD(cmd, fd);
+            virCommandSetErrorBuffer(cmd, &errbuf);
+            virCommandDoAsyncIO(cmd);
 
             if (virCommandRunAsync(cmd, NULL) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4928,6 +4931,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
 
         if (virCommandWait(cmd, NULL) < 0)
             ret = -1;
+        VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf));
     }
     VIR_FORCE_CLOSE(intermediatefd);
 
@@ -4977,6 +4981,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
 
 out:
     virCommandFree(cmd);
+    VIR_FREE(errbuf);
     if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
                                                  vm->def, path) < 0)
         VIR_WARN("failed to restore save state label on %s", path);
-- 
1.8.0.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]