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
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"coverage_score": 18.62,
"coverage_score": 28.58,
"exclude_path": "oxerun",
"crate_features": ""
}
1 change: 0 additions & 1 deletion xen-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ edition = "2018"
[dependencies]
libc = ">=0.2.95"
vmm-sys-util = ">=0.9.0"
nix = "0.24.1"
xen-bindings = { path = "../xen-bindings" }
18 changes: 7 additions & 11 deletions xen-store/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

use std::io;

use nix::libc::{iovec, E2BIG};

pub const XENSTORED_SOCKET: &str = "/var/run/xenstored/socket";
pub const XENBUS_DEVICE: &str = "/dev/xen/xenbus";
pub const XENSTORE_PAYLOAD_MAX: u32 = 4096;

#[repr(C)]
Expand All @@ -26,21 +25,18 @@ pub(crate) struct XenSocketMessage {
}

impl XenSocketMessage {
#[allow(clippy::ptr_arg)]
pub(crate) fn new(r#type: u32, iovec_buffers: &mut Vec<iovec>) -> Result<Self, std::io::Error> {
pub(crate) fn new(r#type: u32, payload_len: usize) -> Result<Self, std::io::Error> {
if payload_len > XENSTORE_PAYLOAD_MAX as usize {
return Err(io::Error::from_raw_os_error(libc::E2BIG));
}

let msg = XenSocketMessage {
r#type,
req_id: 0,
tx_id: 0,
len: iovec_buffers
.iter()
.fold(0, |acc, iovec| acc + iovec.iov_len as u32),
len: payload_len as u32,
};

if msg.len > XENSTORE_PAYLOAD_MAX {
return Err(io::Error::from_raw_os_error(E2BIG));
}

Ok(msg)
}
}
Expand Down
Loading