[libvirt] [PATCH v3 2/5] Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.

Hu Tao hutao at cn.fujitsu.com
Tue Nov 30 07:12:54 UTC 2010


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 |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f00d8a3..ad67e52 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -137,6 +137,8 @@ struct _qemuDomainObjPrivate {
     int persistentAddrs;
 };
 
+static int getCompressionType(struct qemud_driver *driver);
+
 static int qemudShutdown(void);
 
 static void qemuDriverLock(struct qemud_driver *driver)
@@ -6055,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;
+static int getCompressionType(struct qemud_driver *driver)
+{
     int compress;
-    qemuDomainObjPrivatePtr priv;
+
     /*
      * We reuse "save" flag for "dump" here. Then, we can support the same
      * format in "save" and "dump".
@@ -6073,18 +6069,33 @@ static int qemudDomainCoreDump(virDomainPtr dom,
     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"));
+            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;
+    int compress;
+    qemuDomainObjPrivatePtr priv;
+
+    compress = getCompressionType(driver);
 
     qemuDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
-- 
1.7.3


-- 
Thanks,
Hu Tao




More information about the libvir-list mailing list