Skip to content

Commit 7718835

Browse files
author
gitlab
committed
Merge branch 'fix/ZSTAC-80898' into '5.5.12'
fix(vm): handle NoState + Expunging safety net [ZSTAC-80898] See merge request zstackio/zstack!9275
2 parents 37f952e + 62e1626 commit 7718835

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,11 @@ public void handle(Map data) {
16031603
changeVmStateInDb(VmInstanceStateEvent.paused, () -> self.setHostUuid(currentHostUuid));
16041604
} else if (currentState == VmInstanceState.Stopped) {
16051605
changeVmStateInDb(VmInstanceStateEvent.stopped);
1606+
} else if (currentState == VmInstanceState.NoState) {
1607+
// ZSTAC-80898: When host reports NoState (e.g. QEMU crashed, libvirtd restarted),
1608+
// update DB to reflect actual state. Without this, VMs in intermediate states
1609+
// (Migrating, Starting, etc.) remain stuck in DB forever.
1610+
changeVmStateInDb(VmInstanceStateEvent.noState, () -> self.setHostUuid(currentHostUuid));
16061611
}
16071612

16081613
fireEvent.run();

header/src/main/java/org/zstack/header/vm/VmInstanceState.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ public enum VmInstanceState {
171171
new Transaction(VmInstanceStateEvent.stopped, VmInstanceState.Stopped),
172172
new Transaction(VmInstanceStateEvent.expunging, VmInstanceState.Expunging)
173173
);
174+
// ZSTAC-80898: Expunging safety net — if expunge fails, allow recovery
175+
// instead of leaving VM permanently stuck.
176+
Expunging.transactions(
177+
new Transaction(VmInstanceStateEvent.destroyed, VmInstanceState.Destroyed),
178+
new Transaction(VmInstanceStateEvent.stopped, VmInstanceState.Stopped),
179+
new Transaction(VmInstanceStateEvent.unknown, VmInstanceState.Unknown)
180+
);
174181
Destroyed.transactions(
175182
new Transaction(VmInstanceStateEvent.stopped, VmInstanceState.Stopped)
176183
);

0 commit comments

Comments
 (0)