Anthony Liguori wrote: > Uri Lublin wrote: >> Qcow2 extensions are build of magic (id) len (in bytes) and data. >> They reside between the end of the header and the filename. >> >> We can keep the backing file format in a such a qcow2 extension, to >> 1. Provide a way to know the backing file format without probing >> it (setting the format at creation time). >> 2. Enable using qcow2 format over host block devices. >> (only if the user specifically asks for it, by providing the format >> at creation time). >> >> I've added bdrv_create2 and drv->bdrv_create2 (implemented only >> by block-qcow2 currently) to pass the backing-format to create. >> >> Based on a work done by Shahar Frank. >> >> Also fixes a security flaw found by Daniel P. Berrange on [1] >> which summarizes: "Autoprobing: just say no." >> >> [1] http://lists.gnu.org/archive/html/qemu-devel/2008-12/msg01083.html >> >> Signed-off-by: Uri Lublin >> > > This made it through my regression testing but... > >> int bdrv_create(BlockDriver *drv, >> const char *filename, int64_t size_in_sectors, >> const char *backing_file, int flags) >> @@ -348,6 +362,9 @@ int bdrv_open2(BlockDriverState *bs, const char >> *filename, int flags, >> >> /* if there is a backing file, use it */ >> bs1 = bdrv_new(""); >> +/* if (drv) */ >> +/* pstrcpy(bs1->backing_format, >> sizeof(bs->backing_format), */ >> +/* drv->format_name); */ >> > > I don't know if I missed this before or it was added since v3 but I'm > curious why this is here and why it's commented out. > It's an old code, which should have been deleted. The purpose was to make sure the temporary-snapshot-file backing-file-format is known. This is now done with bdrv_create2, that I've added. You can delete it yourself or apply the attached patch (or squash patches) Alternatively I can send it to you again as a single patch (v5) Also I've noticed that a small fix is needed for BDRV_O_SNAPSHOT. e.g we should use bdrv_open2 (so we would not probe the image if the format is known), so I'm attaching a patch to fix that too. Again if you want I can resend it as a single patch (squashed with v4) or you can apply(squash) this patch yourself on top of my previous patches. Thanks, Uri.