-
Notifications
You must be signed in to change notification settings - Fork 57
vhost-device-console: add Unix domain socket backend support #821
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
base: main
Are you sure you want to change the base?
Conversation
c942138
to
2e00bdf
Compare
I see some CI fails, trying to reproduce on my dev machine, but currently blocked by some dependency of a newer libc version, I'll try to solve the problem next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR!
I like the new backend, but please add a better description in the PR and also don't mix fixes, refactoring and new feature in a single commit, otherwise it's a mess to review and also to maintain.
I'll wait better commits before a deeper review.
1f6dc04
to
68d1378
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, now the commit are much much better!
About the changes, I'd check better that --tcp-port is used only with network backend and --uds-path only with uds.
Thanks for your patient review. This week, I have some higher-priority work to do, and I will complete the changes you suggested next week. |
You're welcome!
@DarcySail sure, it's not a problem at all, take your time! |
Replace non-informative expect() messages with meaningful error contexts. Signed-off-by: Hang SU <[email protected]>
Rename TCP-related identifiers to generic socket terminology: generate_tcp_addrs → generate_vm_socks tcp_addr → vm_sock listener → tcp_listener Simplify stream handler method names: write_tcp_stream → write_stream read_tcp_stream → read_stream conventions without functional changes. Signed-off-by: Hang SU <[email protected]>
Rework conditional logic using match expressions for backend type dispatch. No functional changes, this patch is a preparation for new backend type: uds. Signed-off-by: Hang SU <[email protected]>
68d1378
to
784263c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just minor comments.
9569918
to
aa6ab82
Compare
Agreed, I add a check patch for parameter mutual exclusivity~ |
72ae395
to
eae96e0
Compare
- Introduce `BackendType::Uds` for VM communication via Unix sockets - Refactor address generation logic with `generate_vm_sock_addrs` - Add CLI parameter `--vm-sock` to specify UDS path - Update documentation and error handling Signed-off-by: Hang SU <[email protected]> Suggested-by: Xuewei Niu <[email protected]>
- Verify UDS path parent directory existence check - Test UDS address generation logic with multiple sockets - Add error handling test for invalid UDS backend initialization Signed-off-by: Hang SU <[email protected]>
- Introduce `InvalidCmdlineOption` error type to handle conflicting parameters - Implement backend-specific parameter checks: * Nested backend: - Require single socket (socket_count=1) - Disallow TCP port/UDS path * Network backend: Disallow UDS path * UDS backend: Disallow TCP port - Remove default TCP port value to enforce explicit configuration Signed-off-by: Hang SU <[email protected]>
eae96e0
to
7f81834
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments here...
<normal UML options> \ | ||
virtio_uml.device=/tmp/console.sock0:3 console=tty0 console=hvc0 \ | ||
init=/bin/systemd \ | ||
systemd.unit=kata-containers.target agent.debug_console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think testing with UML does not need to depend on Kata Containers:
- Remove staff regarding kata-containers:
systemd.unit
,debug_console
. - Use
/bin/bash
instead.
$ sudo linux ubd0=kata-ubuntu-latest.image \
root=/dev/ubda1 \
init=/bin/bash \
console=hvc0 \
virtio_uml.device=/tmp/console.sock0:3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, Kata's rootfs image can still be used here.
let uds_parent = self | ||
.uds_path | ||
.parent() | ||
.expect("uds has no parent directory."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to create all directories, instead of doing expect()
here.
if args.backend == BackendType::Nested { | ||
if args.socket_count != 1 { | ||
return Err(Error::WrongBackendSocket); | ||
} | ||
|
||
if (args.tcp_port.as_ref().map_or(false, |s| !s.is_empty())) | ||
|| (args | ||
.uds_path | ||
.as_ref() | ||
.map_or(false, |path| !path.as_os_str().is_empty())) | ||
{ | ||
return Err(Error::InvalidCmdlineOption); | ||
} | ||
} | ||
|
||
if args.backend == BackendType::Network | ||
&& args | ||
.uds_path | ||
.as_ref() | ||
.map_or(false, |path| !path.as_os_str().is_empty()) | ||
{ | ||
return Err(Error::InvalidCmdlineOption); | ||
} | ||
|
||
if args.backend == BackendType::Uds | ||
&& args.tcp_port.as_ref().map_or(false, |s| !s.is_empty()) | ||
{ | ||
return Err(Error::InvalidCmdlineOption); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use match args.backend
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your reply.
I get several high-priority tasks this week, I will make time to implement the code changes as your comments.
Summary of the PR
Please summarize here why the changes in this PR are needed.
kata platform use uds to connect with VM layer.
#815
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s
), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafe
code is properly documented.