Skip to content

Commit be2d754

Browse files
committed
Possible race condition between VMM thread and API thread (FC 1.2)
firecracker-microvm@174e042
1 parent 32de822 commit be2d754

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/firecracker/src/api_server_adapter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl MutEventSubscriber for ApiServerAdapter {
7171
let event_set = event.event_set();
7272

7373
if source == self.api_event_fd.as_raw_fd() && event_set == EventSet::IN {
74+
let _ = self.api_event_fd.read();
7475
match self.from_api.try_recv() {
7576
Ok(api_request) => {
7677
let request_is_pause = *api_request == VmmAction::Pause;
@@ -101,7 +102,6 @@ impl MutEventSubscriber for ApiServerAdapter {
101102
panic!("The channel's sending half was disconnected. Cannot receive data.");
102103
}
103104
};
104-
let _ = self.api_event_fd.read();
105105
} else {
106106
error!("Spurious EventManager event for handler: ApiServerAdapter");
107107
}
@@ -129,7 +129,7 @@ pub(crate) fn run_with_api(
129129
// FD to notify of API events. This is a blocking eventfd by design.
130130
// It is used in the config/pre-boot loop which is a simple blocking loop
131131
// which only consumes API events.
132-
let api_event_fd = EventFd::new(0).expect("Cannot create API Eventfd.");
132+
let api_event_fd = EventFd::new(libc::EFD_SEMAPHORE).expect("Cannot create API Eventfd.");
133133

134134
// Channels for both directions between Vmm and Api threads.
135135
let (to_vmm, from_api) = channel();

0 commit comments

Comments
 (0)