mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-25 22:49:59 +00:00
kata-types: Add support for capability of block discard/unmap
To tells if the hypervisor exposes block discard/unmap support to the guest, we introduce a new capability of discard/unmap named `BlockDeviceDiscardSupport` in the capability set. Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
committed by
Fabiano Fidêncio
parent
569cbd21ca
commit
4951b14611
@@ -21,6 +21,8 @@ pub enum CapabilityBits {
|
||||
HybridVsockSupport,
|
||||
/// hypervisor supports memory hotplug probe interface
|
||||
GuestMemoryProbe,
|
||||
/// hypervisor supports exposing block discard/unmap to the guest
|
||||
BlockDeviceDiscardSupport,
|
||||
}
|
||||
|
||||
/// Capabilities describe a virtcontainers hypervisor capabilities through a bit mask.
|
||||
@@ -83,6 +85,12 @@ impl Capabilities {
|
||||
pub fn is_mem_hotplug_probe_supported(&self) -> bool {
|
||||
self.flags.and(CapabilityBits::GuestMemoryProbe) != 0
|
||||
}
|
||||
|
||||
/// is_block_device_discard_supported tells if the hypervisor exposes
|
||||
/// block discard/unmap support to the guest.
|
||||
pub fn is_block_device_discard_supported(&self) -> bool {
|
||||
self.flags.and(CapabilityBits::BlockDeviceDiscardSupport) != 0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -133,5 +141,8 @@ mod tests {
|
||||
cap.add(CapabilityBits::GuestMemoryProbe);
|
||||
assert!(cap.is_mem_hotplug_probe_supported());
|
||||
assert!(cap.is_fs_sharing_supported());
|
||||
// test block discard capability
|
||||
cap.add(CapabilityBits::BlockDeviceDiscardSupport);
|
||||
assert!(cap.is_block_device_discard_supported());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user