summaryrefslogtreecommitdiff
path: root/src/vhost_user/master.rs
diff options
context:
space:
mode:
authorSebastien Boeuf <sebastien.boeuf@intel.com>2021-03-08 12:00:31 +0100
committerJiang Liu <gerry@linux.alibaba.com>2021-03-10 23:37:29 +0800
commite7d46d6980ed1312e16243ff2ec4bb018f9aec5f (patch)
tree36bd2804a6c6cc8838e4050fe28ce1a15631c845 /src/vhost_user/master.rs
parent0bfb5a3180dbff2b29ec1fe8af4ed4dbec99a7db (diff)
downloadvmm_vhost-e7d46d6980ed1312e16243ff2ec4bb018f9aec5f.tar.gz
vhost_user: Add support for GET_MAX_MEM_SLOTS
Add the support for GET_MAX_MEM_SLOTS command. This requests the vhost-user backend to provide the maximum amount of memory slots that can be supported. It is only available if the protocol feature VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS has been negotiated. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
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 {