@@ -28,6 +28,7 @@ use crate::vmm_config::drive::{BlockDeviceConfig, BlockDeviceUpdateConfig, Drive
28
28
use crate :: vmm_config:: entropy:: { EntropyDeviceConfig , EntropyDeviceError } ;
29
29
use crate :: vmm_config:: instance_info:: InstanceInfo ;
30
30
use crate :: vmm_config:: machine_config:: { MachineConfig , MachineConfigError , MachineConfigUpdate } ;
31
+ use crate :: vmm_config:: memory_hotplug:: { MemoryHotplugConfig , MemoryHotplugConfigError } ;
31
32
use crate :: vmm_config:: metrics:: { MetricsConfig , MetricsConfigError } ;
32
33
use crate :: vmm_config:: mmds:: { MmdsConfig , MmdsConfigError } ;
33
34
use crate :: vmm_config:: net:: {
@@ -106,6 +107,9 @@ pub enum VmmAction {
106
107
/// Set the entropy device using `EntropyDeviceConfig` as input. This action can only be called
107
108
/// before the microVM has booted.
108
109
SetEntropyDevice ( EntropyDeviceConfig ) ,
110
+ /// Set the memory hotplug device using `MemoryHotplugConfig` as input. This action can only be
111
+ /// called before the microVM has booted.
112
+ SetMemoryHotplugDevice ( MemoryHotplugConfig ) ,
109
113
/// Launch the microVM. This action can only be called before the microVM has booted.
110
114
StartMicroVm ,
111
115
/// Send CTRL+ALT+DEL to the microVM, using the i8042 keyboard function. If an AT-keyboard
@@ -143,6 +147,8 @@ pub enum VmmActionError {
143
147
DriveConfig ( #[ from] DriveError ) ,
144
148
/// Entropy device error: {0}
145
149
EntropyDevice ( #[ from] EntropyDeviceError ) ,
150
+ /// Memory hotplug config error: {0}
151
+ MemoryHotplugConfig ( #[ from] MemoryHotplugConfigError ) ,
146
152
/// Internal VMM error: {0}
147
153
InternalVmm ( #[ from] VmmError ) ,
148
154
/// Load snapshot error: {0}
@@ -447,6 +453,7 @@ impl<'a> PrebootApiController<'a> {
447
453
StartMicroVm => self . start_microvm ( ) ,
448
454
UpdateMachineConfiguration ( config) => self . update_machine_config ( config) ,
449
455
SetEntropyDevice ( config) => self . set_entropy_device ( config) ,
456
+ SetMemoryHotplugDevice ( config) => self . set_memory_hotplug_device ( config) ,
450
457
// Operations not allowed pre-boot.
451
458
CreateSnapshot ( _)
452
459
| FlushMetrics
@@ -546,6 +553,15 @@ impl<'a> PrebootApiController<'a> {
546
553
Ok ( VmmData :: Empty )
547
554
}
548
555
556
+ fn set_memory_hotplug_device (
557
+ & mut self ,
558
+ cfg : MemoryHotplugConfig ,
559
+ ) -> Result < VmmData , VmmActionError > {
560
+ self . boot_path = true ;
561
+ self . vm_resources . set_memory_hotplug_config ( cfg) ?;
562
+ Ok ( VmmData :: Empty )
563
+ }
564
+
549
565
// On success, this command will end the pre-boot stage and this controller
550
566
// will be replaced by a runtime controller.
551
567
fn start_microvm ( & mut self ) -> Result < VmmData , VmmActionError > {
@@ -694,6 +710,7 @@ impl RuntimeApiController {
694
710
| SetVsockDevice ( _)
695
711
| SetMmdsConfiguration ( _)
696
712
| SetEntropyDevice ( _)
713
+ | SetMemoryHotplugDevice ( _)
697
714
| StartMicroVm
698
715
| UpdateMachineConfiguration ( _) => Err ( VmmActionError :: OperationNotSupportedPostBoot ) ,
699
716
}
@@ -1272,5 +1289,8 @@ mod tests {
1272
1289
check_unsupported ( runtime_request ( VmmAction :: SetEntropyDevice (
1273
1290
EntropyDeviceConfig :: default ( ) ,
1274
1291
) ) ) ;
1292
+ check_unsupported ( runtime_request ( VmmAction :: SetMemoryHotplugDevice (
1293
+ MemoryHotplugConfig :: default ( ) ,
1294
+ ) ) ) ;
1275
1295
}
1276
1296
}
0 commit comments