MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / activate

Method activate

virtio-devices/src/vhost_user/fs.rs:244–289  ·  view source on GitHub ↗
(&mut self, context: crate::device::ActivationContext)

Source from the content-addressed store, hash-verified

242 }
243
244 fn activate(&mut self, context: crate::device::ActivationContext) -> ActivateResult {
245 let crate::device::ActivationContext {
246 mem,
247 interrupt_cb,
248 queues,
249 device_status,
250 } = context;
251 self.vu_common
252 .virtio_common
253 .activate(&queues, interrupt_cb.clone())?;
254 self.guest_memory = Some(mem.clone());
255
256 let backend_req_handler: Option<FrontendReqHandler<BackendReqHandler>> = None;
257 // Run a dedicated thread for handling potential reconnections with
258 // the backend.
259 let (kill_evt, pause_evt) = self.vu_common.virtio_common.dup_eventfds();
260
261 let mut handler = self.vu_common.activate(
262 mem,
263 &queues,
264 interrupt_cb.clone(),
265 self.vu_common.virtio_common.acked_features,
266 backend_req_handler,
267 kill_evt,
268 pause_evt,
269 )?;
270
271 let paused = self.vu_common.virtio_common.paused.clone();
272 let paused_sync = self.vu_common.virtio_common.paused_sync.clone();
273
274 let mut epoll_threads = Vec::new();
275 spawn_virtio_thread(
276 &self.id,
277 &self.seccomp_action,
278 Thread::VirtioVhostFs,
279 &mut epoll_threads,
280 &self.exit_evt,
281 device_status.clone(),
282 interrupt_cb.clone(),
283 move || handler.run(&paused, paused_sync.as_ref().unwrap()),
284 )?;
285 self.vu_common.epoll_thread = Some(epoll_threads.remove(0));
286
287 event!("virtio-device", "activated", "id", &self.id);
288 Ok(())
289 }
290
291 fn reset(&mut self) {
292 self.vu_common.reset(&self.id);

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
spawn_virtio_threadFunction · 0.85
dup_eventfdsMethod · 0.80
cloneMethod · 0.45
runMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected