{"record":{"id":"2ec2c44deb2455da","repo":"firecracker-microvm/firecracker","slug":"failed-to-clone-api-event-fd","errorCode":null,"errorMessage":"Failed to clone API event FD","messagePattern":"Failed to clone API event FD","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/firecracker/src/api_server_adapter.rs","lineNumber":178,"sourceCode":"    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        }\n        Err(err) => {\n            return Err(ApiServerError::FailedToBindAndRunHttpServer(err));\n        }\n    };\n    info_unrestricted!(\"Listening on API socket ({bind_path:?}).\");\n\n    let api_kill_switch_clone = api_kill_switch\n        .try_clone()","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/firecracker-microvm/firecracker/blob/0a745def42ddf4cc2a744d79a08a27ff50b5d27a/src/firecracker/src/api_server_adapter.rs#L160-L196","documentation":"Error \"Failed to clone API event FD\" thrown in firecracker-microvm/firecracker.","triggerScenarios":"Thrown at src/firecracker/src/api_server_adapter.rs:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the process file-descriptor limit; cloning the event FD fails when no fds are available.","Verify the source eventfd is still open at the time of the clone."],"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-14T05:17:10.506Z"}