Skip to content

Commit 53381f7

Browse files
committed
refactor(iovec): add getters
Add methods to obtain head index and pointer to the first buffer from `IoVecBufferMut`. These methods will be used in later commits. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent fddac9b commit 53381f7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/vmm/src/devices/virtio/iovec.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ impl IoVecBufferMut {
281281
Ok(new_buffer)
282282
}
283283

284+
/// Get the index of the haed descriptor from which this IoVecBuffer
285+
/// was built.
286+
pub fn head_index(&self) -> u16 {
287+
self.head_index
288+
}
289+
290+
/// Get the host pointer to the first buffer in the guest,
291+
/// this buffer points to.
292+
///
293+
/// # Safety
294+
///
295+
/// It is assumed that IoVecBuffer will never have 0 elements
296+
/// as it is build from at least one DescriptorChain.
297+
pub fn start_address(&self) -> *mut libc::c_void {
298+
self.vecs[0].iov_base
299+
}
300+
284301
/// Get the total length of the memory regions covered by this `IoVecBuffer`
285302
pub(crate) fn len(&self) -> u32 {
286303
self.len

0 commit comments

Comments
 (0)