mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: checked_descriptor: Add unit test for zero length descriptor
Add passes_through_zero_length_descriptor which submits a descriptor with len 0 and verifies CheckedDescriptorIter yields it without performing a guest memory range check. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
782ce21c1a
commit
3ced92702a
@@ -238,4 +238,17 @@ mod unit_tests {
|
|||||||
let result = it.next().expect("iterator must yield an item");
|
let result = it.next().expect("iterator must yield an item");
|
||||||
result.unwrap_err();
|
result.unwrap_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn passes_through_zero_length_descriptor() {
|
||||||
|
let (_mem, mem_atomic, mut queue) = setup_vq(128 * 1024, 0x4000, 0, 0);
|
||||||
|
let mem_guard = mem_atomic.memory();
|
||||||
|
let mut chain = queue.pop_descriptor_chain(mem_guard).unwrap();
|
||||||
|
let mut it = chain.checked_iter(None);
|
||||||
|
let desc = it
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.expect("zero length descriptor must pass through");
|
||||||
|
assert_eq!(desc.len(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user