'virStorageFileChainLookup' reports an error when the lookup of the
backing chain entry is unsuccessful. Since we possibly use it multiple
times when looking up backing for 'disk->mirror' the function can report
error which won't be actually reported.
Replace the call to virStorageFileChainLookup by lookup in the chain by
index.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e56351333c..44abe0ce93 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9951,7 +9951,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
virDomainDefPtr def)
{
virDomainDiskDefPtr disk = NULL;
- virStorageSourcePtr src = NULL;
+ virStorageSourcePtr n;
g_autofree char *target = NULL;
unsigned int idx;
@@ -9970,13 +9970,20 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
if (idx == 0)
return disk->src;
- if ((src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL)))
- return src;
+ for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
+ if (n->id == idx)
+ return n;
+ }
- if (disk->mirror &&
- (src = virStorageFileChainLookup(disk->mirror, NULL, NULL, idx, NULL)))
- return src;
+ if (disk->mirror) {
+ for (n = disk->mirror; virStorageSourceIsBacking(n); n = n->backingStore)
{
+ if (n->id == idx)
+ return n;
+ }
+ }
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("failed to find disk '%s'"), devstr);
return NULL;
}
--
2.28.0