@@ -315,16 +315,6 @@ impl VmResources {
315
315
mmds_config
316
316
}
317
317
318
- /// Gets a reference to the boot source configuration.
319
- pub fn boot_source_config ( & self ) -> & BootSourceConfig {
320
- & self . boot_source . config
321
- }
322
-
323
- /// Gets a reference to the boot source builder.
324
- pub fn boot_source_builder ( & self ) -> Option < & BootConfig > {
325
- self . boot_source . builder . as_ref ( )
326
- }
327
-
328
318
/// Sets a balloon device to be attached when the VM starts.
329
319
pub fn set_balloon_device (
330
320
& mut self ,
@@ -354,14 +344,12 @@ impl VmResources {
354
344
return Err ( BootSourceConfigError :: HugePagesAndInitRd ) ;
355
345
}
356
346
357
- self . set_boot_source_config ( boot_source_cfg ) ;
358
- self . boot_source . builder = Some ( BootConfig :: new ( self . boot_source_config ( ) ) ? ) ;
359
- Ok ( ( ) )
360
- }
347
+ self . boot_source = BootSource {
348
+ builder : Some ( BootConfig :: new ( & boot_source_cfg ) ? ) ,
349
+ config : boot_source_cfg ,
350
+ } ;
361
351
362
- /// Set the boot source configuration (contains raw kernel config details).
363
- pub fn set_boot_source_config ( & mut self , boot_source_cfg : BootSourceConfig ) {
364
- self . boot_source . config = boot_source_cfg;
352
+ Ok ( ( ) )
365
353
}
366
354
367
355
/// Inserts a block to be attached when the VM starts.
@@ -512,7 +500,7 @@ impl From<&VmResources> for VmmConfig {
512
500
VmmConfig {
513
501
balloon_device : resources. balloon . get_config ( ) . ok ( ) ,
514
502
block_devices : resources. block . configs ( ) ,
515
- boot_source : resources. boot_source_config ( ) . clone ( ) ,
503
+ boot_source : resources. boot_source . config . clone ( ) ,
516
504
cpu_config : None ,
517
505
logger : None ,
518
506
machine_config : Some ( MachineConfig :: from ( & resources. vm_config ) ) ,
@@ -1521,15 +1509,6 @@ mod tests {
1521
1509
assert_eq ! ( actual_entropy_cfg, entropy_device_cfg) ;
1522
1510
}
1523
1511
1524
- #[ test]
1525
- fn test_boot_config ( ) {
1526
- let vm_resources = default_vm_resources ( ) ;
1527
- let expected_boot_cfg = vm_resources. boot_source . builder . as_ref ( ) . unwrap ( ) ;
1528
- let actual_boot_cfg = vm_resources. boot_source_builder ( ) . unwrap ( ) ;
1529
-
1530
- assert ! ( actual_boot_cfg == expected_boot_cfg) ;
1531
- }
1532
-
1533
1512
#[ test]
1534
1513
fn test_set_boot_source ( ) {
1535
1514
let tmp_file = TempFile :: new ( ) . unwrap ( ) ;
@@ -1541,7 +1520,7 @@ mod tests {
1541
1520
} ;
1542
1521
1543
1522
let mut vm_resources = default_vm_resources ( ) ;
1544
- let boot_builder = vm_resources. boot_source_builder ( ) . unwrap ( ) ;
1523
+ let boot_builder = vm_resources. boot_source . builder . as_ref ( ) . unwrap ( ) ;
1545
1524
let tmp_ino = tmp_file. as_file ( ) . metadata ( ) . unwrap ( ) . st_ino ( ) ;
1546
1525
1547
1526
assert_ne ! (
@@ -1568,7 +1547,7 @@ mod tests {
1568
1547
) ;
1569
1548
1570
1549
vm_resources. build_boot_source ( expected_boot_cfg) . unwrap ( ) ;
1571
- let boot_source_builder = vm_resources. boot_source_builder ( ) . unwrap ( ) ;
1550
+ let boot_source_builder = vm_resources. boot_source . builder . unwrap ( ) ;
1572
1551
assert_eq ! (
1573
1552
boot_source_builder
1574
1553
. cmdline
0 commit comments