[ENHANCEMENT] Resource Cleanup on Panic/Crash #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Network interfaces and IPTables rules remain on the host if the process crashes.
Proposed Fix
Implement a signal handler or a garbage collection routine in
chvm doctor.implemented in #26
Change 1: Auto-cleanup in refresh_status()
Added teardown_network + cleanup_storage() to refresh_status() when a dead VM process is detected
Previously it only marked the VM as Stopped — now it cleans up network interfaces and storage before updating state
Change 2: chvm doctor --gc
Added --gc flag to the doctor command for manual garbage collection
Level 1 (state-aware): Uses refresh_status() to detect crashed VMs and clean their resources
Level 2 (stateless orphan detection): Scans for tap-* interfaces not belonging to any running VM and removes them. Scans iptables nat rules referencing chvm-subnet IPs (192.168.200.X) not owned by a running VM and removes them