At compression, external programs are used but it is not checked whether
the program is available or not.
Check it at parsing qemu.conf and find problems in early stage.

---
 src/qemu/qemu_conf.c |   46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

Index: libvirt-0.8.4/src/qemu/qemu_conf.c
===================================================================
--- libvirt-0.8.4.orig/src/qemu/qemu_conf.c
+++ libvirt-0.8.4/src/qemu/qemu_conf.c
@@ -316,22 +316,54 @@ int qemudLoadDriverConfig(struct qemud_d
     p = virConfGetValue (conf, "save_image_format");
     CHECK_TYPE ("save_image_format", VIR_CONF_STRING);
     if (p && p->str) {
-        VIR_FREE(driver->saveImageFormat);
-        if (!(driver->saveImageFormat = strdup(p->str))) {
-            virReportOOMError();
-            virConfFree(conf);
-            return -1;
-        }
+       int find = 1;
+       if (strcmp(p->str, "raw")) {
+           char *c;
+           c = virFindFileInPath(p->str);
+           if (!c)
+               find = 0;
+           else
+             VIR_FREE(c);
+       }
+       VIR_FREE(driver->saveImageFormat);
+       if (find) {
+            if (!(driver->saveImageFormat = strdup(p->str))) {
+               virReportOOMError();
+               virConfFree(conf);
+               return -1;
+           }
+       } else {
+           qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                    "save_image_format cannot find program %s", p->str);
+           virConfFree(conf);
+           return -1;
+       }
     }
 
     p = virConfGetValue (conf, "dump_image_format");
     CHECK_TYPE ("dump_image_format", VIR_CONF_STRING);
     if (p && p->str) {
+       int find = 1;
+       if (strcmp(p->str, "raw")) {
+            char *c;
+           c = virFindFileInPath(p->str);
+           if (!c)
+               find = 0;
+           else
+               VIR_FREE(c);
+       }
        VIR_FREE(driver->dumpImageFormat);
-       if (!(driver->dumpImageFormat = strdup(p->str))) {
+       if (find) {
+           if (!(driver->dumpImageFormat = strdup(p->str))) {
                virReportOOMError();
                virConfFree(conf);
                return -1;
+           }
+       } else {
+           qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                    "dump_image_format cannot find program %s", p->str);
+           virConfFree(conf);
+           return -1;
        }
     }
 

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to