diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7aeeab0739c3dfe7422e5188321c77b52f7d62e2..f8e41025883d488aca4e10d848d263ef149a615b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -5053,14 +5053,15 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, ret = 0; goto cleanup; } + + backingStore->id = depth; + src->backingStore = g_steal_pointer(&backingStore); } else { /* add terminator */ - if (!(backingStore = virStorageSourceNew())) + if (!(src->backingStore = virStorageSourceNew())) goto cleanup; } - src->backingStore = g_steal_pointer(&backingStore); - if (src->externalDataStoreRaw) { g_autoptr(virStorageSource) externalDataStore = NULL; @@ -5080,8 +5081,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, ret = 0; cleanup: - if (virStorageSourceHasBacking(src)) - src->backingStore->id = depth; virStorageFileDeinit(src); return ret; }