1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-08-24 09:49:59 +03:00

qemu: Run lzop with '--ignore-warn'

Currently, if lzop decompression binary produces a warning, it
doesn't exit with zero status but 2 instead. Terrifying, but
true. However, warnings may be ignored using '--ignore-warn'
command line argument.  Moreover, in which case, the exit status
will be zero.
This commit is contained in:
Michal Privoznik
2013-02-19 18:07:58 +01:00
parent 1d8193ee8a
commit 0eeedf52e7

View File

@ -2507,6 +2507,33 @@ qemuCompressProgramName(int compress)
qemuSaveCompressionTypeToString(compress)); qemuSaveCompressionTypeToString(compress));
} }
static virCommandPtr
qemuCompressGetCommand(virQEMUSaveFormat compression)
{
virCommandPtr ret = NULL;
const char *prog = qemuSaveCompressionTypeToString(compression);
if (!prog) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("Invalid compressed save format %d"),
compression);
return NULL;
}
ret = virCommandNew(prog);
virCommandAddArg(ret, "-dc");
switch (compression) {
case QEMU_SAVE_FORMAT_LZOP:
virCommandAddArg(ret, "--ignore-warn");
break;
default:
break;
}
return ret;
}
/* Internal function to properly create or open existing files, with /* Internal function to properly create or open existing files, with
* ownership affected by qemu driver setup. */ * ownership affected by qemu driver setup. */
static int static int
@ -4775,32 +4802,22 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
if (!(caps = virQEMUDriverGetCapabilities(driver, false))) if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup; goto cleanup;
if (header->version == 2) { if ((header->version == 2) &&
const char *prog = qemuSaveCompressionTypeToString(header->compressed); (header->compressed != QEMU_SAVE_FORMAT_RAW)) {
if (prog == NULL) { if (!(cmd = qemuCompressGetCommand(header->compressed)))
virReportError(VIR_ERR_OPERATION_FAILED,
_("Invalid compressed save format %d"),
header->compressed);
goto cleanup; goto cleanup;
}
if (header->compressed != QEMU_SAVE_FORMAT_RAW) { intermediatefd = *fd;
cmd = virCommandNewArgList(prog, "-dc", NULL); *fd = -1;
intermediatefd = *fd;
*fd = -1;
virCommandSetInputFD(cmd, intermediatefd); virCommandSetInputFD(cmd, intermediatefd);
virCommandSetOutputFD(cmd, fd); virCommandSetOutputFD(cmd, fd);
virCommandSetErrorBuffer(cmd, &errbuf); virCommandSetErrorBuffer(cmd, &errbuf);
virCommandDoAsyncIO(cmd); virCommandDoAsyncIO(cmd);
if (virCommandRunAsync(cmd, NULL) < 0) { if (virCommandRunAsync(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, *fd = intermediatefd;
_("Failed to start decompression binary %s"), goto cleanup;
prog);
*fd = intermediatefd;
goto cleanup;
}
} }
} }