mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio: Port codebase to the latest virtio-queue version
The new virtio-queue version introduced some breaking changes which need to be addressed so that Cloud Hypervisor can still work with this version. The most important change is about removing a handle to the guest memory from the Queue, meaning the caller has to provide the guest memory handle for multiple methods from the QueueT trait. One interesting aspect is that QueueT has been widely extended to provide every getter and setter we need to access and update the Queue structure without having direct access to its internal fields. This patch ports all the virtio and vhost-user devices to this new crate definition. It also updates both vhost-user-block and vhost-user-net backends based on the updated vhost-user-backend crate. It also updates the fuzz directory. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
7199119bb2
commit
a423bf13ad
@@ -11,9 +11,8 @@
|
||||
pub mod testing {
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use virtio_queue::{Queue, QueueState, VirtqUsedElem};
|
||||
use vm_memory::{bitmap::AtomicBitmap, Address, GuestAddress, GuestUsize};
|
||||
use vm_memory::{Bytes, GuestMemoryAtomic};
|
||||
use virtio_queue::{Queue, QueueT, VirtqUsedElem};
|
||||
use vm_memory::{bitmap::AtomicBitmap, Address, Bytes, GuestAddress, GuestUsize};
|
||||
|
||||
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
|
||||
|
||||
@@ -225,16 +224,14 @@ pub mod testing {
|
||||
}
|
||||
|
||||
// Creates a new Queue, using the underlying memory regions represented by the VirtQueue.
|
||||
pub fn create_queue(&self) -> Queue<GuestMemoryAtomic<GuestMemoryMmap>> {
|
||||
let mem = GuestMemoryAtomic::new(self.mem.clone());
|
||||
let mut q =
|
||||
Queue::<GuestMemoryAtomic<GuestMemoryMmap>, QueueState>::new(mem, self.size());
|
||||
pub fn create_queue(&self) -> Queue {
|
||||
let mut q = Queue::new(self.size()).unwrap();
|
||||
|
||||
q.state.size = self.size();
|
||||
q.state.ready = true;
|
||||
q.state.desc_table = self.dtable_start();
|
||||
q.state.avail_ring = self.avail_start();
|
||||
q.state.used_ring = self.used_start();
|
||||
q.set_size(self.size());
|
||||
q.set_ready(true);
|
||||
q.try_set_desc_table_address(self.dtable_start()).unwrap();
|
||||
q.try_set_avail_ring_address(self.avail_start()).unwrap();
|
||||
q.try_set_used_ring_address(self.used_start()).unwrap();
|
||||
|
||||
q
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user