]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSnapshotDiskHasBackingDisk: Avoid call of virStorageSourceIsSameLocation with...
authorPeter Krempa <pkrempa@redhat.com>
Fri, 23 Jan 2026 07:42:50 +0000 (08:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jan 2026 09:42:24 +0000 (10:42 +0100)
When the 'backingStore' pointer is not populated the function calls
'virStorageSourceGetMetadata' to try to populate it but if the on-disk
metadata doesn't have a backing image (e.g. if it's the 'base' image of
the chain) the 'backingStore' or the metadata fetcher fails the pointer
will still be NULL.

The function then calls 'virStorageSourceIsSameLocation' but the
internal functions for dealing with storage sources don't handle NULL
gracefully.

Since the code calling 'qemu-img' based on the data detected here
doesn't actually raise errors if the operations fail there's no point
in raising errors here either.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/844
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_snapshot.c

index e738afffc315191e25b171382c2afbca03cc3757..8f58df3b4507bbfe18464302f36e3d1d1ad6b1d6 100644 (file)
@@ -3147,7 +3147,8 @@ qemuSnapshotDiskHasBackingDisk(void *payload,
         if (!disk->src->backingStore)
             ignore_value(virStorageSourceGetMetadata(disk->src, uid, gid, 1, false));
 
-        if (virStorageSourceIsSameLocation(disk->src->backingStore, iterdata->diskSrc)) {
+        if (disk->src->backingStore &&
+            virStorageSourceIsSameLocation(disk->src->backingStore, iterdata->diskSrc)) {
             struct _qemuSnapshotDisksWithBackingStoreData *data =
                 g_new0(struct _qemuSnapshotDisksWithBackingStoreData, 1);