fn activate(&mut self) -> Result<()> {
        let queues_config =
            &self.state.config_space.queues_config[0..self.state.config_space.queue_num];
        for queue_config in queues_config {
            let queue = Queue::new(*queue_config, self.state.config_space.queue_type)?;
            if !queue.is_valid(&self.mem_space) {
                bail!("Invalid queue");
            }
            self.queues.push(Arc::new(Mutex::new(queue)));
        }

        let mut queue_evts = Vec::<EventFd>::new();
        for fd in self.host_notify_info.events.iter() {
            let evt_fd_clone = match fd.try_clone() {
                Ok(fd) => fd,
                Err(e) => {
                    error!("Failed to clone IoEventFd, {}", e);
                    continue;
                }
            };
            queue_evts.push(evt_fd_clone);
        }

        let interrupt_status = self.interrupt_status.clone();
        let interrupt_evt = self.interrupt_evt.try_clone().unwrap();
        let cb = Arc::new(Box::new(
            move |int_type: &VirtioInterruptType, _queue: Option<&Queue>| {
                let status = match int_type {
                    VirtioInterruptType::Config => VIRTIO_MMIO_INT_CONFIG,
                    VirtioInterruptType::Vring => VIRTIO_MMIO_INT_VRING,
                };
                interrupt_status.fetch_or(status as u32, Ordering::SeqCst);
                interrupt_evt
                    .write(1)
                    .chain_err(|| ErrorKind::EventFdWrite)?;

                Ok(())
            },
        ) as VirtioInterrupt);

        self.device.lock().unwrap().activate(
            self.mem_space.clone(),
            cb,
            &self.queues,
            queue_evts,
        )?;

        Ok(())
    }
/// Activate the virtio device, this function is called by vcpu thread when frontend
/// virtio driver is ready and write `DRIVER_OK` to backend.
Activate the virtio device, this function is called by vcpu thread when frontend
virtio driver is ready and write `DRIVER_OK` to backend.
Activate the virtio device this function is called by vcpu thread when frontend virtio driver is ready and write ` DRIVER_OK ` to backend .
fn activate(&mut self) -> Result<()> {
        let queues_config =
            &self.state.config_space.queues_config[0..self.state.config_space.queue_num];
        for queue_config in queues_config {
            let queue = Queue::new(*queue_config, self.state.config_space.queue_type)?;
            if !queue.is_valid(&self.mem_space) {
                bail!("Invalid queue");
            }
            self.queues.push(Arc::new(Mutex::new(queue)));
        }
        let mut queue_evts = Vec::<EventFd>::new();
        for fd in self.host_notify_info.events.iter() {
            let evt_fd_clone = match fd.try_clone() {
                Ok(fd) => fd,
                Err(e) => {
                    error!("Failed to clone IoEventFd, {}", e);
                    continue;
                }
            };
            queue_evts.push(evt_fd_clone);
        }
        let interrupt_status = self.interrupt_status.clone();
        let interrupt_evt = self.interrupt_evt.try_clone().unwrap();
        let cb = Arc::new(Box::new(
            move |int_type: &VirtioInterruptType, _queue: Option<&Queue>| {
                let status = match int_type {
                    VirtioInterruptType::Config => VIRTIO_MMIO_INT_CONFIG,
                    VirtioInterruptType::Vring => VIRTIO_MMIO_INT_VRING,
                };
                interrupt_status.fetch_or(status as u32, Ordering::SeqCst);
                interrupt_evt
                    .write(1)
                    .chain_err(|| ErrorKind::EventFdWrite)?;
                Ok(())
            },
        ) as VirtioInterrupt);
        self.device.lock().unwrap().activate(
            self.mem_space.clone(),
            cb,
            &self.queues,
            queue_evts,
        )?;
        Ok(())
    }
fn activate ( & mut self ) -> Result < ( ) > { let queues_config = & self . state . config_space . queues_config [ 0 .. self . state . config_space . queue_num ] ; for queue_config in queues_config { let queue = Queue :: new ( * queue_config , self . state . config_space . queue_type ) ? ; if ! queue . is_valid ( & self . mem_space ) { bail ! ( " " ) ; } self . queues . push ( Arc :: new ( Mutex :: new ( queue ) ) ) ; } let mut queue_evts = Vec :: < EventFd > :: new ( ) ; for fd in self . host_notify_info . events . iter ( ) { let evt_fd_clone = match fd . try_clone ( ) { Ok ( fd ) => fd , Err ( e ) => { error ! ( " " e ) ; continue ; } } ; queue_evts . push ( evt_fd_clone ) ; } let interrupt_status = self . interrupt_status . clone ( ) ; let interrupt_evt = self . interrupt_evt . try_clone ( ) . unwrap ( ) ; let cb = Arc :: new ( Box :: new ( move | int_type : & VirtioInterruptType , _queue : Option < & Queue > | { let status = match int_type { VirtioInterruptType :: Config => VIRTIO_MMIO_INT_CONFIG , VirtioInterruptType :: Vring => VIRTIO_MMIO_INT_VRING , } ; interrupt_status . fetch_or ( status as u32 , Ordering :: SeqCst ) ; interrupt_evt . write ( 1 ) . chain_err ( | | ErrorKind :: EventFdWrite ) ? ; Ok ( ( ) ) } , ) as VirtioInterrupt ) ; self . device . lock ( ) . unwrap ( ) . activate ( self . mem_space . clone ( ) , cb , & self . queues , queue_evts , ) ? ; Ok ( ( ) ) }
Activate the virtio device, this function is called by vcpu thread when frontend
virtio driver is ready and write `DRIVER_OK` to backend.
Activate the virtio device this function is called by vcpu thread when frontend virtio driver is ready and write ` DRIVER_OK ` to backend .
&mut self
&mut self