
On 02/04/2013 07:03 PM, Daniel P. Berrange wrote:
On Mon, Feb 04, 2013 at 06:53:34PM +0100, Martin Kletzander wrote:
On 02/04/2013 04:53 PM, Daniel P. Berrange wrote:
On Mon, Feb 04, 2013 at 04:46:53PM +0100, Martin Kletzander wrote: [...]
+ + /* not fully supported, but qemu knows it, so we should be able to + * handle this at least basically */ + [VIR_STORAGE_FILE_VDI] = { NULL, ".vdi", LV_LITTLE_ENDIAN, + -2, 0, 0, 0, 0, -1, NULL},
We can do better than that - look at block/vdi.c in QEMU GIT tree to find out the offsets / values for version number, magic signature at least, even if you ignore backing files for now.
Thanks for pointing that out, I've got a v2 and will send it after some testing. However, it looks like VDI doesn't have a magic, because there is a 40 Byte string at the start that cacn contain anything the creating binary puts there. For example qemu-img uses "<<< QEMU VM Virtual Disk Image >>>\n". According to [1], I'm adding "<<<" as the magic, because we don't fail if it doesn't match and we can still match it by the extension then.
No, you need to look at the 'signature' field of the header instead, which has a fixed magic value
#define VDI_SIGNATURE 0xbeda107f
But the struct mapped to the header starts like this: typedef struct { char text[0x40]; uint32_t signature; ... Of course that would just mean adding one more parameter to the FileTypeInfo struct, but I thought it's not magic then. However, I checked that and you're right, I was wrong, because according to magic(5) it can be anywhere. The magic file '/usr/share/misc/magic.mgc' also matches the signature, so I'm using that. Martin