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

Method activate

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

Source from the content-addressed store, hash-verified

271 }
272
273 fn activate(&mut self, context: crate::device::ActivationContext) -> ActivateResult {
274 let crate::device::ActivationContext {
275 mem,
276 interrupt_cb,
277 mut queues,
278 device_status,
279 } = context;
280 self.vu_common
281 .virtio_common
282 .activate(&queues, interrupt_cb.clone())?;
283 self.guest_memory = Some(mem.clone());
284
285 let num_queues = queues.len();
286 let event_idx = self
287 .vu_common
288 .virtio_common
289 .feature_acked(VIRTIO_RING_F_EVENT_IDX.into());
290 if self
291 .vu_common
292 .virtio_common
293 .feature_acked(VIRTIO_NET_F_CTRL_VQ.into())
294 && !num_queues.is_multiple_of(2)
295 {
296 let ctrl_queue_index = num_queues - 1;
297 let (_, mut ctrl_queue, ctrl_queue_evt) = queues.remove(ctrl_queue_index);
298
299 ctrl_queue.set_event_idx(event_idx);
300
301 let (kill_evt, pause_evt) = self.vu_common.virtio_common.dup_eventfds();
302
303 let mut ctrl_handler = NetCtrlEpollHandler {
304 mem: mem.clone(),
305 kill_evt,
306 pause_evt,
307 ctrl_q: CtrlQueue::new(Vec::new()),
308 queue: ctrl_queue,
309 queue_evt: ctrl_queue_evt,
310 access_platform: None,
311 interrupt_cb: interrupt_cb.clone(),
312 queue_index: ctrl_queue_index as u16,
313 };
314
315 let paused = self.vu_common.virtio_common.paused.clone();
316 // Let's update the barrier as we need 1 for the control queue
317 // thread + 1 for the common vhost-user thread + 1 for the main
318 // thread signalling the pause.
319 self.vu_common.virtio_common.paused_sync = Some(Arc::new(Barrier::new(3)));
320 let paused_sync = self.vu_common.virtio_common.paused_sync.clone();
321
322 let mut epoll_threads = Vec::new();
323 spawn_virtio_thread(
324 &format!("{}_ctrl", &self.id),
325 &self.seccomp_action,
326 Thread::VirtioVhostNetCtl,
327 &mut epoll_threads,
328 &self.exit_evt,
329 device_status.clone(),
330 interrupt_cb.clone(),

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
spawn_virtio_threadFunction · 0.85
feature_ackedMethod · 0.80
dup_eventfdsMethod · 0.80
run_ctrlMethod · 0.80
cloneMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45
set_event_idxMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected