pub fn register_mmio_device(
        &mut self,
        vm: &VmFd,
        mmio_device: devices::virtio::MmioTransport,
        type_id: u32,
        device_id: String,
    ) -> Result<(u64, u32)> {
        if self.irq > self.last_irq {
            return Err(Error::IrqsExhausted);
        }

        for (i, queue_evt) in mmio_device
            .locked_device()
            .queue_events()
            .iter()
            .enumerate()
        {
            let io_addr = IoEventAddress::Mmio(
                self.mmio_base + u64::from(devices::virtio::NOTIFY_REG_OFFSET),
            );

            vm.register_ioevent(queue_evt, &io_addr, i as u32)
                .map_err(Error::RegisterIoEvent)?;
        }

        vm.register_irqfd(mmio_device.locked_device().interrupt_evt(), self.irq)
            .map_err(Error::RegisterIrqFd)?;

        self.bus
            .insert(Arc::new(Mutex::new(mmio_device)), self.mmio_base, MMIO_LEN)
            .map_err(Error::BusError)?;
        let ret = (self.mmio_base, self.irq);
        self.id_to_dev_info.insert(
            (DeviceType::Virtio(type_id), device_id),
            MMIODeviceInfo {
                addr: self.mmio_base,
                _len: MMIO_LEN,
                _irq: self.irq,
            },
        );
        self.mmio_base += MMIO_LEN;
        self.irq += 1;

        Ok(ret)
    }
/// Register an already created MMIO device to be used via MMIO transport.
Register an already created MMIO device to be used via MMIO transport.
Register an already created MMIO device to be used via MMIO transport .
pub fn register_mmio_device(
        &mut self,
        vm: &VmFd,
        mmio_device: devices::virtio::MmioTransport,
        type_id: u32,
        device_id: String,
    ) -> Result<(u64, u32)> {
        if self.irq > self.last_irq {
            return Err(Error::IrqsExhausted);
        }
        for (i, queue_evt) in mmio_device
            .locked_device()
            .queue_events()
            .iter()
            .enumerate()
        {
            let io_addr = IoEventAddress::Mmio(
                self.mmio_base + u64::from(devices::virtio::NOTIFY_REG_OFFSET),
            );
            vm.register_ioevent(queue_evt, &io_addr, i as u32)
                .map_err(Error::RegisterIoEvent)?;
        }
        vm.register_irqfd(mmio_device.locked_device().interrupt_evt(), self.irq)
            .map_err(Error::RegisterIrqFd)?;
        self.bus
            .insert(Arc::new(Mutex::new(mmio_device)), self.mmio_base, MMIO_LEN)
            .map_err(Error::BusError)?;
        let ret = (self.mmio_base, self.irq);
        self.id_to_dev_info.insert(
            (DeviceType::Virtio(type_id), device_id),
            MMIODeviceInfo {
                addr: self.mmio_base,
                _len: MMIO_LEN,
                _irq: self.irq,
            },
        );
        self.mmio_base += MMIO_LEN;
        self.irq += 1;
        Ok(ret)
    }
pub fn register_mmio_device ( & mut self , vm : & VmFd , mmio_device : devices :: virtio :: MmioTransport , type_id : u32 , device_id : String , ) -> Result < ( u64 , u32 ) > { if self . irq > self . last_irq { return Err ( Error :: IrqsExhausted ) ; } for ( i , queue_evt ) in mmio_device . locked_device ( ) . queue_events ( ) . iter ( ) . enumerate ( ) { let io_addr = IoEventAddress :: Mmio ( self . mmio_base + u64 :: from ( devices :: virtio :: NOTIFY_REG_OFFSET ) , ) ; vm . register_ioevent ( queue_evt , & io_addr , i as u32 ) . map_err ( Error :: RegisterIoEvent ) ? ; } vm . register_irqfd ( mmio_device . locked_device ( ) . interrupt_evt ( ) , self . irq ) . map_err ( Error :: RegisterIrqFd ) ? ; self . bus . insert ( Arc :: new ( Mutex :: new ( mmio_device ) ) , self . mmio_base , MMIO_LEN ) . map_err ( Error :: BusError ) ? ; let ret = ( self . mmio_base , self . irq ) ; self . id_to_dev_info . insert ( ( DeviceType :: Virtio ( type_id ) , device_id ) , MMIODeviceInfo { addr : self . mmio_base , _len : MMIO_LEN , _irq : self . irq , } , ) ; self . mmio_base += MMIO_LEN ; self . irq += 1 ; Ok ( ret ) }
Register an already created MMIO device to be used via MMIO transport.
Register an already created MMIO device to be used via MMIO transport .
&mut self
vm
&VmFd
mmio_device
devices::virtio::MmioTransport
type_id
u32
device_id
String