[PATCH 2/2] check compression program at virsh save and dump

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

 



>From bc55de1e6a8506adcde52aa95e2be9d4bb5bfb2e Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
Date: Thu, 28 Oct 2010 17:51:18 +0900
Subject: [PATCH 2/2] check compression program availabilityy of virsh save and dump.

---
 src/qemu/qemu_driver.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 51ad50b..61dc6e8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5740,6 +5740,22 @@ cleanup:
     return ret;
 }
 
+/* returns 1 if a compression program is available in PATH */
+static int qemudCompressProgramAvailable(int compress)
+{
+    const char *prog;
+    char *c;
+
+    if (compress == QEMUD_SAVE_FORMAT_RAW)
+        return 1;
+    prog = qemudSaveCompressionTypeToString(compress);
+    c = virFindFileInPath(prog);
+    if (!c)
+        return 0;
+    VIR_FREE(c);
+    return 1;
+}
+
 static int qemudDomainSave(virDomainPtr dom, const char *path)
 {
     struct qemud_driver *driver = dom->conn->privateData;
@@ -5759,6 +5775,12 @@ static int qemudDomainSave(virDomainPtr dom, const char *path)
                                     "in configuration file"));
             return -1;
         }
+        if (!qemudCompressProgramAvailable(compressed)) {
+            qemuReportError(VIR_ERR_OPERATION_FAILED,
+                            "%s", _("Compression program for image format "
+                                    "in configuration file isn't available"));
+            return -1;
+        }
     }
 
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -5922,6 +5944,12 @@ static int qemudDomainCoreDump(virDomainPtr dom,
                              "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);
-- 
1.7.2.3


--
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]