summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorXiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>2019-04-23 17:09:50 +0800
committerCommit Bot <commit-bot@chromium.org>2019-06-10 17:09:03 +0000
commit44bb3dd9095e1c70f17f7960ea269e4bb1cd446f (patch)
tree48f0d2be4898a223a50dfda5419b808827874064 /src/linux.rs
parentb6515a91675935dcaa9833c4a64c8a35b0971edb (diff)
downloadcrosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar.gz
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar.bz2
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar.lz
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar.xz
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.tar.zst
crosvm-44bb3dd9095e1c70f17f7960ea269e4bb1cd446f.zip
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>
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/linux.rs b/src/linux.rs
index 271cc5b..9de014a 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -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)?;
             }
         }