Skip to content

Commit fddac9b

Browse files
committed
feat(iovec): add head index to IoVecBufferMut
Now we will know the index of the head descriptor from which the IoVecBufferMut was build. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 5f94f2a commit fddac9b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ impl IoVecBuffer {
217217
/// of data from that buffer.
218218
#[derive(Debug, Default, Clone)]
219219
pub struct IoVecBufferMut {
220+
// Index of the head desciptor
221+
head_index: u16,
220222
// container of the memory regions included in this IO vector
221223
vecs: IoVecVec,
222224
// Total length of the IoVecBufferMut
@@ -234,6 +236,7 @@ impl IoVecBufferMut {
234236
head: DescriptorChain,
235237
) -> Result<(), IoVecError> {
236238
self.clear();
239+
self.head_index = head.index;
237240

238241
let mut next_descriptor = Some(head);
239242
while let Some(desc) = next_descriptor {
@@ -422,6 +425,7 @@ mod tests {
422425
impl From<&mut [u8]> for IoVecBufferMut {
423426
fn from(buf: &mut [u8]) -> Self {
424427
Self {
428+
head_index: 0,
425429
vecs: vec![iovec {
426430
iov_base: buf.as_mut_ptr().cast::<c_void>(),
427431
iov_len: buf.len(),
@@ -733,7 +737,12 @@ mod verification {
733737
};
734738

735739
let (vecs, len) = create_iovecs(mem, GUEST_MEMORY_SIZE);
736-
Self { vecs, len }
740+
let head_index = kani::any();
741+
Self {
742+
head_index,
743+
vecs,
744+
len,
745+
}
737746
}
738747
}
739748

0 commit comments

Comments
 (0)