Create a new virtio network device with the given TAP interface.
(tap: Tap)
| 84 | impl VhostUserNetThread { |
| 85 | /// Create a new virtio network device with the given TAP interface. |
| 86 | fn new(tap: Tap) -> Result<Self> { |
| 87 | Ok(VhostUserNetThread { |
| 88 | kill_evt: EventFd::new(EFD_NONBLOCK).map_err(Error::CreateKillEventFd)?, |
| 89 | net: NetQueuePair { |
| 90 | tap_for_write_epoll: tap.clone(), |
| 91 | tap, |
| 92 | rx: RxVirtio::new(), |
| 93 | tx: TxVirtio::new(), |
| 94 | rx_tap_listening: false, |
| 95 | tx_tap_listening: false, |
| 96 | epoll_fd: None, |
| 97 | counters: NetCounters::default(), |
| 98 | tap_rx_event_id: 3, |
| 99 | tap_tx_event_id: 4, |
| 100 | rx_desc_avail: false, |
| 101 | rx_rate_limiter: None, |
| 102 | tx_rate_limiter: None, |
| 103 | access_platform: None, |
| 104 | }, |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | pub fn set_epoll_fd(&mut self, fd: RawFd) { |
| 109 | self.net.epoll_fd = Some(fd); |