Starts a thread to accept incoming connections and handle them. These additional connections are used to receive additional memory regions during VM migration.
(
listener: ReceiveListener,
guest_memory: GuestMemoryAtomic<GuestMemoryMmap>,
)
| 262 | /// additional connections are used to receive additional memory regions |
| 263 | /// during VM migration. |
| 264 | pub(crate) fn new( |
| 265 | listener: ReceiveListener, |
| 266 | guest_memory: GuestMemoryAtomic<GuestMemoryMmap>, |
| 267 | ) -> Result<Self, MigratableError> { |
| 268 | let event_fd = EventFd::new(0) |
| 269 | .context("Error creating terminate fd") |
| 270 | .map_err(MigratableError::MigrateReceive)?; |
| 271 | |
| 272 | let terminate_fd = event_fd |
| 273 | .try_clone() |
| 274 | .context("Error cloning terminate fd") |
| 275 | .map_err(MigratableError::MigrateReceive)?; |
| 276 | |
| 277 | let accept_thread = thread::Builder::new() |
| 278 | .name("migrate-receive-accept-connections".to_owned()) |
| 279 | .spawn(move || Self::accept_connections(listener, &terminate_fd, &guest_memory)) |
| 280 | .context("Error creating connection accept thread") |
| 281 | .map_err(MigratableError::MigrateReceive)?; |
| 282 | |
| 283 | Ok(Self { |
| 284 | accept_thread: Some(accept_thread), |
| 285 | terminate_fd: event_fd, |
| 286 | }) |
| 287 | } |
| 288 | |
| 289 | fn accept_connections( |
| 290 | mut listener: ReceiveListener, |