Skip to content

Commit

Permalink
virtio-devices: vhost-user: Send set_vring_num before setup inflight …
Browse files Browse the repository at this point in the history
…I/O tracking

backend like SPDK required to know how many virt queues to be handled
before gets VHOST_USER_SET_INFLIGHT_FD message.

fix dpdk core dump while processing vhost_user_set_inflight_fd:
    #0 0x00007fffef47c347 in vhost_user_set_inflight_fd (pdev=0x7fffe2895998, msg=0x7fffe28956f0, main_fd=545) at ../lib/librte_vhost/vhost_user.c:1570
    #1 0x00007fffef47e7b9 in vhost_user_msg_handler (vid=0, fd=545) at ../lib/librte_vhost/vhost_user.c:2735
    #2 0x00007fffef46bac0 in vhost_user_read_cb (connfd=545, dat=0x7fffdc0008c0, remove=0x7fffe2895a64) at ../lib/librte_vhost/socket.c:309
    #3 0x00007fffef45b3f6 in fdset_event_dispatch (arg=0x7fffef6dc2e0 <vhost_user+8192>) at ../lib/librte_vhost/fd_man.c:286
    #4 0x00007ffff09926f3 in rte_thread_init (arg=0x15ee180) at ../lib/librte_eal/common/eal_common_thread.c:175

Signed-off-by: Arafatms <arafatms@outlook.com>
  • Loading branch information
arafatms authored and Sebastien Boeuf committed Aug 4, 2021
1 parent c7d3992 commit 8fb53eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 0 additions & 10 deletions virtio-devices/src/vhost_user/blk.rs
Expand Up @@ -24,7 +24,6 @@ use vhost::vhost_user::message::VhostUserConfigFlags;
use vhost::vhost_user::message::VHOST_USER_CONFIG_OFFSET;
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost::vhost_user::{MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler};
use vhost::VhostBackend;
use virtio_bindings::bindings::virtio_blk::{
VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_CONFIG_WCE, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_FLUSH,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX,
Expand Down Expand Up @@ -128,15 +127,6 @@ impl Blk {
config.num_queues = num_queues as u16;
}

// Send set_vring_base here, since it could tell backends, like SPDK,
// how many virt queues to be handled, which backend required to know
// at early stage.
for i in 0..num_queues {
vu.socket_handle()
.set_vring_base(i, 0)
.map_err(Error::VhostUserSetVringBase)?;
}

Ok(Blk {
common: VirtioCommon {
device_type: VirtioDeviceType::Block as u32,
Expand Down
13 changes: 9 additions & 4 deletions virtio-devices/src/vhost_user/vu_common_ctrl.rs
Expand Up @@ -141,6 +141,15 @@ impl VhostUserHandle {
// Let's first provide the memory table to the backend.
self.update_mem_table(mem)?;

// Send set_vring_num here, since it could tell backends, like SPDK,
// how many virt queues to be handled, which backend required to know
// at early stage.
for (queue_index, queue) in queues.iter().enumerate() {
self.vu
.set_vring_num(queue_index, queue.actual_size())
.map_err(Error::VhostUserSetVringNum)?;
}

// Setup for inflight I/O tracking shared memory.
if let Some(inflight) = inflight {
if inflight.fd.is_none() {
Expand Down Expand Up @@ -168,10 +177,6 @@ impl VhostUserHandle {
for (queue_index, queue) in queues.into_iter().enumerate() {
let actual_size: usize = queue.actual_size().try_into().unwrap();

self.vu
.set_vring_num(queue_index, queue.actual_size())
.map_err(Error::VhostUserSetVringNum)?;

let config_data = VringConfigData {
queue_max_size: queue.get_max_size(),
queue_size: queue.actual_size(),
Expand Down

0 comments on commit 8fb53eb

Please sign in to comment.