fn realize(&mut self) -> Result<()> {
        let backend = VhostBackend::new(&self.mem_space, "/dev/vhost-net", self.net_cfg.vhost_fd)
            .chain_err(|| "Failed to create backend for vhost net")?;
        backend
            .set_owner()
            .chain_err(|| "Failed to set owner for vhost net")?;

        let mut vhost_features = backend
            .get_features()
            .chain_err(|| "Failed to get features for vhost net")?;
        vhost_features &= !(1_u64 << VHOST_NET_F_VIRTIO_NET_HDR);
        vhost_features &= !(1_u64 << VIRTIO_F_ACCESS_PLATFORM);

        let mut device_features = vhost_features;
        device_features |= 1 << VIRTIO_F_VERSION_1
            | 1 << VIRTIO_NET_F_CSUM
            | 1 << VIRTIO_NET_F_GUEST_CSUM
            | 1 << VIRTIO_NET_F_GUEST_TSO4
            | 1 << VIRTIO_NET_F_GUEST_UFO
            | 1 << VIRTIO_NET_F_HOST_TSO4
            | 1 << VIRTIO_NET_F_HOST_UFO;

        if let Some(mac) = &self.net_cfg.mac {
            device_features |= build_device_config_space(&mut self.device_config, mac);
        }

        let host_dev_name = match self.net_cfg.host_dev_name.as_str() {
            "" => None,
            _ => Some(self.net_cfg.host_dev_name.as_str()),
        };

        self.tap = create_tap(self.net_cfg.tap_fd, host_dev_name)
            .chain_err(|| "Failed to create tap for vhost net")?;
        self.backend = Some(backend);
        self.device_features = device_features;
        self.vhost_features = vhost_features;

        Ok(())
    }
/// Realize vhost virtio network device.
Realize vhost virtio network device.
Realize vhost virtio network device .
fn realize(&mut self) -> Result<()> {
        let backend = VhostBackend::new(&self.mem_space, "/dev/vhost-net", self.net_cfg.vhost_fd)
            .chain_err(|| "Failed to create backend for vhost net")?;
        backend
            .set_owner()
            .chain_err(|| "Failed to set owner for vhost net")?;
        let mut vhost_features = backend
            .get_features()
            .chain_err(|| "Failed to get features for vhost net")?;
        vhost_features &= !(1_u64 << VHOST_NET_F_VIRTIO_NET_HDR);
        vhost_features &= !(1_u64 << VIRTIO_F_ACCESS_PLATFORM);
        let mut device_features = vhost_features;
        device_features |= 1 << VIRTIO_F_VERSION_1
            | 1 << VIRTIO_NET_F_CSUM
            | 1 << VIRTIO_NET_F_GUEST_CSUM
            | 1 << VIRTIO_NET_F_GUEST_TSO4
            | 1 << VIRTIO_NET_F_GUEST_UFO
            | 1 << VIRTIO_NET_F_HOST_TSO4
            | 1 << VIRTIO_NET_F_HOST_UFO;
        if let Some(mac) = &self.net_cfg.mac {
            device_features |= build_device_config_space(&mut self.device_config, mac);
        }
        let host_dev_name = match self.net_cfg.host_dev_name.as_str() {
            "" => None,
            _ => Some(self.net_cfg.host_dev_name.as_str()),
        };
        self.tap = create_tap(self.net_cfg.tap_fd, host_dev_name)
            .chain_err(|| "Failed to create tap for vhost net")?;
        self.backend = Some(backend);
        self.device_features = device_features;
        self.vhost_features = vhost_features;
        Ok(())
    }
fn realize ( & mut self ) -> Result < ( ) > { let backend = VhostBackend :: new ( & self . mem_space , " " , self . net_cfg . vhost_fd ) . chain_err ( | | " " ) ? ; backend . set_owner ( ) . chain_err ( | | " " ) ? ; let mut vhost_features = backend . get_features ( ) . chain_err ( | | " " ) ? ; vhost_features &= ! ( 1_u64 << VHOST_NET_F_VIRTIO_NET_HDR ) ; vhost_features &= ! ( 1_u64 << VIRTIO_F_ACCESS_PLATFORM ) ; let mut device_features = vhost_features ; device_features |= 1 << VIRTIO_F_VERSION_1 | 1 << VIRTIO_NET_F_CSUM | 1 << VIRTIO_NET_F_GUEST_CSUM | 1 << VIRTIO_NET_F_GUEST_TSO4 | 1 << VIRTIO_NET_F_GUEST_UFO | 1 << VIRTIO_NET_F_HOST_TSO4 | 1 << VIRTIO_NET_F_HOST_UFO ; if let Some ( mac ) = & self . net_cfg . mac { device_features |= build_device_config_space ( & mut self . device_config , mac ) ; } let host_dev_name = match self . net_cfg . host_dev_name . as_str ( ) { " " => None , _ => Some ( self . net_cfg . host_dev_name . as_str ( ) ) , } ; self . tap = create_tap ( self . net_cfg . tap_fd , host_dev_name ) . chain_err ( | | " " ) ? ; self . backend = Some ( backend ) ; self . device_features = device_features ; self . vhost_features = vhost_features ; Ok ( ( ) ) }
Realize vhost virtio network device.
Realize vhost virtio network device .
&mut self
&mut self