From af3f3bbecd363e58556427fddb98beb003ed1fcc Mon Sep 17 00:00:00 2001 From: Hikaru Nishida Date: Fri, 21 May 2021 12:03:54 +0900 Subject: [PATCH] linux: Set recv timeout for balloon_host_tube to avoid deadlock Before this change, crosvm process will be stall when `crosvm balloon_stats` command is called before the first message is received because the logic waits reply from balloon device forever and it blocks the VM going forward. This CL sets recv timeout on balloon_host_tube to unblock the execution in such case. BUG=None TEST=Sent `crosvm ballon_stats ` command right after crosvm started and observed Resource temporarily unavailable error instead of stall. Change-Id: I9e7716fdbd3493846993d0a3f727eed2043df4c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2909697 Tested-by: kokoro Commit-Queue: Hikaru Nishida Reviewed-by: Dylan Reid Reviewed-by: Charles William Dick --- src/linux.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/linux.rs b/src/linux.rs index 77949e8c13..d145e57175 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -2513,6 +2513,10 @@ where control_tubes.push(TaggedControlTube::VmMemory(wayland_host_tube)); // Balloon gets a special socket so balloon requests can be forwarded from the main process. let (balloon_host_tube, balloon_device_tube) = Tube::pair().map_err(Error::CreateTube)?; + // Set recv timeout to avoid deadlock on sending BalloonControlCommand before guest is ready. + balloon_host_tube + .set_recv_timeout(Some(Duration::from_millis(100))) + .map_err(Error::CreateTube)?; // Create one control socket per disk. let mut disk_device_tubes = Vec::new();