Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dragonball: Support vhost-user-net device #8503

Merged
merged 3 commits into from Dec 25, 2023

Conversation

justxuewei
Copy link
Member

This PR introduces vhost-user-net devices to Dragonball. The devices are
allowed to run as server on the VMM side.

Fixes: #8502

Signed-off-by: Eric Ren renzhen@linux.alibaba.com
Signed-off-by: Liu Jiang gerry@linux.alibaba.com
Signed-off-by: Zha Bin zhabin@linux.alibaba.com
Signed-off-by: Chao Wu chaowu@linux.alibaba.com
Signed-off-by: Zizheng Bian zizheng.bian@linux.alibaba.com
Signed-off-by: Xuewei Niu niuxuewei.nxw@antgroup.com

@katacontainersbot katacontainersbot added the size/huge Largest and most complex task (probably needs breaking into small pieces) label Nov 23, 2023
@justxuewei
Copy link
Member Author

Hi @studychao @ZizhengBian @lifupan, vhost-user-net device has been tested with DPDK. Please take a look at this. Thanks!

match mem.read_slice(&mut buf, desc.addr()) {
Ok(_) => unsafe { Ok(std::ptr::read_volatile(&buf[..] as *const _ as *const T)) },
Err(err) => {
error!("Failed to read from memory, {}", err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the error msg here too generic? It's difficult to tell if it's vhost-net related.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used to read an object from memory, but its type is generic without implementing Debug trait. No more details are able to retrieve. To get more info, a possible way is to add a context("extra info here") when calling this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE 1: anyhow crate isn't used by Dragonball. So the context is unavailable. Then extra info is required to pass from parameters, which I think it isn't a elegant way.

}
}
Err(err) => {
error!("{}: failed to setup connection: {}", self.id, err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above two error messages are identical, making it difficult to figure out where goes wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VhostUserProtocol error branch is to try to reconnect. Others should be one type of errors: print error log and stop performing this function. Sharing one error message is acceptable in my perspective.

@justxuewei
Copy link
Member Author

Hi @liubogithub, I've pushed a new commit which resolve issues you mentioned in your code review. PTAL. Thanks!

@justxuewei justxuewei force-pushed the vhost-user-net branch 9 times, most recently from 47439af to 6e2d8fb Compare December 20, 2023 07:08
Copy link
Member

@studychao studychao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, a few comments

@@ -364,6 +367,10 @@ pub mod tests {
pub const VIRTQ_DESC_F_NEXT: u16 = 0x1;
pub const VIRTQ_DESC_F_WRITE: u16 = 0x2;

pub(crate) const GUEST_PHYS_END: u64 = (1 << 46) - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you use GUEST_PHYS_END, GUEST_MEM_START and GUEST_MEM_END defined in dbs_boot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Arc::new(cfg.queue_sizes()),
epoll_mgr.clone(),
)?)),
None => Err(VirtioError::InvalidInput),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about making this error information more explicit like NoEpollMgr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's great. However, other device managers, e.g. VirtioNetDeviceMgr, are still using the InvalidInput as well. Shall we file an issue to track this down and fix this in another PR?

let config = VirtioDeviceConfig::<Arc<GuestMemoryMmap<()>>>::new(
Arc::new(mem),
address_space,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you separate all addreess_space related change to a different commit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've slipt that changes into a separate commit.

@justxuewei justxuewei force-pushed the vhost-user-net branch 2 times, most recently from 34866a8 to 0d8312e Compare December 20, 2023 10:13
@justxuewei
Copy link
Member Author

Hi @studychao, I've addressed the issues mentioned in your comments. Could you take a look at this again? Thanks!

Copy link
Member

@studychao studychao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@justxuewei
Copy link
Member Author

/test

Vhost-user-net has a dependency on address space from `MmioV2DeviceState`.
The addition of the address space is introduced in this patch. Plus, it
makes sure all unit tests have the according parameter as well.

Fixes: kata-containers#8502

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This PR introduces vhost-user-net devices to Dragonball. The devices are
allowed to run as server on the VMM side.

Fixes: kata-containers#8502

Signed-off-by: Eric Ren <renzhen@linux.alibaba.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Zha Bin <zhabin@linux.alibaba.com>
Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
Signed-off-by: Zizheng Bian <zizheng.bian@linux.alibaba.com>
Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
@justxuewei justxuewei force-pushed the vhost-user-net branch 3 times, most recently from 88d797d to e6c1868 Compare December 22, 2023 07:14
@justxuewei justxuewei changed the title dragonball: Support vhost-user-net devices dragonball: Support vhost-user-net device Dec 22, 2023
@justxuewei
Copy link
Member Author

/test

Config space of network device is shared and accord with virtio 1.1 spec.
It is a good way to abstract the common part into one function.
`set_config_space()` implements this.

Plus, this patch removes `vq_pairs` from vhost-net devices, since there is
a possibility of data inconsistency. For example, some places read that
from `self.vq_pairs`, others read from `queue_sizes.len() / 2`.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
@justxuewei
Copy link
Member Author

/test

@justxuewei justxuewei merged commit 38eb407 into kata-containers:main Dec 25, 2023
166 of 176 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test size/huge Largest and most complex task (probably needs breaking into small pieces)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dragonball: Support vhost-user-net devices
5 participants