Skip to content

Commit

Permalink
Update to nix 0.24.1.
Browse files Browse the repository at this point in the history
This makes the contents of VsockAddr private, so we have to use the
provided methods instead.

Signed-off-by: Andrew Walbran <[email protected]>
  • Loading branch information
qwandor committed Jun 7, 2022
1 parent 9b5e180 commit b4a73ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude = ["test_fixture"]

[dependencies]
libc = "0.2.79"
nix = "0.23.0"
nix = "0.24.1"

[dev-dependencies]
rand = "0.8.3"
Expand Down
21 changes: 15 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl VsockListener {
/// Create a new VsockListener which is bound and listening on the socket address.
pub fn bind(addr: &SockAddr) -> Result<VsockListener> {
let mut vsock_addr = if let SockAddr::Vsock(addr) = addr {
addr.0
addr.as_ref().to_owned()
} else {
return Err(Error::new(
ErrorKind::Other,
Expand Down Expand Up @@ -116,7 +116,10 @@ impl VsockListener {
{
Err(Error::last_os_error())
} else {
Ok(SockAddr::Vsock(VsockAddr(vsock_addr)))
Ok(SockAddr::Vsock(VsockAddr::new(
vsock_addr.svm_cid,
vsock_addr.svm_port,
)))
}
}

Expand Down Expand Up @@ -229,7 +232,7 @@ impl VsockStream {
/// Open a connection to a remote host.
pub fn connect(addr: &SockAddr) -> Result<Self> {
let vsock_addr = if let SockAddr::Vsock(addr) = addr {
addr.0
addr.as_ref()
} else {
return Err(Error::new(
ErrorKind::Other,
Expand All @@ -244,7 +247,7 @@ impl VsockStream {
if unsafe {
connect(
sock,
&vsock_addr as *const _ as *const sockaddr,
vsock_addr as *const _ as *const sockaddr,
size_of::<sockaddr_vm>() as socklen_t,
)
} < 0
Expand Down Expand Up @@ -280,7 +283,10 @@ impl VsockStream {
{
Err(Error::last_os_error())
} else {
Ok(SockAddr::Vsock(VsockAddr(vsock_addr)))
Ok(SockAddr::Vsock(VsockAddr::new(
vsock_addr.svm_cid,
vsock_addr.svm_port,
)))
}
}

Expand All @@ -304,7 +310,10 @@ impl VsockStream {
{
Err(Error::last_os_error())
} else {
Ok(SockAddr::Vsock(VsockAddr(vsock_addr)))
Ok(SockAddr::Vsock(VsockAddr::new(
vsock_addr.svm_cid,
vsock_addr.svm_port,
)))
}
}

Expand Down

0 comments on commit b4a73ef

Please sign in to comment.