File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -281,3 +281,37 @@ impl<T: VhostKernBackend> VhostBackend for T {
281
281
ioctl_result ( ret, ( ) )
282
282
}
283
283
}
284
+
285
+ /// Interface to handle in-kernel backend features.
286
+ pub trait VhostKernFeatures : Sized + AsRawFd {
287
+ /// Get features acked with the vhost backend.
288
+ fn get_backend_features_acked ( & self ) -> u64 ;
289
+
290
+ /// Set features acked with the vhost backend.
291
+ fn set_backend_features_acked ( & mut self , features : u64 ) ;
292
+
293
+ /// Get a bitmask of supported vhost backend features.
294
+ fn get_backend_features ( & self ) -> Result < u64 > {
295
+ let mut avail_features: u64 = 0 ;
296
+ // This ioctl is called on a valid vhost fd and has its return value checked.
297
+ let ret =
298
+ unsafe { ioctl_with_mut_ref ( self , VHOST_GET_BACKEND_FEATURES ( ) , & mut avail_features) } ;
299
+ ioctl_result ( ret, avail_features)
300
+ }
301
+
302
+ /// Inform the vhost subsystem which backend features to enable. This should
303
+ /// be a subset of supported features from VHOST_GET_BACKEND_FEATURES.
304
+ ///
305
+ /// # Arguments
306
+ /// * `features` - Bitmask of features to set.
307
+ fn set_backend_features ( & mut self , features : u64 ) -> Result < ( ) > {
308
+ // This ioctl is called on a valid vhost fd and has its return value checked.
309
+ let ret = unsafe { ioctl_with_ref ( self , VHOST_SET_BACKEND_FEATURES ( ) , & features) } ;
310
+
311
+ if ret >= 0 {
312
+ self . set_backend_features_acked ( features) ;
313
+ }
314
+
315
+ ioctl_result ( ret, ( ) )
316
+ }
317
+ }
You can’t perform that action at this time.
0 commit comments