pub fn register_virtio_mmio_device(
        &mut self,
        vm: &VmFd,
        device_id: String,
        mmio_device: MmioTransport,
        slot: &MMIODeviceInfo,
    ) -> Result<()> {
        // Our virtio devices are currently hardcoded to use a single IRQ.
        // Validate that requirement.
        if slot.irqs.len() != 1 {
            return Err(Error::InvalidInput);
        }
        let identifier;
        {
            let locked_device = mmio_device.locked_device();
            identifier = (DeviceType::Virtio(locked_device.device_type()), device_id);
            for (i, queue_evt) in locked_device.queue_events().iter().enumerate() {
                let io_addr =
                    IoEventAddress::Mmio(slot.addr + u64::from(devices::virtio::NOTIFY_REG_OFFSET));
                vm.register_ioevent(queue_evt, &io_addr, i as u32)
                    .map_err(Error::RegisterIoEvent)?;
            }
            vm.register_irqfd(locked_device.interrupt_evt(), slot.irqs[0])
                .map_err(Error::RegisterIrqFd)?;
        }

        self.register_mmio_device(identifier, slot.clone(), Arc::new(Mutex::new(mmio_device)))
    }
/// Register a virtio-over-MMIO device to be used via MMIO transport at a specific slot.
Register a virtio-over-MMIO device to be used via MMIO transport at a specific slot.
Register a virtio - over - MMIO device to be used via MMIO transport at a specific slot .
pub fn register_virtio_mmio_device(
        &mut self,
        vm: &VmFd,
        device_id: String,
        mmio_device: MmioTransport,
        slot: &MMIODeviceInfo,
    ) -> Result<()> {
        // Our virtio devices are currently hardcoded to use a single IRQ.
        // Validate that requirement.
        if slot.irqs.len() != 1 {
            return Err(Error::InvalidInput);
        }
        let identifier;
        {
            let locked_device = mmio_device.locked_device();
            identifier = (DeviceType::Virtio(locked_device.device_type()), device_id);
            for (i, queue_evt) in locked_device.queue_events().iter().enumerate() {
                let io_addr =
                    IoEventAddress::Mmio(slot.addr + u64::from(devices::virtio::NOTIFY_REG_OFFSET));
                vm.register_ioevent(queue_evt, &io_addr, i as u32)
                    .map_err(Error::RegisterIoEvent)?;
            }
            vm.register_irqfd(locked_device.interrupt_evt(), slot.irqs[0])
                .map_err(Error::RegisterIrqFd)?;
        }
        self.register_mmio_device(identifier, slot.clone(), Arc::new(Mutex::new(mmio_device)))
    }
pub fn register_virtio_mmio_device ( & mut self , vm : & VmFd , device_id : String , mmio_device : MmioTransport , slot : & MMIODeviceInfo , ) -> Result < ( ) > { // Our virtio devices are currently hardcoded to use a single IRQ. // Validate that requirement. if slot . irqs . len ( ) != 1 { return Err ( Error :: InvalidInput ) ; } let identifier ; { let locked_device = mmio_device . locked_device ( ) ; identifier = ( DeviceType :: Virtio ( locked_device . device_type ( ) ) , device_id ) ; for ( i , queue_evt ) in locked_device . queue_events ( ) . iter ( ) . enumerate ( ) { let io_addr = IoEventAddress :: Mmio ( slot . addr + u64 :: from ( devices :: virtio :: NOTIFY_REG_OFFSET ) ) ; vm . register_ioevent ( queue_evt , & io_addr , i as u32 ) . map_err ( Error :: RegisterIoEvent ) ? ; } vm . register_irqfd ( locked_device . interrupt_evt ( ) , slot . irqs [ 0 ] ) . map_err ( Error :: RegisterIrqFd ) ? ; } self . register_mmio_device ( identifier , slot . clone ( ) , Arc :: new ( Mutex :: new ( mmio_device ) ) ) }
Register a virtio-over-MMIO device to be used via MMIO transport at a specific slot.
Register a virtio - over - MMIO device to be used via MMIO transport at a specific slot .
&mut self
vm
&VmFd
device_id
String
mmio_device
MmioTransport
slot
&MMIODeviceInfo
&mut self
vm
&VmFd
device_id
String
mmio_device
MmioTransport
slot
&MMIODeviceInfo