rust-vsock / vsock-rs

Virtio socket support for Rust
https://crates.io/crates/vsock
Apache License 2.0
27 stars 19 forks source link

nix 0.24 made VsockAddr opaque #24

Closed jamessan closed 2 years ago

jamessan commented 2 years ago

https://github.com/nix-rust/nix/pull/1614

vsock won't build with nix >= 0.24.

Build log ``` error[E0423]: cannot initialize a tuple struct which contains private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:117:32 | 117 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^^^^^ help: a local variable with a similar name exists: `vsock_addr` | note: constructor is not visible here due to private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/nix-0.24.1/src/sys/socket/addr.rs:2518:26 | 2518 | pub struct VsockAddr(pub(in super::super) sockaddr_vm); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private field error[E0423]: cannot initialize a tuple struct which contains private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:281:32 | 281 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^^^^^ help: a local variable with a similar name exists: `vsock_addr` | note: constructor is not visible here due to private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/nix-0.24.1/src/sys/socket/addr.rs:2518:26 | 2518 | pub struct VsockAddr(pub(in super::super) sockaddr_vm); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private field error[E0423]: cannot initialize a tuple struct which contains private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:305:32 | 305 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^^^^^ help: a local variable with a similar name exists: `vsock_addr` | note: constructor is not visible here due to private fields --> /tmp/tmp.xk1r9Xh1Kg/registry/nix-0.24.1/src/sys/socket/addr.rs:2518:26 | 2518 | pub struct VsockAddr(pub(in super::super) sockaddr_vm); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private field warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:29:28 | 29 | pub use nix::sys::socket::{SockAddr, VsockAddr}; | ^^^^^^^^ | = note: `#[warn(deprecated)]` on by default warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:57:24 | 57 | pub fn bind(addr: &SockAddr) -> Result { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:58:47 | 58 | let mut vsock_addr = if let SockAddr::Vsock(addr) = addr { | ^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:94:31 | 94 | Self::bind(&SockAddr::Vsock(VsockAddr::new(cid, port))) | ^^^^^ warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:98:40 | 98 | pub fn local_addr(&self) -> Result { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:117:26 | 117 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^ warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:127:50 | 127 | pub fn accept(&self) -> Result<(VsockStream, SockAddr)> { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:149:27 | 149 | SockAddr::Vsock(VsockAddr::new(vsock_addr.svm_cid, vsock_addr.svm_port)), | ^^^^^ warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:228:27 | 228 | pub fn connect(addr: &SockAddr) -> Result { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:229:43 | 229 | let vsock_addr = if let SockAddr::Vsock(addr) = addr { | ^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:258:34 | 258 | Self::connect(&SockAddr::Vsock(VsockAddr::new(cid, port))) | ^^^^^ warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:262:39 | 262 | pub fn peer_addr(&self) -> Result { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:281:26 | 281 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^ warning: use of deprecated enum `nix::sys::socket::SockAddr`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:286:40 | 286 | pub fn local_addr(&self) -> Result { | ^^^^^^^^ warning: use of deprecated variant `nix::sys::socket::SockAddr::Vsock`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:305:26 | 305 | Ok(SockAddr::Vsock(VsockAddr(vsock_addr))) | ^^^^^ warning: use of deprecated field `nix::sys::socket::SockAddr::Vsock::0`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:58:53 | 58 | let mut vsock_addr = if let SockAddr::Vsock(addr) = addr { | ^^^^ error[E0616]: field `0` of struct `VsockAddr` is private --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:59:18 | 59 | addr.0 | ^ private field warning: use of deprecated field `nix::sys::socket::SockAddr::Vsock::0`: use SockaddrLike or SockaddrStorage instead --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:229:49 | 229 | let vsock_addr = if let SockAddr::Vsock(addr) = addr { | ^^^^ error[E0616]: field `0` of struct `VsockAddr` is private --> /tmp/tmp.xk1r9Xh1Kg/registry/vsock-0.2.4/src/lib.rs:230:18 | 230 | addr.0 | ^ private field ```
Tim-Zhang commented 2 years ago

Why you guys need such a new version of nix. just curious. Knowing usecases of our users will make the project better.

qwandor commented 2 years ago

In Android we vendor in all third-party dependencies, including Rust crates, and build with Soong (not cargo). This means that we can only have one version of each crate in the tree. We will need to update nix at some point for other users, and so we need the vsock crate to build with the latest version.

And even in the cargo ecosystem, it's generally desirable to avoid having multiple versions of the same crate where possible, to reduce build time and binary size.

jamessan commented 2 years ago

I'm in a similar situation as qwandor. Debian packages crates, primarily to serve building bin crates. It's possible for us to have multiple, versioned crates for a single project in Debian, but we try to avoid it if at all possible.

We recently bumped nix to 0.24 without realizing that a couple of the dependent packages, vsock included, would be affected by the breaking changes in 0.24.