@@ -29,7 +29,9 @@ use crate::vmm_config::drive::{BlockDeviceConfig, BlockDeviceUpdateConfig, Drive
29
29
use crate :: vmm_config:: entropy:: { EntropyDeviceConfig , EntropyDeviceError } ;
30
30
use crate :: vmm_config:: instance_info:: InstanceInfo ;
31
31
use crate :: vmm_config:: machine_config:: { MachineConfig , MachineConfigError , MachineConfigUpdate } ;
32
- use crate :: vmm_config:: memory_hotplug:: { MemoryHotplugConfig , MemoryHotplugConfigError } ;
32
+ use crate :: vmm_config:: memory_hotplug:: {
33
+ MemoryHotplugConfig , MemoryHotplugConfigError , MemoryHotplugSizeUpdate ,
34
+ } ;
33
35
use crate :: vmm_config:: metrics:: { MetricsConfig , MetricsConfigError } ;
34
36
use crate :: vmm_config:: mmds:: { MmdsConfig , MmdsConfigError } ;
35
37
use crate :: vmm_config:: net:: {
@@ -113,6 +115,9 @@ pub enum VmmAction {
113
115
/// Set the memory hotplug device using `MemoryHotplugConfig` as input. This action can only be
114
116
/// called before the microVM has booted.
115
117
SetMemoryHotplugDevice ( MemoryHotplugConfig ) ,
118
+ /// Updates the memory hotplug device using `MemoryHotplugConfigUpdate` as input. This action
119
+ /// can only be called after the microVM has booted.
120
+ UpdateMemoryHotplugSize ( MemoryHotplugSizeUpdate ) ,
116
121
/// Launch the microVM. This action can only be called before the microVM has booted.
117
122
StartMicroVm ,
118
123
/// Send CTRL+ALT+DEL to the microVM, using the i8042 keyboard function. If an AT-keyboard
@@ -152,6 +157,8 @@ pub enum VmmActionError {
152
157
EntropyDevice ( #[ from] EntropyDeviceError ) ,
153
158
/// Memory hotplug config error: {0}
154
159
MemoryHotplugConfig ( #[ from] MemoryHotplugConfigError ) ,
160
+ /// Memory hotplug update error: {0}
161
+ MemoryHotplugUpdate ( VmmError ) ,
155
162
/// Internal VMM error: {0}
156
163
InternalVmm ( #[ from] VmmError ) ,
157
164
/// Load snapshot error: {0}
@@ -469,6 +476,7 @@ impl<'a> PrebootApiController<'a> {
469
476
| UpdateBalloon ( _)
470
477
| UpdateBalloonStatistics ( _)
471
478
| UpdateBlockDevice ( _)
479
+ | UpdateMemoryHotplugSize ( _)
472
480
| UpdateNetworkInterface ( _) => Err ( VmmActionError :: OperationNotSupportedPreBoot ) ,
473
481
#[ cfg( target_arch = "x86_64" ) ]
474
482
SendCtrlAltDel => Err ( VmmActionError :: OperationNotSupportedPreBoot ) ,
@@ -709,7 +717,13 @@ impl RuntimeApiController {
709
717
. map_err ( VmmActionError :: BalloonUpdate ) ,
710
718
UpdateBlockDevice ( new_cfg) => self . update_block_device ( new_cfg) ,
711
719
UpdateNetworkInterface ( netif_update) => self . update_net_rate_limiters ( netif_update) ,
712
-
720
+ UpdateMemoryHotplugSize ( cfg) => self
721
+ . vmm
722
+ . lock ( )
723
+ . expect ( "Poisoned lock" )
724
+ . update_memory_hotplug_size ( cfg. requested_size_mib )
725
+ . map ( |_| VmmData :: Empty )
726
+ . map_err ( VmmActionError :: MemoryHotplugUpdate ) ,
713
727
// Operations not allowed post-boot.
714
728
ConfigureBootSource ( _)
715
729
| ConfigureLogger ( _)
@@ -1181,6 +1195,11 @@ mod tests {
1181
1195
) ) ) ;
1182
1196
#[ cfg( target_arch = "x86_64" ) ]
1183
1197
check_unsupported ( preboot_request ( VmmAction :: SendCtrlAltDel ) ) ;
1198
+ check_unsupported ( preboot_request ( VmmAction :: UpdateMemoryHotplugSize (
1199
+ MemoryHotplugSizeUpdate {
1200
+ requested_size_mib : 0 ,
1201
+ } ,
1202
+ ) ) ) ;
1184
1203
}
1185
1204
1186
1205
fn runtime_request ( request : VmmAction ) -> Result < VmmData , VmmActionError > {
0 commit comments