@@ -113,6 +113,13 @@ pub struct Run {
113113 #[ structopt( long="preserve-path" , name="path" , require_delimiter=true , value_delimiter=":" ) ]
114114 preserved_paths : Vec < PathBuf > ,
115115
116+ /// Remap the TCP listen socket ports during restore.
117+ /// Format is old_port:new_port.
118+ /// Multiple tcp port remaps may be passed as a comma separated list.
119+ // We use String because we just pass the argument directly to criu-image-streamer.
120+ #[ structopt( long, require_delimiter = true ) ]
121+ tcp_listen_remap : Vec < String > ,
122+
116123 /// Leave application stopped after restore, useful for debugging.
117124 /// Has no effect when running the app from scratch.
118125 #[ structopt( long) ]
@@ -190,14 +197,15 @@ pub fn is_app_running() -> bool {
190197fn restore (
191198 image_url : ImageUrl ,
192199 mut preserved_paths : HashSet < PathBuf > ,
200+ tcp_listen_remaps : Vec < String > ,
193201 passphrase_file : Option < PathBuf > ,
194202 shard_download_cmds : Vec < String > ,
195203 leave_stopped : bool ,
196204) -> Result < ( Stats , Duration ) > {
197205 info ! ( "Restoring application{}" , if leave_stopped { " (leave stopped)" } else { "" } ) ;
198206 let mut pgrp = ProcessGroup :: new ( ) ?;
199207
200- let mut img_streamer = ImageStreamer :: spawn_serve ( shard_download_cmds. len ( ) ) ?;
208+ let mut img_streamer = ImageStreamer :: spawn_serve ( shard_download_cmds. len ( ) , tcp_listen_remaps ) ?;
201209 img_streamer. process . join ( & mut pgrp) ;
202210
203211 // Spawn the download processes connected to the image streamer's input
@@ -444,6 +452,7 @@ fn do_run(
444452 image_url : ImageUrl ,
445453 app_args : Option < Vec < OsString > > ,
446454 preserved_paths : HashSet < PathBuf > ,
455+ tcp_listen_remaps : Vec < String > ,
447456 passphrase_file : Option < PathBuf > ,
448457 no_restore : bool ,
449458 allow_bad_image_version : bool ,
@@ -482,8 +491,8 @@ fn do_run(
482491
483492 with_metrics ( "restore" , ||
484493 restore (
485- image_url, preserved_paths, passphrase_file ,
486- shard_download_cmds, leave_stopped
494+ image_url, preserved_paths, tcp_listen_remaps ,
495+ passphrase_file , shard_download_cmds, leave_stopped
487496 ) . context ( ExitCode ( EXIT_CODE_RESTORE_FAILURE ) ) ,
488497 |( stats, duration_since_checkpoint) |
489498 json ! ( {
@@ -538,7 +547,8 @@ impl super::CLI for Run {
538547 let Self {
539548 image_url, app_args, on_app_ready_cmd, no_restore,
540549 allow_bad_image_version, passphrase_file, preserved_paths,
541- leave_stopped, verbose : _, app_name, no_container } = self ;
550+ tcp_listen_remap, leave_stopped, verbose : _, app_name,
551+ no_container } = self ;
542552
543553 // We allow app_args to be empty. This indicates a restore-only mode.
544554 let app_args = if app_args. is_empty ( ) {
@@ -589,8 +599,9 @@ impl super::CLI for Run {
589599 let preserved_paths = preserved_paths. into_iter ( ) . collect ( ) ;
590600
591601 with_checkpoint_restore_lock ( || do_run (
592- image_url, app_args, preserved_paths, passphrase_file,
593- no_restore, allow_bad_image_version, leave_stopped) ) ?;
602+ image_url, app_args, preserved_paths, tcp_listen_remap,
603+ passphrase_file, no_restore, allow_bad_image_version,
604+ leave_stopped) ) ?;
594605
595606 if let Some ( on_app_ready_cmd) = on_app_ready_cmd {
596607 // Fire and forget.
0 commit comments