qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr

When idx is 0 virStorageFileChainLookup returns the base (bottom) of the
backing chain rather than the top. This is expected by the callers of
qemuDomainGetStorageSourceByDevstr.

Add a special case for idx == 0
This commit is contained in:
Peter Krempa 2017-03-29 16:56:05 +02:00
parent e9f9690958
commit 20ee78bf9b

View File

@ -8605,7 +8605,10 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
goto cleanup;
}
src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
if (idx == 0)
src = disk->src;
else
src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
cleanup:
VIR_FREE(target);