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.
This commit is contained in:
Michal Privoznik 2013-01-17 11:42:00 +01:00
parent 1f25194ad1
commit cc6c425f94

View File

@ -4879,6 +4879,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
virDomainEventPtr event; virDomainEventPtr event;
int intermediatefd = -1; int intermediatefd = -1;
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
char *errbuf = NULL;
if (header->version == 2) { if (header->version == 2) {
const char *prog = qemuSaveCompressionTypeToString(header->compressed); const char *prog = qemuSaveCompressionTypeToString(header->compressed);
@ -4896,6 +4897,8 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
virCommandSetInputFD(cmd, intermediatefd); virCommandSetInputFD(cmd, intermediatefd);
virCommandSetOutputFD(cmd, fd); virCommandSetOutputFD(cmd, fd);
virCommandSetErrorBuffer(cmd, &errbuf);
virCommandDoAsyncIO(cmd);
if (virCommandRunAsync(cmd, NULL) < 0) { if (virCommandRunAsync(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -4926,6 +4929,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
ret = -1; ret = -1;
} }
VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf));
} }
VIR_FORCE_CLOSE(intermediatefd); VIR_FORCE_CLOSE(intermediatefd);
@ -4975,6 +4979,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
out: out:
virCommandFree(cmd); virCommandFree(cmd);
VIR_FREE(errbuf);
if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager, if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
vm->def, path) < 0) vm->def, path) < 0)
VIR_WARN("failed to restore save state label on %s", path); VIR_WARN("failed to restore save state label on %s", path);