virtio-devices: Set the AccessPlatform for every VirtioDevice

Moving away from the virtio-queue mechanism for descriptor address
translation. Instead, we enable the new mechanism added to every
VirtioDevice implementation, by setting the AccessPlatform trait if one
can be found.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-01-26 17:16:58 +01:00 committed by Rob Bradford
parent e2225bb4b0
commit 8759c3db3e

View File

@ -352,23 +352,25 @@ impl VirtioPciDevice {
use_64bit_bar: bool,
) -> Result<Self> {
let device_clone = device.clone();
let locked_device = device_clone.lock().unwrap();
let mut locked_device = device_clone.lock().unwrap();
let mut queue_evts = Vec::new();
for _ in locked_device.queue_max_sizes().iter() {
queue_evts.push(EventFd::new(EFD_NONBLOCK)?)
}
let num_queues = locked_device.queue_max_sizes().len();
if let Some(access_platform) = &access_platform {
locked_device.set_access_platform(access_platform.clone());
}
let queues = locked_device
.queue_max_sizes()
.iter()
.map(|&s| {
let mut queue =
Queue::<GuestMemoryAtomic<GuestMemoryMmap>, virtio_queue::QueueState>::new(
memory.clone(),
s,
);
queue.state.access_platform = access_platform.clone();
queue
Queue::<GuestMemoryAtomic<GuestMemoryMmap>, virtio_queue::QueueState>::new(
memory.clone(),
s,
)
})
.collect();