Skip to content

Commit 41252f5

Browse files
wangyan0507Fei Xu
authored andcommitted
vhost-user: fix vring base caculating
When the queue is not enabled, it should not call get_avail_idx which will cause an error. So, default to 0 in this situation. Signed-off-by: Yan Wang <[email protected]>
1 parent 529fe3b commit 41252f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

virtio/src/vhost/user/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,11 @@ impl VhostUserClient {
510510
queue_index,
511511
)
512512
})?;
513-
let last_avail_idx = queue.vring.get_avail_idx(&self.mem_space)?;
513+
let last_avail_idx = if queue.vring.is_enabled() {
514+
queue.vring.get_avail_idx(&self.mem_space)?
515+
} else {
516+
0
517+
};
514518
self.set_vring_base(queue_index, last_avail_idx)
515519
.with_context(|| {
516520
format!(

0 commit comments

Comments
 (0)