From: Hu Tao Date: Tue, 30 Nov 2010 07:12:54 +0000 (+0800) Subject: Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails. X-Git-Tag: v0.8.7~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b6f13bb7002da76db15242e1d996e8a6222a754;p=thirdparty%2Flibvirt.git 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. --- diff --git a/AUTHORS b/AUTHORS index 16c755daa1..ca2414c033 100644 --- a/AUTHORS +++ b/AUTHORS @@ -136,6 +136,7 @@ Patches have also been contributed by: Osier Yang Kamezawa Hiroyuki Wen Congyang + Hu Tao [....send patches to get your name here....] diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4877692e86..fcb90a3635 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6057,36 +6057,46 @@ 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) +{ + int compress = QEMUD_SAVE_FORMAT_RAW; + /* * We reuse "save" flag for "dump" here. Then, we can support the same * 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; + 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")); - return -1; + "in configuration file isn't available, " + "using raw")); + 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);