@@ -360,7 +360,7 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
360
360
. runtime
361
361
. ps ( & p. id )
362
362
. await
363
- . map_err ( other_error ! ( e , "failed to execute runc ps" ) ) ?;
363
+ . map_err ( other_error ! ( "failed to execute runc ps" ) ) ?;
364
364
Ok ( pids
365
365
. iter ( )
366
366
. map ( |& x| ProcessInfo {
@@ -369,6 +369,46 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
369
369
} )
370
370
. collect ( ) )
371
371
}
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
+ }
372
412
}
373
413
374
414
impl RuncInitLifecycle {
@@ -495,6 +535,14 @@ impl ProcessLifecycle<ExecProcess> for RuncExecLifecycle {
495
535
async fn ps ( & self , _p : & ExecProcess ) -> Result < Vec < ProcessInfo > > {
496
536
Err ( Error :: Unimplemented ( "exec ps" . to_string ( ) ) )
497
537
}
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
+ }
498
546
}
499
547
500
548
async fn copy_console (
0 commit comments