Skip to content

Commit

Permalink
Properly handle errors from the fuse device.
Browse files Browse the repository at this point in the history
At the moment, we are indiscriminately returning a SessionFailure("epoll error")
if any of the registered file descriptors would return an error upon read. This
means that the more detailed error handling code below can never be reached.

Instead, attempt to read from fuse device when the device is either
readable *or* has an error state, and then handle the error as we always
intended.

Fixes: cloud-hypervisor#197.
  • Loading branch information
nrath-js committed Dec 4, 2024
1 parent 36cd288 commit ae28f4d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/transport/fusedev/linux_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ impl FuseChannel {
}

for event in events.iter() {
if event.is_readable() {
// We will handle errors when reading from the fuse device
if event.is_readable() || event.is_error() {
match event.token() {
EXIT_FUSE_EVENT => need_exit = true,
FUSE_DEV_EVENT => fusereq_available = true,
Expand All @@ -350,9 +351,6 @@ impl FuseChannel {
return Err(SessionFailure(format!("unexpected epoll event: {}", x.0)));
}
}
} else if event.is_error() {
info!("FUSE channel already closed!");
return Err(SessionFailure("epoll error".to_string()));
} else {
// We should not step into this branch as other event is not registered.
panic!("unknown epoll result events");
Expand Down

0 comments on commit ae28f4d

Please sign in to comment.