{"record":{"id":"3bbdbcd86dde83b5","repo":"firecracker-microvm/firecracker","slug":"cannot-create-api-kill-switch","errorCode":null,"errorMessage":"Cannot create API kill switch.","messagePattern":"Cannot create API kill switch\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/firecracker/src/api_server_adapter.rs","lineNumber":170,"sourceCode":"#[allow(clippy::too_many_arguments)]\npub(crate) fn run_with_api(\n    seccomp_filters: &mut BpfThreadMap,\n    config_json: Option<String>,\n    bind_path: PathBuf,\n    instance_info: InstanceInfo,\n    process_time_reporter: ProcessTimeReporter,\n    boot_timer_enabled: bool,\n    pci_enabled: bool,\n    api_payload_limit: usize,\n    mmds_size_limit: usize,\n    metadata_json: Option<&str>,\n) -> Result<(), ApiServerError> {\n    // FD to notify of API events. This is a blocking eventfd by design.\n    // It is used in the config/pre-boot loop which is a simple blocking loop\n    // which only consumes API events.\n    let api_event_fd = EventFd::new(libc::EFD_SEMAPHORE).expect(\"Cannot create API Eventfd.\");\n    // FD used to signal API thread to stop/shutdown.\n    let api_kill_switch = EventFd::new(libc::EFD_NONBLOCK).expect(\"Cannot create API kill switch.\");\n\n    // Channels for both directions between Vmm and Api threads.\n    let (to_vmm, from_api) = channel();\n    let (to_api, from_vmm) = channel();\n\n    let to_vmm_event_fd = api_event_fd\n        .try_clone()\n        .expect(\"Failed to clone API event FD\");\n    let api_seccomp_filter = seccomp_filters\n        .remove(\"api\")\n        .expect(\"Missing seccomp filter for API thread.\");\n\n    let mut server = match HttpServer::new(&bind_path) {\n        Ok(s) => s,\n        Err(ServerError::IOError(inner)) if inner.kind() == std::io::ErrorKind::AddrInUse => {\n            let sock_path = bind_path.display().to_string();\n            return Err(ApiServerError::FailedToBindSocket(sock_path));\n        }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/firecracker-microvm/firecracker/blob/0a745def42ddf4cc2a744d79a08a27ff50b5d27a/src/firecracker/src/api_server_adapter.rs#L152-L188","documentation":"Error \"Cannot create API kill switch.\" thrown in firecracker-microvm/firecracker.","triggerScenarios":"Thrown at src/firecracker/src/api_server_adapter.rs:170 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the process file-descriptor limit; eventfd creation for the kill switch fails on fd exhaustion.","Verify eventfd creation is permitted by the active seccomp filter."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0a745def42ddf4cc2a744d79a08a27ff50b5d27a","analyzedAt":"2026-08-19T05:27:02.517Z","contentChangedAt":"2026-08-19T05:27:02.517Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}