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.
This commit is contained in:
João Jandre 2025-07-21 08:17:27 -03:00 committed by GitHub
parent c5da9e6188
commit 6ad9296412
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -155,7 +155,9 @@ public class SnapshotObject implements SnapshotInfo {
@Override
public SnapshotInfo getChild() {
QueryBuilder<SnapshotDataStoreVO> 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());