diff --git a/Cargo.lock b/Cargo.lock index 66804b21c..838940d57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1521,6 +1521,7 @@ dependencies = [ "block_util", "byteorder", "epoll", + "event_monitor", "io-uring", "libc", "log 0.4.14", diff --git a/virtio-devices/Cargo.toml b/virtio-devices/Cargo.toml index 669e3a197..1c96c98fb 100644 --- a/virtio-devices/Cargo.toml +++ b/virtio-devices/Cargo.toml @@ -14,6 +14,7 @@ arc-swap = ">=1.0.0" block_util = { path = "../block_util" } byteorder = "1.3.4" epoll = ">=4.0.1" +event_monitor = { path = "../event_monitor" } io-uring = ">=0.4.0" libc = "0.2.86" log = "0.4.14" diff --git a/virtio-devices/src/balloon.rs b/virtio-devices/src/balloon.rs index 14d1ac657..a52ab1bb1 100644 --- a/virtio-devices/src/balloon.rs +++ b/virtio-devices/src/balloon.rs @@ -462,11 +462,14 @@ impl VirtioDevice for Balloon { })?; self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } } diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index bd31556d2..0f142920e 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -567,12 +567,15 @@ impl VirtioDevice for Block { } self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } fn counters(&self) -> Option>> { diff --git a/virtio-devices/src/console.rs b/virtio-devices/src/console.rs index 5cb2dc516..f964a4410 100644 --- a/virtio-devices/src/console.rs +++ b/virtio-devices/src/console.rs @@ -485,11 +485,14 @@ impl VirtioDevice for Console { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } } diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index c7aee1c2c..6a36fa0a6 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -948,11 +948,14 @@ impl VirtioDevice for Iommu { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } } diff --git a/virtio-devices/src/lib.rs b/virtio-devices/src/lib.rs index b6249371a..26fed217e 100644 --- a/virtio-devices/src/lib.rs +++ b/virtio-devices/src/lib.rs @@ -13,6 +13,8 @@ extern crate arc_swap; extern crate epoll; #[macro_use] +extern crate event_monitor; +#[macro_use] extern crate log; extern crate pci; extern crate serde; diff --git a/virtio-devices/src/mem.rs b/virtio-devices/src/mem.rs index b04045644..679ead7e4 100644 --- a/virtio-devices/src/mem.rs +++ b/virtio-devices/src/mem.rs @@ -869,11 +869,14 @@ impl VirtioDevice for Mem { })?; self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } } diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index 759d308ed..99f10cdc6 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -524,13 +524,16 @@ impl VirtioDevice for Net { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); return Ok(()); } Err(ActivateError::BadActivate) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } fn counters(&self) -> Option>> { diff --git a/virtio-devices/src/pmem.rs b/virtio-devices/src/pmem.rs index 7515920fd..042964115 100644 --- a/virtio-devices/src/pmem.rs +++ b/virtio-devices/src/pmem.rs @@ -428,13 +428,16 @@ impl VirtioDevice for Pmem { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); return Ok(()); } Err(ActivateError::BadActivate) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } fn userspace_mappings(&self) -> Vec { diff --git a/virtio-devices/src/rng.rs b/virtio-devices/src/rng.rs index 09fa095fe..77e246a6e 100644 --- a/virtio-devices/src/rng.rs +++ b/virtio-devices/src/rng.rs @@ -274,13 +274,16 @@ impl VirtioDevice for Rng { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); return Ok(()); } Err(ActivateError::BadActivate) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } } diff --git a/virtio-devices/src/vhost_user/blk.rs b/virtio-devices/src/vhost_user/blk.rs index 45c2fff2c..e33f26446 100644 --- a/virtio-devices/src/vhost_user/blk.rs +++ b/virtio-devices/src/vhost_user/blk.rs @@ -272,6 +272,7 @@ impl VirtioDevice for Blk { } self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } @@ -291,6 +292,8 @@ impl VirtioDevice for Blk { let _ = kill_evt.write(1); } + event!("virtio-device", "reset", "id", &self.id); + // Return the interrupt Some(self.common.interrupt_cb.take().unwrap()) } diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index f88033e92..4dea49fe4 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -492,6 +492,7 @@ impl VirtioDevice for Fs { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } @@ -511,6 +512,8 @@ impl VirtioDevice for Fs { let _ = kill_evt.write(1); } + event!("virtio-device", "reset", "id", &self.id); + // Return the interrupt Some(self.common.interrupt_cb.take().unwrap()) } diff --git a/virtio-devices/src/vhost_user/net.rs b/virtio-devices/src/vhost_user/net.rs index c13d53298..4f4a1b55b 100644 --- a/virtio-devices/src/vhost_user/net.rs +++ b/virtio-devices/src/vhost_user/net.rs @@ -347,6 +347,8 @@ impl VirtioDevice for Net { let _ = kill_evt.write(1); } + event!("virtio-device", "reset", "id", &self.id); + // Return the interrupt Some(self.common.interrupt_cb.take().unwrap()) } diff --git a/virtio-devices/src/vsock/device.rs b/virtio-devices/src/vsock/device.rs index fb5fe07aa..675821476 100644 --- a/virtio-devices/src/vsock/device.rs +++ b/virtio-devices/src/vsock/device.rs @@ -471,11 +471,14 @@ where self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } fn shutdown(&mut self) { diff --git a/virtio-devices/src/watchdog.rs b/virtio-devices/src/watchdog.rs index b76fcb1b1..10626d20f 100644 --- a/virtio-devices/src/watchdog.rs +++ b/virtio-devices/src/watchdog.rs @@ -355,11 +355,14 @@ impl VirtioDevice for Watchdog { self.common.epoll_threads = Some(epoll_threads); + event!("virtio-device", "activated", "id", &self.id); Ok(()) } fn reset(&mut self) -> Option> { - self.common.reset() + let result = self.common.reset(); + event!("virtio-device", "reset", "id", &self.id); + result } }