@@ -130,7 +130,20 @@ impl PetriVmRuntime for PetriVmOpenVmm {
130
130
new_openhcl : & ResolvedArtifact ,
131
131
flags : OpenHclServicingFlags ,
132
132
) -> anyhow:: Result < ( ) > {
133
- Self :: restart_openhcl ( self , new_openhcl, flags) . await
133
+ Self :: save_openhcl ( self , new_openhcl, flags) . await ?;
134
+ Self :: restore_openhcl ( self ) . await
135
+ }
136
+
137
+ async fn save_openhcl (
138
+ & mut self ,
139
+ new_openhcl : & ResolvedArtifact ,
140
+ flags : OpenHclServicingFlags ,
141
+ ) -> anyhow:: Result < ( ) > {
142
+ Self :: save_openhcl ( self , new_openhcl, flags) . await
143
+ }
144
+
145
+ async fn restore_openhcl ( & mut self ) -> anyhow:: Result < ( ) > {
146
+ Self :: restore_openhcl ( self ) . await
134
147
}
135
148
136
149
fn inspector ( & self ) -> Option < OpenVmmInspector > {
@@ -212,13 +225,19 @@ impl PetriVmOpenVmm {
212
225
pub async fn wait_for_kvp( & mut self ) -> anyhow:: Result <mesh:: Sender <hyperv_ic_resources:: kvp:: KvpRpc >>
213
226
) ;
214
227
petri_vm_fn ! (
215
- /// Restarts OpenHCL.
216
- pub async fn restart_openhcl (
228
+ /// Stages the new OpenHCL file and saves the existing state .
229
+ pub async fn save_openhcl (
217
230
& mut self ,
218
231
new_openhcl: & ResolvedArtifact ,
219
232
flags: OpenHclServicingFlags
220
233
) -> anyhow:: Result <( ) >
221
234
) ;
235
+ petri_vm_fn ! (
236
+ /// Restores OpenHCL from a previously saved state.
237
+ pub async fn restore_openhcl(
238
+ & mut self
239
+ ) -> anyhow:: Result <( ) >
240
+ ) ;
222
241
petri_vm_fn ! (
223
242
/// Resets the hardware state of the VM, simulating a power cycle.
224
243
pub async fn reset( & mut self ) -> anyhow:: Result <( ) >
@@ -369,7 +388,7 @@ impl PetriVmInner {
369
388
Ok ( send)
370
389
}
371
390
372
- async fn restart_openhcl (
391
+ async fn save_openhcl (
373
392
& self ,
374
393
new_openhcl : & ResolvedArtifact ,
375
394
flags : OpenHclServicingFlags ,
@@ -382,10 +401,20 @@ impl PetriVmInner {
382
401
383
402
let igvm_file = fs_err:: File :: open ( new_openhcl) . context ( "failed to open igvm file" ) ?;
384
403
self . worker
385
- . restart_openhcl ( ged_send, flags, igvm_file. into ( ) )
404
+ . save_openhcl ( ged_send, flags, igvm_file. into ( ) )
386
405
. await
387
406
}
388
407
408
+ async fn restore_openhcl ( & self ) -> anyhow:: Result < ( ) > {
409
+ let ged_send = self
410
+ . resources
411
+ . ged_send
412
+ . as_ref ( )
413
+ . context ( "openhcl not configured" ) ?;
414
+
415
+ self . worker . restore_openhcl ( ged_send) . await
416
+ }
417
+
389
418
async fn modify_vtl2_settings (
390
419
& mut self ,
391
420
f : impl FnOnce ( & mut Vtl2Settings ) ,
0 commit comments