vmm: Unregister old ioeventfds when reprogramming PCI BAR

Now that kvm-ioctls has been updated, the function unregister_ioevent()
can be used to remove eventfd previously associated with some specific
PIO or MMIO guest address. Particularly, it is useful for the PCI BAR
reprogramming case, as we want to ensure the eventfd will only get
triggered by the new BAR address, and not the old one.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-10-30 09:41:08 -07:00 committed by Samuel Ortiz
parent 587a420429
commit 3fa5df4161

View File

@ -360,6 +360,10 @@ impl DeviceRelocation for AddressManager {
if let Some(virtio_pci_dev) = any_dev.downcast_ref::<VirtioPciDevice>() {
let bar_addr = virtio_pci_dev.config_bar_addr();
if bar_addr == new_base {
for (event, addr, _) in virtio_pci_dev.ioeventfds(old_base) {
let io_addr = IoEventAddress::Mmio(addr);
self.vm_fd.unregister_ioevent(event, &io_addr)?;
}
for (event, addr, _) in virtio_pci_dev.ioeventfds(new_base) {
let io_addr = IoEventAddress::Mmio(addr);
self.vm_fd.register_ioevent(event, &io_addr, NoDatamatch)?;