The 'max_depth' argument of 'virStorageSourceGetMetadata' doesn't just
limit how far the function goes but also fails completely if the chain
is deeper than the passed value.
In 'qemuSnapshotDiskHasBackingDisk' we only care about finding the
backing image, so just one level below, the passed path, but due to the
above setting '1' as max_depth will make the function simply fail every
time.
Extract and reuse QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH as the
detection depth. While '200' layers is overkill for this code, we also
start a full qemu instance just to delete an snapshot so this doens't
matter and still protects from self-referential images.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
}
-#define QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH 200
-
/**
* qemuDomainStorageSourceValidateDepth:
* @src: storage source chain to validate
size_t diskIndex,
bool cold_boot);
+#define QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH 200
int qemuDomainStorageSourceValidateDepth(virStorageSource *src,
int add,
const char *diskdst);
NULL, &uid, &gid);
if (!disk->src->backingStore)
- ignore_value(virStorageSourceGetMetadata(disk->src, uid, gid, 1, false));
+ ignore_value(virStorageSourceGetMetadata(disk->src, uid, gid,
+ QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH,
+ false));
if (disk->src->backingStore &&
virStorageSourceIsSameLocation(disk->src->backingStore, iterdata->diskSrc)) {