]> xenbits.xensource.com Git - libvirt.git/commit
conf: fix detection of infinite backing loop
authorEric Blake <eblake@redhat.com>
Sat, 5 Apr 2014 00:05:22 +0000 (18:05 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 8 Apr 2014 19:28:19 +0000 (13:28 -0600)
commitaf095bfa0de52819eec15be734798ea11cac0411
tree269d98b1faa6ed6b525181f1e58f5584d897354f
parent2fe658ad906f23f08ac36ba5f727d27be494998e
conf: fix detection of infinite backing loop

While trying to refactor the backing file chain, I noticed that
if you have a self-referential qcow2 file via a relative name:

qemu-img create -f qcow2 loop 10M
qemu-img rebase -u -f qcow2 -F qcow2 -b loop loop

then libvirt was creating a chain 2 deep before realizing it
had hit a loop; furthermore, virStorageFileChainCheckBroken
was not identifying the chain as broken.  With this patch,
the loop is detected when the chain is only 1 deep; still
enough for storage volume XML to display the file, but now
with a proper error report about where the loop was found.

This patch adds a parameter to virStorageFileGetMetadataRecurse,
so that errors at the top of the chain remain unchanged; messages
issued for backing files now use the name provided by the user
instead of the canonical name (for VDSM, which uses relative
symlinks to device mapper block devices, this is actually more
useful).

* src/util/virstoragefile.c (virStorageFileGetMetadataRecurse):
Add parameter, require canonical path up front.  Mark chain
broken on OOM or loop detection.
(virStorageFileGetMetadata): Pass in canonical name.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/virstoragefile.c