Skip to content

Commit 5f94f2a

Browse files
committed
refactor(queue): make structs/fields public
Make some structs/fields public as following commits will need this. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 027c7db commit 5f94f2a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vmm/src/devices/virtio/queue.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ unsafe impl ByteValued for Descriptor {}
5959
/// https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-430008
6060
/// 2.6.8 The Virtqueue Used Ring
6161
#[repr(C)]
62-
#[derive(Default, Clone, Copy)]
63-
struct UsedElement {
64-
id: u32,
65-
len: u32,
62+
#[derive(Default, Debug, Clone, Copy)]
63+
pub struct UsedElement {
64+
pub id: u32,
65+
pub len: u32,
6666
}
6767

6868
// SAFETY: `UsedElement` is a POD and contains no padding.
@@ -391,7 +391,7 @@ impl Queue {
391391
/// # Important
392392
/// This is an internal method that ASSUMES THAT THERE ARE AVAILABLE DESCRIPTORS. Otherwise it
393393
/// will retrieve a descriptor that contains garbage data (obsolete/empty).
394-
fn do_pop_unchecked<'b, M: GuestMemory>(
394+
pub fn do_pop_unchecked<'b, M: GuestMemory>(
395395
&mut self,
396396
mem: &'b M,
397397
) -> Option<DescriptorChain<'b, M>> {
@@ -468,7 +468,6 @@ impl Queue {
468468
self.set_used_ring_idx(self.next_used.0, mem);
469469
}
470470

471-
fn write_used_ring<M: GuestMemory>(
472471
/// Read used element from a used ring at specified index.
473472
#[inline(always)]
474473
pub fn read_used_ring<M: GuestMemory>(&self, mem: &M, index: u16) -> UsedElement {
@@ -491,6 +490,9 @@ impl Queue {
491490
mem.read_obj(used_element_address).unwrap()
492491
}
493492

493+
/// Read used element to the used ring at specified index.
494+
#[inline(always)]
495+
pub fn write_used_ring<M: GuestMemory>(
494496
&self,
495497
mem: &M,
496498
index: u16,
@@ -555,7 +557,7 @@ impl Queue {
555557

556558
/// Helper method that writes to the `avail_event` field of the used ring.
557559
#[inline(always)]
558-
fn set_used_ring_avail_event<M: GuestMemory>(&mut self, avail_event: u16, mem: &M) {
560+
pub fn set_used_ring_avail_event<M: GuestMemory>(&mut self, avail_event: u16, mem: &M) {
559561
debug_assert!(self.is_layout_valid(mem));
560562

561563
// Used ring has layout:
@@ -578,7 +580,7 @@ impl Queue {
578580

579581
/// Helper method that writes to the `idx` field of the used ring.
580582
#[inline(always)]
581-
fn set_used_ring_idx<M: GuestMemory>(&mut self, next_used: u16, mem: &M) {
583+
pub fn set_used_ring_idx<M: GuestMemory>(&mut self, next_used: u16, mem: &M) {
582584
debug_assert!(self.is_layout_valid(mem));
583585

584586
// Used ring has layout:

0 commit comments

Comments
 (0)