Skip to content

Commit 14dcc4e

Browse files
committed
fix(vmm): preserve orphan VM workdir when no .removing marker
Only delete the VM workdir during cleanup if the .removing marker file is present (set by user-initiated remove_vm). Orphaned supervisor processes discovered at startup without the marker now have their workdir preserved, preventing accidental data loss on VMM restart.
1 parent 8630143 commit 14dcc4e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

vmm/src/app.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,17 @@ impl App {
351351
}
352352
}
353353

354-
// Delete the workdir (may already be gone, e.g. manual deletion before reload)
354+
// Only delete the workdir if the .removing marker is present (user-initiated removal).
355+
// Orphaned supervisor processes without the marker keep their data intact.
355356
let vm_path = self.work_dir(id);
356-
if vm_path.path().exists() {
357-
if let Err(err) = fs::remove_dir_all(&vm_path) {
358-
error!("Failed to remove VM directory for {id}: {err:?}");
357+
if vm_path.is_removing() {
358+
if vm_path.path().exists() {
359+
if let Err(err) = fs::remove_dir_all(&vm_path) {
360+
error!("failed to remove VM directory for {id}: {err:?}");
361+
}
359362
}
363+
} else if vm_path.path().exists() {
364+
info!("VM {id} workdir preserved (no .removing marker): {}", vm_path.path().display());
360365
}
361366

362367
// Free CID and remove from memory (last step)

0 commit comments

Comments
 (0)