Always clean stale taps before creating new ones

deleteTap before createTap in all four call sites:
snapshot restore, cold boot, agent start, snapshot create.
Prevents "Device or resource busy" from leftover taps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:07:24 +00:00
parent 6485705d4b
commit cf2d2d31b7
3 changed files with 4 additions and 0 deletions

View File

@@ -268,6 +268,7 @@ export async function startAgent(
// Setup network
ensureBridge();
ensureNat();
deleteTap(tapDevice); // clean stale tap from previous run
createTap(tapDevice);
// Boot VM

View File

@@ -63,6 +63,7 @@ export async function createSnapshot() {
log("Setting up network...");
ensureBridge();
ensureNat();
deleteTap(snap.tapDevice); // clean stale tap from previous run
createTap(snap.tapDevice);
let proc: ChildProcess | null = null;

View File

@@ -78,6 +78,7 @@ export class VMInstance {
log(verbose, `VM ${id}: restoring from snapshot...`);
ensureBridge();
ensureNat();
deleteTap(snap.tapDevice); // clean stale tap from previous run
createTap(snap.tapDevice);
// Spawn firecracker and load snapshot
@@ -155,6 +156,7 @@ export class VMInstance {
log(verbose, `VM ${id}: creating tap ${tapDevice}...`);
ensureBridge();
ensureNat();
deleteTap(tapDevice); // clean stale tap from previous run
createTap(tapDevice);
log(verbose, `VM ${id}: booting...`);