File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,11 @@ impl VmResources {
217217 BalloonConfigError :: IncompatibleWith ( "huge pages" ) ,
218218 ) ) ;
219219 }
220+ if self . machine_config . mem_config . secret_free {
221+ return Err ( ResourcesError :: BalloonDevice (
222+ BalloonConfigError :: IncompatibleWith ( "secret freedom" ) ,
223+ ) ) ;
224+ }
220225 }
221226
222227 SharedDeviceType :: Vsock ( vsock) => {
@@ -262,6 +267,12 @@ impl VmResources {
262267 "huge pages" ,
263268 ) ) ;
264269 }
270+ if self . balloon . get ( ) . is_some ( ) && updated. mem_config . secret_free {
271+ return Err ( MachineConfigError :: Incompatible (
272+ "balloon device" ,
273+ "secret freedom" ,
274+ ) ) ;
275+ }
265276 self . machine_config = updated;
266277
267278 Ok ( ( ) )
@@ -319,6 +330,9 @@ impl VmResources {
319330 if self . machine_config . huge_pages != HugePageConfig :: None {
320331 return Err ( BalloonConfigError :: IncompatibleWith ( "huge pages" ) ) ;
321332 }
333+ if self . machine_config . mem_config . secret_free {
334+ return Err ( BalloonConfigError :: IncompatibleWith ( "secret freedom" ) ) ;
335+ }
322336
323337 self . balloon . set ( config)
324338 }
Original file line number Diff line number Diff line change @@ -99,6 +99,11 @@ pub struct MemoryConfig {
9999 #[ cfg( target_arch = "aarch64" ) ]
100100 #[ serde( default ) ]
101101 pub initial_swiotlb_size : usize ,
102+ /// Whether guest_memfd should be used to back normal guest memory. If this is enabled
103+ /// and any devices are attached to the VM, then initial_swiotlb_size must be non-zero,
104+ /// as I/O into secret free memory is not possible.
105+ #[ serde( default ) ]
106+ pub secret_free : bool ,
102107}
103108
104109/// Struct used in PUT `/machine-config` API call.
@@ -301,6 +306,13 @@ impl MachineConfig {
301306 return Err ( MachineConfigError :: InvalidSwiotlbRegionSize ) ;
302307 }
303308
309+ if mem_config. secret_free && page_config != HugePageConfig :: None {
310+ return Err ( MachineConfigError :: Incompatible (
311+ "secret freedom" ,
312+ "huge pages" ,
313+ ) ) ;
314+ }
315+
304316 let cpu_template = match update. cpu_template {
305317 None => self . cpu_template . clone ( ) ,
306318 Some ( StaticCpuTemplate :: None ) => None ,
You can’t perform that action at this time.
0 commit comments