Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to

### Added

- [#5595](https://github.com/firecracker-microvm/firecracker/pull/5595): Added
`vsock_type` field to the vsock device API to denote the type of the
underlying socket. Can be `stream` or `seqpacket`
- [#5595](https://github.com/firecracker-microvm/firecracker/pull/5595): Added
`conn_buffer_size` field to denote how many bytes we can internally buffer
during receiving large seqpacket packets from the host.
- [#5323](https://github.com/firecracker-microvm/firecracker/pull/5323): Add
support for Vsock Unix domain socket path overriding on snapshot restore. More
information can be found in the
Expand Down
26 changes: 26 additions & 0 deletions resources/seccomp/aarch64-unknown-linux-musl.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,32 @@
}
]
},
{
"syscall": "socket",
"comment": "Called to open the vsock seqpacket UDS (SeqpacketConn::connect and SeqpacketListener::bind)",
"args": [
{
"index": 0,
"type": "dword",
"op": "eq",
"val": 1,
"comment": "libc::AF_UNIX"
},
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 524293,
"comment": "libc::SOCK_SEQPACKET | libc::SOCK_CLOEXEC"
},
{
"index": 2,
"type": "dword",
"op": "eq",
"val": 0
}
]
},
{
"syscall": "sendto",
"comment": "Rust std uses it to write to unix socket"
Expand Down
26 changes: 26 additions & 0 deletions resources/seccomp/x86_64-unknown-linux-musl.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,32 @@
}
]
},
{
"syscall": "socket",
"comment": "Called to open the vsock seqpacket UDS (SeqpacketConn::connect and SeqpacketListener::bind)",
"args": [
{
"index": 0,
"type": "dword",
"op": "eq",
"val": 1,
"comment": "libc::AF_UNIX"
},
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 524293,
"comment": "libc::SOCK_SEQPACKET | libc::SOCK_CLOEXEC"
},
{
"index": 2,
"type": "dword",
"op": "eq",
"val": 0
}
]
},
{
"syscall": "sendto",
"comment": "Rust std uses it to write to unix socket"
Expand Down
2 changes: 1 addition & 1 deletion src/firecracker/src/api_server/parsed_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ pub mod tests {
fn test_try_from_put_vsock() {
let (mut sender, receiver) = UnixStream::pair().unwrap();
let mut connection = HttpConnection::new(receiver);
let body = "{ \"vsock_id\": \"string\", \"guest_cid\": 0, \"uds_path\": \"string\" }";
let body = "{ \"vsock_id\": \"string\", \"guest_cid\": 0, \"uds_path\": \"string\", \"vsock_type\": \"stream\" }";
sender
.write_all(http_request("PUT", "/vsock", Some(body)).as_bytes())
.unwrap();
Expand Down
9 changes: 6 additions & 3 deletions src/firecracker/src/api_server/request/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ mod tests {
fn test_parse_put_vsock_request() {
let body = r#"{
"guest_cid": 42,
"uds_path": "vsock.sock"
"uds_path": "vsock.sock",
"vsock_type": "stream"
}"#;
parse_put_vsock(&Body::new(body)).unwrap();

Expand All @@ -57,7 +58,8 @@ mod tests {
let body = r#"{
"vsock_id": "foo",
"guest_cid": 42,
"uds_path": "vsock.sock"
"uds_path": "vsock.sock",
"vsock_type": "stream"
}"#;
depr_action_from_req(
parse_put_vsock(&Body::new(body)).unwrap(),
Expand All @@ -66,7 +68,8 @@ mod tests {

let body = r#"{
"guest_cid": 42,
"uds_path": "vsock.sock"
"uds_path": "vsock.sock",
"vsock_type": "stream"
}"#;
let (_, mut parsing_info) = parse_put_vsock(&Body::new(body)).unwrap().into_parts();
assert!(parsing_info.take_deprecation_message().is_none());
Expand Down
16 changes: 16 additions & 0 deletions src/firecracker/swagger/firecracker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,22 @@ definitions:
uds_path:
type: string
description: Path to UNIX domain socket, used to proxy vsock connections.
vsock_type:
description: Enumeration indicating the type of the underlying socket (stream or seqpacket)
type: string
enum:
- stream
- seqpacket
default: stream
conn_buffer_size:
Comment thread
aerosouund marked this conversation as resolved.
type: integer
minimum: 4096
maximum: 262144
description:
The amount in bytes that can be buffered in firecracker if the data in the tx/rx queue is
too much to fit in a single descriptor. This parameter is ignored for stream sockets
because connection buffering is a seqpacket only concept. The minimum is 4096 (one
virtqueue descriptor) and the maximum is 256KB (kernel limit)
vsock_id:
type: string
description:
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ pub(crate) mod tests {
vsock_config: VsockDeviceConfig,
) {
let vsock_dev_id = VSOCK_DEV_ID.to_owned();
let vsock = VsockBuilder::create_unixsock_vsock(vsock_config).unwrap();
let vsock = VsockBuilder::create_unixsock_vsock(&vsock_config).unwrap();
let vsock = Arc::new(Mutex::new(vsock));

attach_unixsock_vsock_device(
Expand Down
7 changes: 5 additions & 2 deletions src/vmm/src/device_manager/pci_mngr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ mod tests {
use crate::vmm_config::memory_hotplug::MemoryHotplugConfig;
use crate::vmm_config::net::NetworkInterfaceConfig;
use crate::vmm_config::pmem::PmemConfig;
use crate::vmm_config::vsock::VsockDeviceConfig;
use crate::vmm_config::vsock::{VsockDeviceConfig, VsockType};

#[test]
fn test_device_manager_persistence() {
Expand Down Expand Up @@ -693,6 +693,8 @@ mod tests {
vsock_id: Some(vsock_dev_id.to_string()),
guest_cid: 3,
uds_path: tmp_sock_file.as_path().to_str().unwrap().to_string(),
vsock_type: VsockType::Stream,
conn_buffer_size: None,
};
insert_vsock_device(&mut vmm, &mut cmdline, &mut event_manager, vsock_config);
// Add an entropy device.
Expand Down Expand Up @@ -803,7 +805,8 @@ mod tests {
],
"vsock": {{
"guest_cid": 3,
"uds_path": "{}"
"uds_path": "{}",
"vsock_type": "stream"
}},
"entropy": {{
"rate_limiter": null
Expand Down
7 changes: 5 additions & 2 deletions src/vmm/src/device_manager/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ mod tests {
use crate::vmm_config::memory_hotplug::MemoryHotplugConfig;
use crate::vmm_config::net::NetworkInterfaceConfig;
use crate::vmm_config::pmem::PmemConfig;
use crate::vmm_config::vsock::VsockDeviceConfig;
use crate::vmm_config::vsock::{VsockDeviceConfig, VsockType};

impl<T> PartialEq for VirtioDeviceState<T> {
fn eq(&self, other: &VirtioDeviceState<T>) -> bool {
Expand Down Expand Up @@ -723,6 +723,8 @@ mod tests {
vsock_id: Some(vsock_dev_id.to_string()),
guest_cid: 3,
uds_path: tmp_sock_file.as_path().to_str().unwrap().to_string(),
vsock_type: VsockType::Stream,
conn_buffer_size: None,
};
insert_vsock_device(&mut vmm, &mut cmdline, &mut event_manager, vsock_config);
// Add an entropy device.
Expand Down Expand Up @@ -830,7 +832,8 @@ mod tests {
],
"vsock": {{
"guest_cid": 3,
"uds_path": "{}"
"uds_path": "{}",
"vsock_type": "stream"
}},
"entropy": {{
"rate_limiter": null
Expand Down
1 change: 1 addition & 0 deletions src/vmm/src/devices/virtio/generated/virtio_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
clippy::redundant_static_lifetimes
)]

pub const VIRTIO_VSOCK_F_SEQPACKET: u32 = 1;
pub const VIRTIO_F_NOTIFY_ON_EMPTY: u32 = 24;
pub const VIRTIO_F_ANY_LAYOUT: u32 = 27;
pub const VIRTIO_F_VERSION_1: u32 = 32;
Expand Down
4 changes: 3 additions & 1 deletion src/vmm/src/devices/virtio/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ mod tests {
use crate::devices::virtio::test_utils::default_mem;
use crate::devices::virtio::transport::mmio::tests::DummyDevice;
use crate::devices::virtio::vsock::{Vsock, VsockUnixBackend};
use crate::snapshot::Snapshot;
use crate::vmm_config::vsock::VsockType;

const DEFAULT_QUEUE_MAX_SIZE: u16 = 256;
impl Default for QueueState {
Expand Down Expand Up @@ -481,7 +483,7 @@ mod tests {
// Remove the file so the path can be used by the socket.
temp_uds_path.remove().unwrap();
let uds_path = String::from(temp_uds_path.as_path().to_str().unwrap());
let backend = VsockUnixBackend::new(guest_cid, uds_path).unwrap();
let backend = VsockUnixBackend::new(guest_cid, uds_path, VsockType::Stream, None).unwrap();
let vsock = Vsock::new(guest_cid, backend).unwrap();
let vsock = Arc::new(Mutex::new(vsock));
let mmio_transport =
Expand Down
Loading