On 10/12/2012 08:38 AM, Kevin Wolf wrote: >> Hmm. For 'qemu-img info', I can see two behaviors, both useful, when >> presented with a corrupt image. One is to error out right away (because >> qemu would be unable to use the image). But the other is for debugging >> WHY the image is corrupt, at which point I want qemu-img info to display >> as much information as possible, INCLUDING what backing file is recorded >> in the header, so that I can follow the loop and decide where to break >> the loop. Sounds like we might need another flag to bdrv_open() on >> whether to detect cycles; as well as fixing qemu-img info to check for >> cycles on its own when it bypasses normal cycle-checking in bdrv_open. > > Makes sense. Though I think BDRV_O_NO_BACKING is enough to implement > this functionality in qemu-img. We'd just have to have an error code > that allows qemu-img to check if we detected a loop so that it can start > searching the broken image.
Indeed - BDRV_O_NO_BACKING seems to be the flag that prevents bdrv_open from failing on a cycle, so the logic would be something like: Try a normal bdrv_open() if it succeeds image is fine, so recursively print it else if error indicated a loop init hash table while (1) if file in hash table break, since we identified the loop bdrv_open(BDRV_O_NO_BACKING) print this file, then add it to the hash table file = backing At any rate, adding this logic should be a separate patch, and not hold up Stefan's current patch. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature