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

Method activate

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

Source from the content-addressed store, hash-verified

267 }
268
269 fn activate(&mut self, context: crate::device::ActivationContext) -> ActivateResult {
270 let crate::device::ActivationContext {
271 mem,
272 interrupt_cb,
273 queues,
274 device_status,
275 } = context;
276 self.vu_common
277 .virtio_common
278 .activate(&queues, interrupt_cb.clone())?;
279 self.guest_memory = Some(mem.clone());
280
281 let backend_req_handler: Option<FrontendReqHandler<BackendReqHandler>> = None;
282
283 // Run a dedicated thread for handling potential reconnections with
284 // the backend.
285 let (kill_evt, pause_evt) = self.vu_common.virtio_common.dup_eventfds();
286
287 let mut handler = self.vu_common.activate(
288 mem,
289 &queues,
290 interrupt_cb.clone(),
291 self.vu_common.virtio_common.acked_features,
292 backend_req_handler,
293 kill_evt,
294 pause_evt,
295 )?;
296
297 let paused = self.vu_common.virtio_common.paused.clone();
298 let paused_sync = self.vu_common.virtio_common.paused_sync.clone();
299
300 let mut epoll_threads = Vec::new();
301
302 spawn_virtio_thread(
303 &self.id,
304 &self.seccomp_action,
305 Thread::VirtioVhostBlock,
306 &mut epoll_threads,
307 &self.exit_evt,
308 device_status.clone(),
309 interrupt_cb.clone(),
310 move || handler.run(&paused, paused_sync.as_ref().unwrap()),
311 )?;
312 self.vu_common.epoll_thread = Some(epoll_threads.remove(0));
313
314 Ok(())
315 }
316
317 fn reset(&mut self) {
318 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