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.
---
src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++----------------
1 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4877692..e6ba1a7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6057,16 +6057,10 @@ cleanup:
return ret;
}
-static int qemudDomainCoreDump(virDomainPtr dom,
- const char *path,
- int flags ATTRIBUTE_UNUSED) {
- struct qemud_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int resume = 0, paused = 0;
- int ret = -1, fd = -1;
- virDomainEventPtr event = NULL;
- int compress;
- qemuDomainObjPrivatePtr priv;
+static enum qemud_save_formats getCompressionType(struct qemud_driver *driver)
+{
+ enum qemud_save_formats compress;
+
/*
* We reuse "save" flag for "dump" here. Then, we can support the
same
* format in "save" and "dump".
@@ -6074,19 +6068,34 @@ static int qemudDomainCoreDump(virDomainPtr dom,
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 ((signed)compress < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Invalid dump image format specified in "
+ "configuration file"));
+ 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"));
- return -1;
+ return QEMUD_SAVE_FORMAT_RAW;
}
}
+ return compress;
+}
+
+static int qemudDomainCoreDump(virDomainPtr dom,
+ const char *path,
+ int flags ATTRIBUTE_UNUSED) {
+ struct qemud_driver *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ int resume = 0, paused = 0;
+ int ret = -1, fd = -1;
+ virDomainEventPtr event = NULL;
+ enum qemud_save_formats compress;
+ qemuDomainObjPrivatePtr priv;
+
+ compress = getCompressionType(driver);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
--
1.7.3
--
Thanks,
Hu Tao