Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit cdaf9bf

Browse files
acatangiuSamuel Ortiz
authored and
Samuel Ortiz
committed
implement MsrList as a FamStructWrapper over kvm_msr_list
Since kvm_msr_list contains a flexible array member, we can implement MsrList as a FamStructWrapper<kvm_msr_list>. This allows users of kvm-ioctls to work with safe code even when dealing with kvm_msr_list. Signed-off-by: Adrian Catangiu <[email protected]>
1 parent c545742 commit cdaf9bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/x86/fam_wrappers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,15 @@ generate_fam_struct_impl!(
5757
/// the array elements, this type is implemented using
5858
/// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html).
5959
pub type Msrs = FamStructWrapper<kvm_msrs>;
60+
61+
// Implement the FamStruct trait for kvm_msr_list.
62+
generate_fam_struct_impl!(kvm_msr_list, u32, indices, u32, nmsrs, KVM_MAX_MSR_ENTRIES);
63+
64+
/// Wrapper over the `kvm_msr_list` structure.
65+
///
66+
/// The `kvm_msr_list` structure contains a flexible array member. For details check the
67+
/// [KVM API](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt)
68+
/// documentation on `kvm_msr_list`. To provide safe access to
69+
/// the array elements, this type is implemented using
70+
/// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html).
71+
pub type MsrList = FamStructWrapper<kvm_msr_list>;

0 commit comments

Comments
 (0)