File tree Expand file tree Collapse file tree 6 files changed +50
-0
lines changed
Expand file tree Collapse file tree 6 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -2951,6 +2951,17 @@ impl LoadedVm {
29512951 VmRpc :: WriteMemory ( rpc) => rpc. handle_failable_sync ( |( gpa, bytes) | {
29522952 self . inner . gm . write_at ( gpa, bytes. as_slice ( ) )
29532953 } ) ,
2954+ VmRpc :: UpdateCliParams ( rpc) => {
2955+ rpc. handle_failable_sync ( |params| match & mut self . inner . load_mode {
2956+ LoadMode :: Igvm { cmdline, .. } => {
2957+ * cmdline = params;
2958+ Ok ( ( ) )
2959+ }
2960+ _ => anyhow:: bail!(
2961+ "Updating command line parameters is only supported for Igvm load mode"
2962+ ) ,
2963+ } )
2964+ }
29542965 } ,
29552966 Event :: Halt ( Err ( _) ) => break ,
29562967 Event :: Halt ( Ok ( reason) ) => {
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ pub enum VmRpc {
3131 CompleteReloadIgvm ( FailableRpc < bool , ( ) > ) ,
3232 ReadMemory ( FailableRpc < ( u64 , usize ) , Vec < u8 > > ) ,
3333 WriteMemory ( FailableRpc < ( u64 , Vec < u8 > ) , ( ) > ) ,
34+ /// Updates the command line parameters that will be passed to the boot shim
35+ /// on the *next* VM load. This will replace the existing command line parameters.
36+ UpdateCliParams ( FailableRpc < String , ( ) > ) ,
3437}
3538
3639#[ derive( Debug , MeshPayload , thiserror:: Error ) ]
@@ -63,6 +66,7 @@ impl fmt::Debug for VmRpc {
6366 VmRpc :: CompleteReloadIgvm ( _) => "CompleteReloadIgvm" ,
6467 VmRpc :: ReadMemory ( _) => "ReadMemory" ,
6568 VmRpc :: WriteMemory ( _) => "WriteMemory" ,
69+ VmRpc :: UpdateCliParams ( _) => "UpdateCliParams" ,
6670 } ;
6771 f. pad ( s)
6872 }
Original file line number Diff line number Diff line change @@ -863,6 +863,10 @@ impl PetriVmRuntime for HyperVPetriRuntime {
863863 anyhow:: bail!( "restoring OpenHCL firmware separately is not yet supported on Hyper-V" ) ;
864864 }
865865
866+ async fn update_command_line ( & mut self , _command_line : & str ) -> anyhow:: Result < ( ) > {
867+ anyhow:: bail!( "updating command line is not yet supported on Hyper-V" ) ;
868+ }
869+
866870 fn take_framebuffer_access ( & mut self ) -> Option < vm:: HyperVFramebufferAccess > {
867871 ( !self . is_isolated ) . then ( || self . vm . get_framebuffer_access ( ) )
868872 }
Original file line number Diff line number Diff line change @@ -1014,6 +1014,12 @@ impl<T: PetriVmmBackend> PetriVm<T> {
10141014 . await
10151015 }
10161016
1017+ /// Update the command line parameter of the running VM that will apply on next boot.
1018+ /// Will fail if the VM is not using IGVM load mode.
1019+ pub async fn update_command_line ( & mut self , command_line : & str ) -> anyhow:: Result < ( ) > {
1020+ self . runtime . update_command_line ( command_line) . await
1021+ }
1022+
10171023 /// Instruct the OpenHCL to save the state of the VTL2 paravisor. Will fail if the VM
10181024 /// is not running OpenHCL. Will also fail if the VM is not running or if this is called twice in succession
10191025 pub async fn save_openhcl (
@@ -1122,6 +1128,9 @@ pub trait PetriVmRuntime: Send + Sync + 'static {
11221128 /// Instruct the OpenHCL to restore the state of the VTL2 paravisor. Will fail if the VM
11231129 /// is not running OpenHCL. Will also fail if the VM is running or if this is called without prior save.
11241130 async fn restore_openhcl ( & mut self ) -> anyhow:: Result < ( ) > ;
1131+ /// Update the command line parameter of the running VM that will apply on next boot.
1132+ /// Will fail if the VM is not using IGVM load mode.
1133+ async fn update_command_line ( & mut self , command_line : & str ) -> anyhow:: Result < ( ) > ;
11251134 /// If the backend supports it, get an inspect interface
11261135 fn inspector ( & self ) -> Option < Self :: VmInspector > {
11271136 None
Original file line number Diff line number Diff line change @@ -144,6 +144,10 @@ impl PetriVmRuntime for PetriVmOpenVmm {
144144 Self :: restore_openhcl ( self ) . await
145145 }
146146
147+ async fn update_command_line ( & mut self , command_line : & str ) -> anyhow:: Result < ( ) > {
148+ Self :: update_command_line ( self , command_line) . await
149+ }
150+
147151 fn inspector ( & self ) -> Option < OpenVmmInspector > {
148152 Some ( OpenVmmInspector {
149153 worker : self . inner . worker . clone ( ) ,
@@ -240,6 +244,13 @@ impl PetriVmOpenVmm {
240244 & mut self
241245 ) -> anyhow:: Result <( ) >
242246 ) ;
247+ petri_vm_fn ! (
248+ /// Updates the command line parameters of the running VM.
249+ pub async fn update_command_line(
250+ & mut self ,
251+ command_line: & str
252+ ) -> anyhow:: Result <( ) >
253+ ) ;
243254 petri_vm_fn ! (
244255 /// Resets the hardware state of the VM, simulating a power cycle.
245256 pub async fn reset( & mut self ) -> anyhow:: Result <( ) >
@@ -407,6 +418,10 @@ impl PetriVmInner {
407418 . await
408419 }
409420
421+ async fn update_command_line ( & mut self , command_line : & str ) -> anyhow:: Result < ( ) > {
422+ self . worker . update_command_line ( command_line) . await
423+ }
424+
410425 async fn restore_openhcl ( & self ) -> anyhow:: Result < ( ) > {
411426 let ged_send = self
412427 . resources
Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ impl Worker {
8383 hvlite_helpers:: underhill:: restore_underhill ( & self . rpc , send) . await
8484 }
8585
86+ pub ( crate ) async fn update_command_line ( & self , command_line : & str ) -> anyhow:: Result < ( ) > {
87+ self . rpc
88+ . call_failable ( VmRpc :: UpdateCliParams , command_line. to_string ( ) )
89+ . await ?;
90+ Ok ( ( ) )
91+ }
92+
8693 pub ( crate ) async fn inspect_all ( & self ) -> inspect:: Node {
8794 let mut inspection = inspect:: inspect ( "" , & self . handle ) ;
8895 inspection. resolve ( ) . await ;
You can’t perform that action at this time.
0 commit comments