@@ -36,7 +36,6 @@ impl Kvm {
36
36
/// use kvm_ioctls::Kvm;
37
37
/// let kvm = Kvm::new().unwrap();
38
38
/// ```
39
- ///
40
39
#[ allow( clippy:: new_ret_no_self) ]
41
40
pub fn new ( ) -> Result < Self > {
42
41
// Open `/dev/kvm` using `O_CLOEXEC` flag.
@@ -66,7 +65,6 @@ impl Kvm {
66
65
/// // `from_raw_fd` for creating a `Kvm` object:
67
66
/// let kvm = unsafe { Kvm::from_raw_fd(kvm_fd) };
68
67
/// ```
69
- ///
70
68
pub fn open_with_cloexec ( close_on_exec : bool ) -> Result < RawFd > {
71
69
let open_flags = O_RDWR | if close_on_exec { O_CLOEXEC } else { 0 } ;
72
70
// Safe because we give a constant nul-terminated string and verify the result.
@@ -89,7 +87,6 @@ impl Kvm {
89
87
/// let kvm = Kvm::new().unwrap();
90
88
/// assert_eq!(kvm.get_api_version(), 12);
91
89
/// ```
92
- ///
93
90
pub fn get_api_version ( & self ) -> i32 {
94
91
// Safe because we know that our file is a KVM fd and that the request is one of the ones
95
92
// defined by kernel.
@@ -132,7 +129,6 @@ impl Kvm {
132
129
/// // Check if `KVM_CAP_USER_MEMORY` is supported.
133
130
/// assert!(kvm.check_extension(Cap::UserMemory));
134
131
/// ```
135
- ///
136
132
pub fn check_extension ( & self , c : Cap ) -> bool {
137
133
self . check_extension_int ( c) > 0
138
134
}
@@ -148,7 +144,6 @@ impl Kvm {
148
144
/// let kvm = Kvm::new().unwrap();
149
145
/// assert!(kvm.get_vcpu_mmap_size().unwrap() > 0);
150
146
/// ```
151
- ///
152
147
pub fn get_vcpu_mmap_size ( & self ) -> Result < usize > {
153
148
// Safe because we know that our file is a KVM fd and we verify the return result.
154
149
let res = unsafe { ioctl ( self , KVM_GET_VCPU_MMAP_SIZE ( ) ) } ;
@@ -172,7 +167,6 @@ impl Kvm {
172
167
/// // We expect the number of vCPUs to be > 0 as per KVM API documentation.
173
168
/// assert!(kvm.get_nr_vcpus() > 0);
174
169
/// ```
175
- ///
176
170
pub fn get_nr_vcpus ( & self ) -> usize {
177
171
let x = self . check_extension_int ( Cap :: NrVcpus ) ;
178
172
if x > 0 {
@@ -196,7 +190,6 @@ impl Kvm {
196
190
/// let kvm = Kvm::new().unwrap();
197
191
/// assert!(kvm.get_nr_memslots() > 0);
198
192
/// ```
199
- ///
200
193
pub fn get_nr_memslots ( & self ) -> usize {
201
194
let x = self . check_extension_int ( Cap :: NrMemslots ) ;
202
195
if x > 0 {
@@ -219,7 +212,6 @@ impl Kvm {
219
212
/// let kvm = Kvm::new().unwrap();
220
213
/// assert!(kvm.get_max_vcpus() > 0);
221
214
/// ```
222
- ///
223
215
pub fn get_max_vcpus ( & self ) -> usize {
224
216
match self . check_extension_int ( Cap :: MaxVcpus ) {
225
217
0 => self . get_nr_vcpus ( ) ,
@@ -240,7 +232,6 @@ impl Kvm {
240
232
/// let kvm = Kvm::new().unwrap();
241
233
/// assert!(kvm.get_max_vcpu_id() > 0);
242
234
/// ```
243
- ///
244
235
pub fn get_max_vcpu_id ( & self ) -> usize {
245
236
match self . check_extension_int ( Cap :: MaxVcpuId ) {
246
237
0 => self . get_max_vcpus ( ) ,
@@ -294,7 +285,6 @@ impl Kvm {
294
285
/// let cpuid_entries = cpuid.as_mut_slice();
295
286
/// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES);
296
287
/// ```
297
- ///
298
288
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
299
289
pub fn get_emulated_cpuid ( & self , num_entries : usize ) -> Result < CpuId > {
300
290
self . get_cpuid ( KVM_GET_EMULATED_CPUID ( ) , num_entries)
@@ -324,7 +314,6 @@ impl Kvm {
324
314
/// let cpuid_entries = cpuid.as_mut_slice();
325
315
/// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES);
326
316
/// ```
327
- ///
328
317
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
329
318
pub fn get_supported_cpuid ( & self , num_entries : usize ) -> Result < CpuId > {
330
319
self . get_cpuid ( KVM_GET_SUPPORTED_CPUID ( ) , num_entries)
@@ -380,7 +369,6 @@ impl Kvm {
380
369
/// // Check that the VM mmap size is the same reported by `KVM_GET_VCPU_MMAP_SIZE`.
381
370
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
382
371
/// ```
383
- ///
384
372
#[ cfg( not( any( target_arch = "aarch64" ) ) ) ]
385
373
pub fn create_vm ( & self ) -> Result < VmFd > {
386
374
self . create_vm_with_type ( 0 ) // Create using default VM type
@@ -401,7 +389,6 @@ impl Kvm {
401
389
/// // Check that the VM mmap size is the same reported by `KVM_GET_VCPU_MMAP_SIZE`.
402
390
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
403
391
/// ```
404
- ///
405
392
#[ cfg( any( target_arch = "aarch64" ) ) ]
406
393
pub fn create_vm ( & self ) -> Result < VmFd > {
407
394
let mut ipa_size = 0 ; // Create using default VM type
@@ -441,7 +428,6 @@ impl Kvm {
441
428
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
442
429
/// }
443
430
/// ```
444
- ///
445
431
#[ cfg( any( target_arch = "aarch64" ) ) ]
446
432
pub fn create_vm_with_ipa_size ( & self , ipa_size : u32 ) -> Result < VmFd > {
447
433
self . create_vm_with_type ( ( ipa_size & KVM_VM_TYPE_ARM_IPA_SIZE_MASK ) . into ( ) )
@@ -464,7 +450,6 @@ impl Kvm {
464
450
/// // Check that the VM mmap size is the same reported by `KVM_GET_VCPU_MMAP_SIZE`.
465
451
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
466
452
/// ```
467
- ///
468
453
pub fn create_vm_with_type ( & self , vm_type : u64 ) -> Result < VmFd > {
469
454
// Safe because we know `self.kvm` is a real KVM fd as this module is the only one that
470
455
// create Kvm objects.
@@ -506,7 +491,6 @@ impl Kvm {
506
491
/// assert!(rawfd >= 0);
507
492
/// let vm = unsafe { kvm.create_vmfd_from_rawfd(rawfd).unwrap() };
508
493
/// ```
509
- ///
510
494
pub unsafe fn create_vmfd_from_rawfd ( & self , fd : RawFd ) -> Result < VmFd > {
511
495
let run_mmap_size = self . get_vcpu_mmap_size ( ) ?;
512
496
Ok ( new_vmfd ( File :: from_raw_fd ( fd) , run_mmap_size) )
@@ -547,7 +531,6 @@ impl FromRawFd for Kvm {
547
531
/// // Safe because we verify that the fd is valid in `open_with_cloexec` and we own the fd.
548
532
/// let kvm = unsafe { Kvm::from_raw_fd(kvm_fd) };
549
533
/// ```
550
- ///
551
534
unsafe fn from_raw_fd ( fd : RawFd ) -> Self {
552
535
Kvm {
553
536
kvm : File :: from_raw_fd ( fd) ,
0 commit comments