Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.

When dumping a domain, it's reasonable to save dump-file in raw format
if dump format is misconfigured or the corresponding compress program
is not available rather then fail dumping.
This commit is contained in:
Hu Tao 2010-11-30 15:12:54 +08:00 committed by Eric Blake
parent 7829052757
commit 1b6f13bb70
2 changed files with 32 additions and 21 deletions

View File

@ -136,6 +136,7 @@ Patches have also been contributed by:
Osier Yang <jyang@redhat.com> Osier Yang <jyang@redhat.com>
Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Wen Congyang <wency@cn.fujitsu.com> Wen Congyang <wency@cn.fujitsu.com>
Hu Tao <hutao@cn.fujitsu.com>
[....send patches to get your name here....] [....send patches to get your name here....]

View File

@ -6057,6 +6057,34 @@ cleanup:
return ret; return ret;
} }
static enum qemud_save_formats
getCompressionType(struct qemud_driver *driver)
{
int compress = QEMUD_SAVE_FORMAT_RAW;
/*
* We reuse "save" flag for "dump" here. Then, we can support the same
* format in "save" and "dump".
*/
if (driver->dumpImageFormat) {
compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
if (compress < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid dump image format specified in "
"configuration file, using raw"));
return QEMUD_SAVE_FORMAT_RAW;
}
if (!qemudCompressProgramAvailable(compress)) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Compression program for dump image format "
"in configuration file isn't available, "
"using raw"));
return QEMUD_SAVE_FORMAT_RAW;
}
}
return compress;
}
static int qemudDomainCoreDump(virDomainPtr dom, static int qemudDomainCoreDump(virDomainPtr dom,
const char *path, const char *path,
int flags ATTRIBUTE_UNUSED) { int flags ATTRIBUTE_UNUSED) {
@ -6065,28 +6093,10 @@ static int qemudDomainCoreDump(virDomainPtr dom,
int resume = 0, paused = 0; int resume = 0, paused = 0;
int ret = -1, fd = -1; int ret = -1, fd = -1;
virDomainEventPtr event = NULL; virDomainEventPtr event = NULL;
int compress; enum qemud_save_formats compress;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
/*
* We reuse "save" flag for "dump" here. Then, we can support the same compress = getCompressionType(driver);
* format in "save" and "dump".
*/
compress = QEMUD_SAVE_FORMAT_RAW;
if (driver->dumpImageFormat) {
compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
if (compress < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid dump image format specified in "
"configuration file"));
return -1;
}
if (!qemudCompressProgramAvailable(compress)) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Compression program for dump image format "
"in configuration file isn't available"));
return -1;
}
}
qemuDriverLock(driver); qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid); vm = virDomainFindByUUID(&driver->domains, dom->uuid);