]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Log warning if storage magic matches, but version does not
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 13 Dec 2012 14:22:51 +0000 (14:22 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 13 Dec 2012 15:00:12 +0000 (15:00 +0000)
To help us detect when new storage file versions come into
existance log a warning if the storage file magic matches,
but the version does not

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/storage_file.c

index 17a47cf02684c05ea844e6b1fb53afd99eb51b57..4281d90d05b2f745211b4b2f81c0346cb88537dd 100644 (file)
@@ -756,16 +756,26 @@ virStorageFileProbeFormatFromBuf(const char *path,
 {
     int format = VIR_STORAGE_FILE_RAW;
     int i;
+    int possibleFormat = VIR_STORAGE_FILE_RAW;
+    VIR_DEBUG("path=%s", path);
 
     /* First check file magic */
     for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
-        if (virStorageFileMatchesMagic(i, buf, buflen) &&
-            virStorageFileMatchesVersion(i, buf, buflen)) {
+        if (virStorageFileMatchesMagic(i, buf, buflen)) {
+            if (!virStorageFileMatchesVersion(i, buf, buflen)) {
+                possibleFormat = i;
+                continue;
+            }
             format = i;
             goto cleanup;
         }
     }
 
+    if (possibleFormat != VIR_STORAGE_FILE_RAW)
+        VIR_WARN("File %s matches %s magic, but version is wrong. "
+                 "Please report new version to libvir-list@redhat.com",
+                 path, virStorageFileFormatTypeToString(possibleFormat));
+
     /* No magic, so check file extension */
     for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
         if (virStorageFileMatchesExtension(i, path)) {