@@ -360,7 +360,7 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
360360 . runtime
361361 . ps ( & p. id )
362362 . await
363- . map_err ( other_error ! ( e , "failed to execute runc ps" ) ) ?;
363+ . map_err ( other_error ! ( "failed to execute runc ps" ) ) ?;
364364 Ok ( pids
365365 . iter ( )
366366 . map ( |& x| ProcessInfo {
@@ -369,6 +369,46 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
369369 } )
370370 . collect ( ) )
371371 }
372+
373+ #[ cfg( target_os = "linux" ) ]
374+ async fn pause ( & self , p : & mut InitProcess ) -> Result < ( ) > {
375+ match p. state {
376+ Status :: RUNNING => {
377+ p. state = Status :: PAUSING ;
378+ if let Err ( e) = self . runtime . pause ( p. id . as_str ( ) ) . await {
379+ p. state = Status :: RUNNING ;
380+ return Err ( runtime_error ( & self . bundle , e, "OCI runtime pause failed" ) . await ) ;
381+ }
382+ p. state = Status :: PAUSED ;
383+ Ok ( ( ) )
384+ }
385+ _ => Err ( other ! ( "cannot pause when in {:?} state" , p. state) ) ,
386+ }
387+ }
388+
389+ #[ cfg( not( target_os = "linux" ) ) ]
390+ async fn pause ( & self , _p : & mut InitProcess ) -> Result < ( ) > {
391+ Err ( Error :: Unimplemented ( "pause" . to_string ( ) ) )
392+ }
393+
394+ #[ cfg( target_os = "linux" ) ]
395+ async fn resume ( & self , p : & mut InitProcess ) -> Result < ( ) > {
396+ match p. state {
397+ Status :: PAUSED => {
398+ if let Err ( e) = self . runtime . resume ( p. id . as_str ( ) ) . await {
399+ return Err ( runtime_error ( & self . bundle , e, "OCI runtime pause failed" ) . await ) ;
400+ }
401+ p. state = Status :: RUNNING ;
402+ Ok ( ( ) )
403+ }
404+ _ => Err ( other ! ( "cannot resume when in {:?} state" , p. state) ) ,
405+ }
406+ }
407+
408+ #[ cfg( not( target_os = "linux" ) ) ]
409+ async fn resume ( & self , _p : & mut InitProcess ) -> Result < ( ) > {
410+ Err ( Error :: Unimplemented ( "resume" . to_string ( ) ) )
411+ }
372412}
373413
374414impl RuncInitLifecycle {
@@ -495,6 +535,14 @@ impl ProcessLifecycle<ExecProcess> for RuncExecLifecycle {
495535 async fn ps ( & self , _p : & ExecProcess ) -> Result < Vec < ProcessInfo > > {
496536 Err ( Error :: Unimplemented ( "exec ps" . to_string ( ) ) )
497537 }
538+
539+ async fn pause ( & self , _p : & mut ExecProcess ) -> Result < ( ) > {
540+ Err ( Error :: Unimplemented ( "exec pause" . to_string ( ) ) )
541+ }
542+
543+ async fn resume ( & self , _p : & mut ExecProcess ) -> Result < ( ) > {
544+ Err ( Error :: Unimplemented ( "exec resume" . to_string ( ) ) )
545+ }
498546}
499547
500548async fn copy_console (
0 commit comments