mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-10 13:54:12 +00:00
runtime-rs: Introduce Capability of HybridVsockSupport.
Introduce HybridVsock Cap to judge which kind of vm socket will be supported by the Hypervisor. Use `is_hybrid_vsock_supported` to tell if an hypervisor supports hybrid-vsock, if not, it supports legacy vsock. Fixes: #8474 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
6af0592274
commit
c5178dd258
@ -17,6 +17,8 @@ pub enum CapabilityBits {
|
||||
MultiQueueSupport,
|
||||
/// hypervisor supports filesystem share
|
||||
FsSharingSupport,
|
||||
/// hypervisor supports hybrid-vsock
|
||||
HybridVsockSupport,
|
||||
}
|
||||
|
||||
/// Capabilities describe a virtcontainers hypervisor capabilities through a bit mask.
|
||||
@ -60,6 +62,11 @@ impl Capabilities {
|
||||
self.flags.and(CapabilityBits::MultiQueueSupport) != 0
|
||||
}
|
||||
|
||||
/// is_hybrid_vsock_supported tells if an hypervisor supports hybrid-vsock support.
|
||||
pub fn is_hybrid_vsock_supported(&self) -> bool {
|
||||
self.flags.and(CapabilityBits::HybridVsockSupport) != 0
|
||||
}
|
||||
|
||||
/// is_fs_sharing_supported tells if an hypervisor supports host filesystem sharing.
|
||||
pub fn is_fs_sharing_supported(&self) -> bool {
|
||||
self.flags.and(CapabilityBits::FsSharingSupport) != 0
|
||||
@ -77,6 +84,9 @@ mod tests {
|
||||
let mut cap = Capabilities::new();
|
||||
assert!(!cap.is_block_device_supported());
|
||||
|
||||
// test legacy vsock support
|
||||
assert!(!cap.is_hybrid_vsock_supported());
|
||||
|
||||
// test set block device support
|
||||
cap.set(CapabilityBits::BlockDeviceSupport);
|
||||
assert!(cap.is_block_device_supported());
|
||||
@ -102,6 +112,10 @@ mod tests {
|
||||
| CapabilityBits::MultiQueueSupport
|
||||
| CapabilityBits::FsSharingSupport,
|
||||
);
|
||||
assert!(cap.is_fs_sharing_supported())
|
||||
assert!(cap.is_fs_sharing_supported());
|
||||
|
||||
// test set hybrid-vsock support
|
||||
cap.set(CapabilityBits::HybridVsockSupport);
|
||||
assert!(cap.is_hybrid_vsock_supported());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user