(&mut self)
| 543 | } |
| 544 | |
| 545 | fn unplug_all(&mut self) -> u16 { |
| 546 | let mut config = self.config.lock().unwrap(); |
| 547 | if let Err(e) = self.discard_memory_range(0, config.region_size) { |
| 548 | error!("failed discarding memory range: {e:?}"); |
| 549 | return VIRTIO_MEM_RESP_ERROR; |
| 550 | } |
| 551 | |
| 552 | // Remaining plugged blocks are unmapped. |
| 553 | if config.plugged_size > 0 { |
| 554 | let handlers = self.dma_mapping_handlers.lock().unwrap(); |
| 555 | for (idx, plugged) in self.blocks_state.lock().unwrap().inner().iter().enumerate() { |
| 556 | if *plugged { |
| 557 | let gpa = config.addr + (idx as u64 * config.block_size); |
| 558 | for (_, handler) in handlers.iter() { |
| 559 | if let Err(e) = handler.unmap(gpa, config.block_size) { |
| 560 | error!( |
| 561 | "failed DMA unmapping addr 0x{:x} size 0x{:x}: {}", |
| 562 | gpa, config.block_size, e |
| 563 | ); |
| 564 | return VIRTIO_MEM_RESP_ERROR; |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | self.blocks_state.lock().unwrap().set_range( |
| 572 | 0, |
| 573 | (config.region_size / config.block_size) as usize, |
| 574 | false, |
| 575 | ); |
| 576 | |
| 577 | config.plugged_size = 0; |
| 578 | |
| 579 | VIRTIO_MEM_RESP_ACK |
| 580 | } |
| 581 | |
| 582 | fn state_request(&self, addr: u64, nb_blocks: u16) -> (u16, u16) { |
| 583 | let config = self.config.lock().unwrap(); |
no test coverage detected