diff --git a/Cargo.lock b/Cargo.lock index 7fa87d651..1c02d2604 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2455,6 +2455,7 @@ dependencies = [ "byteorder", "epoll", "event_monitor", + "hypervisor", "libc", "log", "mshv-ioctls", diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index be0380751..e03789eaf 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -1372,6 +1372,7 @@ dependencies = [ "byteorder", "epoll", "event_monitor", + "hypervisor", "libc", "log", "net_util", diff --git a/fuzz/fuzz_targets/balloon.rs b/fuzz/fuzz_targets/balloon.rs index 58b9b3058..69f0c07e8 100644 --- a/fuzz/fuzz_targets/balloon.rs +++ b/fuzz/fuzz_targets/balloon.rs @@ -119,6 +119,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } macro_rules! align { diff --git a/fuzz/fuzz_targets/block.rs b/fuzz/fuzz_targets/block.rs index 51007fe38..952011b55 100644 --- a/fuzz/fuzz_targets/block.rs +++ b/fuzz/fuzz_targets/block.rs @@ -121,6 +121,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue { diff --git a/fuzz/fuzz_targets/console.rs b/fuzz/fuzz_targets/console.rs index e27331ed0..a335a9602 100644 --- a/fuzz/fuzz_targets/console.rs +++ b/fuzz/fuzz_targets/console.rs @@ -148,6 +148,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queues(bytes: &[&[u8; QUEUE_DATA_SIZE]], base_addr: u64) -> Vec { diff --git a/fuzz/fuzz_targets/iommu.rs b/fuzz/fuzz_targets/iommu.rs index a10640487..11600a36a 100644 --- a/fuzz/fuzz_targets/iommu.rs +++ b/fuzz/fuzz_targets/iommu.rs @@ -130,6 +130,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue { diff --git a/fuzz/fuzz_targets/mem.rs b/fuzz/fuzz_targets/mem.rs index 73ec11b02..e430e195a 100644 --- a/fuzz/fuzz_targets/mem.rs +++ b/fuzz/fuzz_targets/mem.rs @@ -125,6 +125,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } // Create a dummy virtio-mem device for fuzzing purpose only diff --git a/fuzz/fuzz_targets/net.rs b/fuzz/fuzz_targets/net.rs index df9a1dce5..efc960580 100644 --- a/fuzz/fuzz_targets/net.rs +++ b/fuzz/fuzz_targets/net.rs @@ -166,6 +166,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queues(bytes: &[&[u8; QUEUE_DATA_SIZE]], base_addr: u64) -> Vec { diff --git a/fuzz/fuzz_targets/pmem.rs b/fuzz/fuzz_targets/pmem.rs index 0bd083a1c..37eabf86c 100644 --- a/fuzz/fuzz_targets/pmem.rs +++ b/fuzz/fuzz_targets/pmem.rs @@ -95,6 +95,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } // Create a dummy virtio-pmem device for fuzzing purpose only diff --git a/fuzz/fuzz_targets/rng.rs b/fuzz/fuzz_targets/rng.rs index 13548664a..c3029f33b 100644 --- a/fuzz/fuzz_targets/rng.rs +++ b/fuzz/fuzz_targets/rng.rs @@ -119,6 +119,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue { diff --git a/fuzz/fuzz_targets/vsock.rs b/fuzz/fuzz_targets/vsock.rs index 33ebe7888..559f2ec13 100644 --- a/fuzz/fuzz_targets/vsock.rs +++ b/fuzz/fuzz_targets/vsock.rs @@ -128,6 +128,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue { diff --git a/fuzz/fuzz_targets/watchdog.rs b/fuzz/fuzz_targets/watchdog.rs index 31361755d..60f4afab5 100644 --- a/fuzz/fuzz_targets/watchdog.rs +++ b/fuzz/fuzz_targets/watchdog.rs @@ -84,6 +84,15 @@ impl VirtioInterrupt for NoopVirtioInterrupt { fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue { diff --git a/virtio-devices/Cargo.toml b/virtio-devices/Cargo.toml index 41b9da8e0..d2658eeec 100644 --- a/virtio-devices/Cargo.toml +++ b/virtio-devices/Cargo.toml @@ -17,6 +17,7 @@ block = { path = "../block" } byteorder = { workspace = true } epoll = { workspace = true } event_monitor = { path = "../event_monitor" } +hypervisor = { path = "../hypervisor" } libc = { workspace = true } log = { workspace = true } mshv-ioctls = { workspace = true, optional = true } diff --git a/virtio-devices/src/device.rs b/virtio-devices/src/device.rs index 4b5cdaf03..91b742a0b 100644 --- a/virtio-devices/src/device.rs +++ b/virtio-devices/src/device.rs @@ -37,6 +37,12 @@ pub trait VirtioInterrupt: Send + Sync { fn notifier(&self, _int_type: VirtioInterruptType) -> Option { None } + fn set_notifier( + &self, + int_type: u32, + notifier: Option, + vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()>; } #[derive(Clone)] diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index 7f049070d..70e03d028 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -914,6 +914,15 @@ impl VirtioInterrupt for VirtioInterruptMsix { self.interrupt_source_group .notifier(vector as InterruptIndex) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } impl PciDevice for VirtioPciDevice { diff --git a/virtio-devices/src/vsock/mod.rs b/virtio-devices/src/vsock/mod.rs index 789558785..34561f5d4 100644 --- a/virtio-devices/src/vsock/mod.rs +++ b/virtio-devices/src/vsock/mod.rs @@ -188,6 +188,15 @@ pub mod unit_tests { ) -> std::result::Result<(), std::io::Error> { Ok(()) } + + fn set_notifier( + &self, + _interrupt: u32, + _eventfd: Option, + _vm: &dyn hypervisor::Vm, + ) -> std::io::Result<()> { + unimplemented!() + } } pub struct TestBackend {