mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
vm-virtio: Provide a way to clone a Queue
Since the QueueState structure has been updated by not implementing Clone anymore, we need a way to keep cloning the Queue. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
1651253777
commit
c622b43f85
@ -12,8 +12,10 @@
|
||||
|
||||
use std::fmt::{self, Debug};
|
||||
use std::sync::Arc;
|
||||
use virtio_queue::Queue;
|
||||
use vm_memory::{bitmap::AtomicBitmap, GuestAddress, GuestMemoryAtomic};
|
||||
|
||||
use vm_memory::GuestAddress;
|
||||
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
|
||||
|
||||
pub mod queue;
|
||||
pub use queue::*;
|
||||
@ -121,3 +123,24 @@ impl Translatable for GuestAddress {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper for cloning a Queue since QueueState doesn't derive Clone
|
||||
pub fn clone_queue(
|
||||
queue: &Queue<GuestMemoryAtomic<GuestMemoryMmap>>,
|
||||
) -> Queue<GuestMemoryAtomic<GuestMemoryMmap>> {
|
||||
Queue::<GuestMemoryAtomic<GuestMemoryMmap>, virtio_queue::QueueState> {
|
||||
mem: queue.mem.clone(),
|
||||
state: virtio_queue::QueueState {
|
||||
max_size: queue.state.max_size,
|
||||
next_avail: queue.state.next_avail,
|
||||
next_used: queue.state.next_used,
|
||||
event_idx_enabled: queue.state.event_idx_enabled,
|
||||
signalled_used: queue.state.signalled_used,
|
||||
size: queue.state.size,
|
||||
ready: queue.state.ready,
|
||||
desc_table: queue.state.desc_table,
|
||||
avail_ring: queue.state.avail_ring,
|
||||
used_ring: queue.state.used_ring,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user