Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/propolis/src/vsock/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ mod test {
let mut accepted = listener.accept().unwrap().0;
accepted.set_nonblocking(false).unwrap();
accepted.set_read_timeout(Some(Duration::from_secs(5))).unwrap();

// Wait for the RESPONSE packet to arrive. The poller takes a desc from
// the rx_avail ring, writes the packet into it, and publishes it via
// `push_used` updating rx_used.
wait_for_condition(|| harness.rx_used_idx() >= 1, 5000);

// Send enough data to exceed half the buffer capacity (64KB).
Expand All @@ -1473,8 +1477,14 @@ mod test {
let payload = vec![0xAB_u8; chunk_size];
let total_sent = num_chunks * chunk_size;

// This is the vsock poller copying the REQUEST data and calling
// `push_used` which bumps the tx ring's used index.
let initial_tx_used = harness.tx_used_idx();

for tx_consumed in (1u16..).take(num_chunks) {
// Reuse descriptor slots each iteration
// Reuse descriptor slots each iteration. This is only safe because
// this test ensures that all tx_avail descriptors are pushed back
// to us via tx_used.
harness.reset_tx_cursors();

let mut rw_hdr = VsockPacketHeader::new();
Expand All @@ -1495,7 +1505,13 @@ mod test {
harness.publish_tx(d_hdr);
notify.queue_notify(VSOCK_TX_QUEUE).unwrap();

wait_for_condition(|| harness.tx_used_idx() >= tx_consumed, 5000);
// Wait for the poller to release the desc chain back to us via
// tx_used. This is the running total of the REQUEST and n RW
// packets.
wait_for_condition(
|| harness.tx_used_idx() >= initial_tx_used + tx_consumed,
5000,
);
}

// Drain the data from the accepted socket to confirm it arrived
Expand Down
Loading