summaryrefslogtreecommitdiff
path: root/src/vhost_user/master.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhost_user/master.rs')
-rw-r--r--src/vhost_user/master.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vhost_user/master.rs b/src/vhost_user/master.rs
index f9da535..a721355 100644
--- a/src/vhost_user/master.rs
+++ b/src/vhost_user/master.rs
@@ -50,6 +50,9 @@ pub trait VhostUserMaster: VhostBackend {
/// Setup slave communication channel.
fn set_slave_request_fd(&mut self, fd: RawFd) -> Result<()>;
+
+ /// Query the maximum amount of memory slots supported by the backend.
+ fn get_max_mem_slots(&mut self) -> Result<u64>;
}
fn error_code<T>(err: VhostUserError) -> Result<T> {
@@ -435,6 +438,19 @@ impl VhostUserMaster for Master {
node.send_request_header(MasterReq::SET_SLAVE_REQ_FD, Some(&fds))?;
Ok(())
}
+
+ fn get_max_mem_slots(&mut self) -> Result<u64> {
+ let mut node = self.node();
+ if node.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits() == 0
+ {
+ return error_code(VhostUserError::InvalidOperation);
+ }
+
+ let hdr = node.send_request_header(MasterReq::GET_MAX_MEM_SLOTS, None)?;
+ let val = node.recv_reply::<VhostUserU64>(&hdr)?;
+
+ Ok(val.value)
+ }
}
impl AsRawFd for Master {