]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Catch stderr of image compression binary
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 17 Jan 2013 10:59:23 +0000 (11:59 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Feb 2013 14:45:21 +0000 (15:45 +0100)
If a compression 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_migration.c

index d03e3613e925b1f1b48b6bebccc2651291f1add0..2c13d4c15e4f39376df49c526621907da91f2e2f 100644 (file)
@@ -3598,6 +3598,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
     virCommandPtr cmd = NULL;
     int pipeFD[2] = { -1, -1 };
     unsigned long saveMigBandwidth = priv->migMaxBandwidth;
+    char *errbuf = NULL;
 
     /* Increase migration bandwidth to unlimited since target is a file.
      * Failure to change migration speed is not fatal. */
@@ -3680,6 +3681,8 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
             cmd = virCommandNewArgs(args);
             virCommandSetInputFD(cmd, pipeFD[0]);
             virCommandSetOutputFD(cmd, &fd);
+            virCommandSetErrorBuffer(cmd, &errbuf);
+            virCommandDoAsyncIO(cmd);
             if (virSetCloseExec(pipeFD[1]) < 0) {
                 virReportSystemError(errno, "%s",
                                      _("Unable to set cloexec flag"));
@@ -3727,7 +3730,11 @@ cleanup:
 
     VIR_FORCE_CLOSE(pipeFD[0]);
     VIR_FORCE_CLOSE(pipeFD[1]);
-    virCommandFree(cmd);
+    if (cmd) {
+        VIR_DEBUG("Compression binary stderr: %s", NULLSTR(errbuf));
+        VIR_FREE(errbuf);
+        virCommandFree(cmd);
+    }
     if (restoreLabel && (!bypassSecurityDriver) &&
         virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
                                                  vm->def, path) < 0)