mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
src/linux.rs: Modify socket instead of add socket when remove other sockets
When an ill socket is detected, it will be removed from poll_context and control_sockets, then the remaining good sockets should change their indices, So modify should be used instead of add, as all of them have been added into poll_context already, the add will return an error. This change is merge of another change at I977be57ea0898cc8226505f7d3da103a46ea626c that was identical to this one except it contained the following similar commit message: linux: when renumbering control sockets, use modify instead of add In some circumstances, a VM control socket will get removed from the list of control sockets in the run_control loop. Usually, the last control socket in the list gets removed, but if that is not the case, the control sockets will get reordered to fill in the gap in the list. The `add` method of `PollContext` was used to change the token used for a given control socket, when `modify` should have been used instead. The problem with using `add` when a control socket is already part of a `PollContext` is that it will return an error and terminate crosvm. This CL fixes that issue. BUG=none TEST="crosvm run --vfio=$GVT_UUID", then run many gpu workloads in guest TEST=crosvm run --gpu Change-Id: Ic00a781d8839e652e2a8fd54ccd8e55849fa20bb Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Signed-off-by: Zach Reizner <zachr@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581151 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
b6515a9167
commit
44bb3dd909
1 changed files with 7 additions and 2 deletions
|
@ -41,7 +41,8 @@ use sys_util::{
|
|||
self, block_signal, clear_signal, drop_capabilities, error, flock, get_blocked_signals,
|
||||
get_group_id, get_user_id, getegid, geteuid, info, register_signal_handler, set_cpu_affinity,
|
||||
validate_raw_fd, warn, EventFd, FlockOperation, GuestAddress, GuestMemory, Killable,
|
||||
MemoryMapping, PollContext, PollToken, Protection, SignalFd, Terminal, TimerFd, SIGRTMIN,
|
||||
MemoryMapping, PollContext, PollToken, Protection, SignalFd, Terminal, TimerFd, WatchingEvents,
|
||||
SIGRTMIN,
|
||||
};
|
||||
use vhost;
|
||||
use vm_control::{
|
||||
|
@ -1740,7 +1741,11 @@ fn run_control(
|
|||
control_sockets.swap_remove(index);
|
||||
if let Some(socket) = control_sockets.get(index) {
|
||||
poll_ctx
|
||||
.add(socket, Token::VmControl { index })
|
||||
.modify(
|
||||
socket,
|
||||
WatchingEvents::empty().set_read(),
|
||||
Token::VmControl { index },
|
||||
)
|
||||
.map_err(Error::PollContextAdd)?;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue