From: Daniel P. Berrange Date: Thu, 13 Dec 2012 14:25:10 +0000 (+0000) Subject: Fix probing of QED file format X-Git-Tag: v1.0.1-rc2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32bef82a2d061fc131ab26c6d8ee09705ccab5c4;p=thirdparty%2Flibvirt.git Fix probing of QED file format The QED file format is non-versioned, so although the magic value matched, libvirt rejected it due to lack of a version number to compare against. We need to distinguish this case by allowing a value of '-2' to indicate a non-versioned file where only the magic is required to match Signed-off-by: Daniel P. Berrange --- diff --git a/src/util/storage_file.c b/src/util/storage_file.c index deb79e9b6a..83a05b3929 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -174,8 +174,8 @@ static struct FileTypeInfo const fileTypeInfo[] = { }, [VIR_STORAGE_FILE_QED] = { /* http://wiki.qemu.org/Features/QED */ - "QED\0", NULL, - LV_LITTLE_ENDIAN, -1, -1, + "QED", NULL, + LV_LITTLE_ENDIAN, -2, -1, QED_HDR_IMAGE_SIZE, 8, 1, -1, qedGetBackingStore, }, [VIR_STORAGE_FILE_VMDK] = { @@ -612,6 +612,10 @@ virStorageFileMatchesVersion(int format, if (fileTypeInfo[format].versionOffset == -1) return false; + /* -2 == non-versioned file format, so trivially match */ + if (fileTypeInfo[format].versionOffset == -2) + return true; + if ((fileTypeInfo[format].versionOffset + 4) > buflen) return false;