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

Add vsock device support #52

Closed
wants to merge 3 commits into from
Closed

Conversation

alexandruag
Copy link
Collaborator

This PR adds support for vsock devices, based on the backend and packet parser implementation currently available in Firecracker (some more details about the Firecracker Unix Domain Socket vsock backend are available here). The code is written and brought over on top of #49.

One way to verify the vsock device operation is to follow the next steps. First, build the vsock helper program from here (ideally as a static binary) and copy the binary to the guest filesystem image. After the guest boots with a vsock device added (i.e. by appending something like --vsock cid=5,uds_path=/tmp/vsock_uds0 to the vmm command line), start the listener server within the guest using ./vsock_helper echosrv 5252 (5252 is an arbitrary port number). Then, on the host, we can use something like the following script to verify that can send some data over the UDS vsock backend, and get a reply:

import re
from socket import socket, AF_UNIX, SOCK_STREAM

uds_path = '/tmp/vsock_uds0'
port = 5252

sock = socket(AF_UNIX, SOCK_STREAM)
sock.connect(uds_path)

buf = bytearray("CONNECT {}\n".format(port).encode("utf-8"))
assert sock.send(buf) == len(buf)

ack_buf = sock.recv(32)
assert re.match("^OK [0-9]+\n$", ack_buf.decode('utf-8')) is not None

msg = "vsock is working"
msg_buf = bytes(msg, 'utf-8')

sent = sock.send(msg_buf)
assert sent == len(msg_buf)

recv_buf = sock.recv(sent)
assert len(recv_buf) == len(msg_buf)
assert recv_buf == msg_buf

print(recv_buf.decode('utf-8'))

We're going to bring over parts of the vsock test infrastructure as well after advancing the discussion around dirty page tracking in vm-memory and seeing how the ongoing vm-virtio discussions conclude. The former is important because we want to start using VolatileSlices for the VsockPacket abstractions, while the latter influence the boiler plate code we have to adapt as part of the testing infrastructure.

Signed-off-by: Alexandru Agache <[email protected]>
Signed-off-by: Alexandru Agache <[email protected]>
Signed-off-by: Alexandru Agache <[email protected]>
@andreeaflorescu
Copy link
Member

Closing this as we are going to add support once we upstream the components in vm-virtio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants