mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 17:44:10 +00:00
vhost_user_devices: Remove O_NONBLOCK from given kick FD
Remove O_NONBLOCK from kick FD as uring_executor assumes so. Otherwise, we may get EAGAIN when we read a value. This patch is needed to use QEMU as a vmm. BUG=b:190450677 TEST=run QEMU and vhost-user-net-devices with uring_executor Change-Id: I8dc533c824909eb0298e4264f45d7a62998ebc6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2950028 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
parent
53103e9df4
commit
8509e2229c
3 changed files with 11 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1171,6 +1171,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"remain",
|
||||
"sync",
|
||||
"sys_util",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"virtio_sys",
|
||||
|
|
|
@ -32,6 +32,7 @@ net_util = { path = "../net_util", optional = true }
|
|||
once_cell = "1.7.2"
|
||||
remain = "*"
|
||||
sync = { path = "../sync" }
|
||||
sys_util = { path = "../sys_util" }
|
||||
thiserror = "*"
|
||||
virtio_sys = { path = "../virtio_sys", optional = true }
|
||||
vm_memory = { path = "../vm_memory" }
|
||||
|
|
|
@ -56,6 +56,7 @@ use cros_async::{AsyncError, AsyncWrapper, Executor};
|
|||
use devices::virtio::{Queue, SignalableInterrupt};
|
||||
use remain::sorted;
|
||||
use sync::Mutex;
|
||||
use sys_util::clear_fd_flags;
|
||||
use thiserror::Error as ThisError;
|
||||
use vm_memory::{GuestAddress, GuestMemory, MemoryRegion};
|
||||
use vmm_vhost::vhost_user::message::{
|
||||
|
@ -475,6 +476,14 @@ impl<B: VhostUserBackend> VhostUserSlaveReqHandlerMut for DeviceRequestHandler<B
|
|||
error!("invalid fd is given: {}", e);
|
||||
VhostError::InvalidParam
|
||||
})?;
|
||||
|
||||
// Remove O_NONBLOCK from kick_fd. Otherwise, uring_executor will fails when we read
|
||||
// values via `next_val()` later.
|
||||
if let Err(e) = clear_fd_flags(rd, libc::O_NONBLOCK) {
|
||||
error!("failed to remove O_NONBLOCK for kick fd: {}", e);
|
||||
return Err(VhostError::InvalidParam);
|
||||
}
|
||||
|
||||
// Safe because the FD is now owned.
|
||||
let kick_evt = unsafe { Event::from_raw_descriptor(rd) };
|
||||
|
||||
|
|
Loading…
Reference in a new issue