From 128ee6d105d2594f67a4ed462e0d2e515e048a4d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 17 Apr 2026 09:11:47 +0100 Subject: [PATCH] virtio-devices: Implement VirtioDevice::access_platform() This forwards through to the VirtioCommon implementation and can be used to simplify the virtio PCI access code. Signed-off-by: Rob Bradford --- virtio-devices/src/block.rs | 4 ++++ virtio-devices/src/console.rs | 4 ++++ virtio-devices/src/net.rs | 4 ++++ virtio-devices/src/pmem.rs | 4 ++++ virtio-devices/src/rng.rs | 4 ++++ virtio-devices/src/vdpa.rs | 4 ++++ virtio-devices/src/vsock/device.rs | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index 961ab9fde..71c0b7ed3 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -1223,6 +1223,10 @@ impl VirtioDevice for Block { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Block { diff --git a/virtio-devices/src/console.rs b/virtio-devices/src/console.rs index b7519626d..f141d08b1 100644 --- a/virtio-devices/src/console.rs +++ b/virtio-devices/src/console.rs @@ -782,6 +782,10 @@ impl VirtioDevice for Console { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Console { diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index 7c50b4f8b..7ddbccca8 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -900,6 +900,10 @@ impl VirtioDevice for Net { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Net { diff --git a/virtio-devices/src/pmem.rs b/virtio-devices/src/pmem.rs index 91e0f6579..eb94e7104 100644 --- a/virtio-devices/src/pmem.rs +++ b/virtio-devices/src/pmem.rs @@ -441,6 +441,10 @@ impl VirtioDevice for Pmem { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Pmem { diff --git a/virtio-devices/src/rng.rs b/virtio-devices/src/rng.rs index e8fd5b374..2f43ac66d 100644 --- a/virtio-devices/src/rng.rs +++ b/virtio-devices/src/rng.rs @@ -305,6 +305,10 @@ impl VirtioDevice for Rng { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Rng { diff --git a/virtio-devices/src/vdpa.rs b/virtio-devices/src/vdpa.rs index ff7305395..f9bf7a39d 100644 --- a/virtio-devices/src/vdpa.rs +++ b/virtio-devices/src/vdpa.rs @@ -465,6 +465,10 @@ impl VirtioDevice for Vdpa { fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Vdpa { diff --git a/virtio-devices/src/vsock/device.rs b/virtio-devices/src/vsock/device.rs index dd877fa55..0b202945b 100644 --- a/virtio-devices/src/vsock/device.rs +++ b/virtio-devices/src/vsock/device.rs @@ -501,6 +501,10 @@ where fn set_access_platform(&mut self, access_platform: Arc) { self.common.set_access_platform(access_platform); } + + fn access_platform(&self) -> Option> { + self.common.access_platform() + } } impl Pausable for Vsock