kvm_rs/
cap.rs

1// SPDX-License-Identifier: MIT
2//
3// Copyright (c) 2021, Johannes Stoelp <dev@memzero.de>
4
5//! Definitions of KVM capabilities.
6
7use crate::kvm_sys;
8use std::convert::Into;
9
10/// Definition of capabilities that return a bool value indicating whether the capability is
11/// supported or not.
12#[repr(u64)]
13pub enum CapBool {
14    /// Check if capabilities can be queried on VM fds (`KVM_CAP_CHECK_EXTENSION_VM`).
15    CheckExtensionVm = kvm_sys::KVM_CAP_CHECK_EXTENSION_VM,
16}
17
18impl Into<u64> for CapBool {
19    fn into(self) -> u64 {
20        self as u64
21    }
22}
23
24/// Definition of capabilities that return an integer value indicating the amount of the queried
25/// capability.
26#[repr(u64)]
27pub enum CapInt {
28    /// Get the recommended max VPCUs (`KVM_CAP_NR_VCPUS`).
29    NrVcpus = kvm_sys::KVM_CAP_NR_VCPUS,
30    /// Get the possible max VPCUs (`KVM_CAP_MAX_VCPUS`).
31    MaxVcpus = kvm_sys::KVM_CAP_MAX_VCPUS,
32}
33
34impl Into<u64> for CapInt {
35    fn into(self) -> u64 {
36        self as u64
37    }
38}