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:
@@ -268,6 +268,7 @@ export async function startAgent(
|
|||||||
// Setup network
|
// Setup network
|
||||||
ensureBridge();
|
ensureBridge();
|
||||||
ensureNat();
|
ensureNat();
|
||||||
|
deleteTap(tapDevice); // clean stale tap from previous run
|
||||||
createTap(tapDevice);
|
createTap(tapDevice);
|
||||||
|
|
||||||
// Boot VM
|
// Boot VM
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ export async function createSnapshot() {
|
|||||||
log("Setting up network...");
|
log("Setting up network...");
|
||||||
ensureBridge();
|
ensureBridge();
|
||||||
ensureNat();
|
ensureNat();
|
||||||
|
deleteTap(snap.tapDevice); // clean stale tap from previous run
|
||||||
createTap(snap.tapDevice);
|
createTap(snap.tapDevice);
|
||||||
|
|
||||||
let proc: ChildProcess | null = null;
|
let proc: ChildProcess | null = null;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export class VMInstance {
|
|||||||
log(verbose, `VM ${id}: restoring from snapshot...`);
|
log(verbose, `VM ${id}: restoring from snapshot...`);
|
||||||
ensureBridge();
|
ensureBridge();
|
||||||
ensureNat();
|
ensureNat();
|
||||||
|
deleteTap(snap.tapDevice); // clean stale tap from previous run
|
||||||
createTap(snap.tapDevice);
|
createTap(snap.tapDevice);
|
||||||
|
|
||||||
// Spawn firecracker and load snapshot
|
// Spawn firecracker and load snapshot
|
||||||
@@ -155,6 +156,7 @@ export class VMInstance {
|
|||||||
log(verbose, `VM ${id}: creating tap ${tapDevice}...`);
|
log(verbose, `VM ${id}: creating tap ${tapDevice}...`);
|
||||||
ensureBridge();
|
ensureBridge();
|
||||||
ensureNat();
|
ensureNat();
|
||||||
|
deleteTap(tapDevice); // clean stale tap from previous run
|
||||||
createTap(tapDevice);
|
createTap(tapDevice);
|
||||||
|
|
||||||
log(verbose, `VM ${id}: booting...`);
|
log(verbose, `VM ${id}: booting...`);
|
||||||
|
|||||||
Reference in New Issue
Block a user