mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 12:35:26 +00:00
devices:vfio-pci: Add close() for vfio pci device
When vfio pci device is hotplug out from the guest machine, vfio device's resource should be returned to system, so vfio pci device's close() is needed. BUG=b:185084350 TEST=Boot a guest and hotplug vfio pci device repeatedly Change-Id: I4686d737e93ae6db6078851e2add3275b9faaa84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2955574 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
436fa1b807
commit
22dc9f80c4
1 changed files with 11 additions and 1 deletions
|
@ -868,11 +868,15 @@ impl VfioPciDevice {
|
|||
}
|
||||
}
|
||||
|
||||
fn enable_bars_mmap(&mut self) {
|
||||
fn disable_bars_mmap(&mut self) {
|
||||
for mmap_info in self.mmap_info.iter() {
|
||||
self.remove_bar_mmap(mmap_info);
|
||||
}
|
||||
self.mmap_info.clear();
|
||||
}
|
||||
|
||||
fn enable_bars_mmap(&mut self) {
|
||||
self.disable_bars_mmap();
|
||||
|
||||
for mmio_info in self.mmio_regions.iter() {
|
||||
let mut mmap_info =
|
||||
|
@ -882,6 +886,12 @@ impl VfioPciDevice {
|
|||
|
||||
self.remap = false;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn close(&mut self) {
|
||||
self.disable_bars_mmap();
|
||||
self.device.close();
|
||||
}
|
||||
}
|
||||
|
||||
impl PciDevice for VfioPciDevice {
|
||||
|
|
Loading…
Reference in a new issue