]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSnapshotDiskHasBackingDisk: Use proper 'max_depth' when calling 'virStorageSource...
authorPeter Krempa <pkrempa@redhat.com>
Mon, 26 Jan 2026 15:39:24 +0000 (16:39 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jan 2026 09:42:24 +0000 (10:42 +0100)
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>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_snapshot.c

index ac56fc7cb433e0e4f1efa10f7f015af746128ceb..486a0e791397dfaf9cd801a85a0a7c30347a1a55 100644 (file)
@@ -6297,8 +6297,6 @@ qemuDomainStorageAlias(const char *device, int depth)
 }
 
 
-#define QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH 200
-
 /**
  * qemuDomainStorageSourceValidateDepth:
  * @src: storage source chain to validate
index 3396f929fd9da5ae60728028b7e4dce0c8dd6451..b9bb3386823992d79895da68224506ad7dc2adc3 100644 (file)
@@ -706,6 +706,7 @@ int qemuDomainCheckDiskStartupPolicy(virQEMUDriver *driver,
                                      size_t diskIndex,
                                      bool cold_boot);
 
+#define QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH 200
 int qemuDomainStorageSourceValidateDepth(virStorageSource *src,
                                          int add,
                                          const char *diskdst);
index 19bb6f8b3787e6694b862db8df55350b2cbeba4f..1628c33865afedd0fa7aac46a7201b73b5a5a2cb 100644 (file)
@@ -3145,7 +3145,9 @@ qemuSnapshotDiskHasBackingDisk(void *payload,
                               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)) {