| 323 | } |
| 324 | |
| 325 | fn enable_irq(&self, irq_index: u32, event_fds: Vec<&EventFd>) -> Result<(), VfioError> { |
| 326 | info!( |
| 327 | "Enabling IRQ {:x} number of fds = {:?}", |
| 328 | irq_index, |
| 329 | event_fds.len() |
| 330 | ); |
| 331 | let fds: Vec<i32> = event_fds.iter().map(|e| e.as_raw_fd()).collect(); |
| 332 | |
| 333 | // Batch into blocks of 16 fds as sendmsg() has a size limit |
| 334 | let mut sent_fds = 0; |
| 335 | let num_fds = event_fds.len() as u32; |
| 336 | while sent_fds < num_fds { |
| 337 | let remaining_fds = num_fds - sent_fds; |
| 338 | let count = if remaining_fds > 16 { |
| 339 | 16 |
| 340 | } else { |
| 341 | remaining_fds |
| 342 | }; |
| 343 | |
| 344 | self.client |
| 345 | .lock() |
| 346 | .unwrap() |
| 347 | .set_irqs( |
| 348 | irq_index, |
| 349 | VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, |
| 350 | sent_fds, |
| 351 | count, |
| 352 | &fds[sent_fds as usize..(sent_fds + count) as usize], |
| 353 | ) |
| 354 | .map_err(VfioError::VfioUser)?; |
| 355 | |
| 356 | sent_fds += count; |
| 357 | } |
| 358 | |
| 359 | Ok(()) |
| 360 | } |
| 361 | |
| 362 | fn disable_irq(&self, irq_index: u32) -> Result<(), VfioError> { |
| 363 | info!("Disabling IRQ {irq_index:x}"); |