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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ed1ea6b..b5b4e83 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)
@@ -6030,16 +6032,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".
@@ -6048,18 +6044,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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]