From 6ad929641206b073c83727b32ca17167d5be4818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Jandre?= <48719461+JoaoJandre@users.noreply.github.com> Date: Mon, 21 Jul 2025 08:17:27 -0300 Subject: [PATCH] Fix KVM incremental snapshot removal when using multiple secondary storages (#11180) When removing an incremental snapshot (For both KVM and XenServer), it is checked if the snapshot has a child or not. If it has, then the snapshot is not removed from the storage. For KVM incremental snapshots, snapshots in the same chain may be on different secondary storages (within the same zone). However, the child search process only considers snapshots from the same secondary storage as theirs. Therefore, if a snapshot has its parent snapshot on a different secondary storage, it will be completely removed, making the snapshot chain inconsistent. --- .../apache/cloudstack/storage/snapshot/SnapshotObject.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java index 178d42f5c74..6cec193cd0a 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotObject.java @@ -155,7 +155,9 @@ public class SnapshotObject implements SnapshotInfo { @Override public SnapshotInfo getChild() { QueryBuilder sc = QueryBuilder.create(SnapshotDataStoreVO.class); - sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId()); + if (!HypervisorType.KVM.equals(snapshot.getHypervisorType())) { + sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId()); + } sc.and(sc.entity().getRole(), Op.EQ, store.getRole()); sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error); sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId());