@@ -418,7 +418,7 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
418418 cleanup_wrapper struct libcriu_wrapper_s * wrapper = NULL ;
419419 cleanup_free char * descriptors_path = NULL ;
420420 cleanup_free char * freezer_path = NULL ;
421- cleanup_free char * rootfs = NULL ;
421+ cleanup_free char * path = NULL ;
422422 cleanup_close int image_fd = -1 ;
423423 cleanup_close int work_fd = -1 ;
424424 int cgroup_mode ;
@@ -557,13 +557,13 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
557557 if (UNLIKELY (ret < 0 ))
558558 return crun_error_wrap (err , "error saving CRIU descriptors file" );
559559
560- ret = append_paths (& rootfs , err , status -> bundle , status -> rootfs , NULL );
560+ ret = append_paths (& path , err , status -> bundle , status -> rootfs , NULL );
561561 if (UNLIKELY (ret < 0 ))
562562 return ret ;
563563
564- ret = libcriu_wrapper -> criu_set_root (rootfs );
564+ ret = libcriu_wrapper -> criu_set_root (path );
565565 if (UNLIKELY (ret != 0 ))
566- return crun_make_error (err , 0 , "error setting CRIU root to `%s`" , rootfs );
566+ return crun_make_error (err , 0 , "error setting CRIU root to `%s`" , path );
567567
568568 cgroup_mode = libcrun_get_cgroup_mode (err );
569569 if (UNLIKELY (cgroup_mode < 0 ))
@@ -586,10 +586,16 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
586586 char buf [PATH_MAX ];
587587 const char * dest_in_root ;
588588
589- dest_in_root = chroot_realpath (rootfs , def -> mounts [i ]-> destination , buf );
589+ dest_in_root = chroot_realpath (status -> rootfs , def -> mounts [i ]-> destination , buf );
590590 if (UNLIKELY (dest_in_root == NULL ))
591- return crun_make_error (err , errno , "unable to resolve external bind mount `%s` under rootfs" , def -> mounts [i ]-> destination );
592- dest_in_root += strlen (rootfs );
591+ {
592+ if (errno != ENOENT )
593+ return crun_make_error (err , errno , "unable to resolve external bind mount `%s` under rootfs" , def -> mounts [i ]-> destination );
594+ else
595+ dest_in_root = def -> mounts [i ]-> destination ;
596+ }
597+ else
598+ dest_in_root += strlen (status -> rootfs );
593599
594600 ret = libcriu_wrapper -> criu_add_ext_mount (dest_in_root , dest_in_root );
595601 if (UNLIKELY (ret < 0 ))
@@ -793,7 +799,6 @@ libcrun_container_restore_linux_criu (libcrun_container_status_t *status, libcru
793799 cleanup_close int inherit_new_pid_fd = -1 ;
794800 cleanup_close int image_fd = -1 ;
795801 cleanup_free char * root = NULL ;
796- cleanup_free char * rootfs = NULL ;
797802 cleanup_free char * bundle_cleanup = NULL ;
798803 cleanup_close int work_fd = -1 ;
799804 int ret_out ;
@@ -904,9 +909,6 @@ libcrun_container_restore_linux_criu (libcrun_container_status_t *status, libcru
904909 }
905910
906911 /* Tell CRIU about external bind mounts. */
907- ret = append_paths (& rootfs , err , status -> bundle , status -> rootfs , NULL );
908- if (UNLIKELY (ret < 0 ))
909- return ret ;
910912 for (i = 0 ; i < def -> mounts_len ; i ++ )
911913 {
912914 if (is_bind_mount (def -> mounts [i ], NULL ))
@@ -915,10 +917,15 @@ libcrun_container_restore_linux_criu (libcrun_container_status_t *status, libcru
915917 char buf [PATH_MAX ];
916918 const char * dest_in_root ;
917919
918- dest_in_root = chroot_realpath (rootfs , def -> mounts [i ]-> destination , buf );
920+ dest_in_root = chroot_realpath (status -> rootfs , def -> mounts [i ]-> destination , buf );
919921 if (UNLIKELY (dest_in_root == NULL ))
920- return crun_make_error (err , errno , "unable to resolve external bind mount `%s` under rootfs" , def -> mounts [i ]-> destination );
921- dest_in_root += strlen (rootfs );
922+ {
923+ if (errno != ENOENT )
924+ return crun_make_error (err , errno , "unable to resolve external bind mount destination `%s` under rootfs" , def -> mounts [i ]-> destination );
925+ dest_in_root = def -> mounts [i ]-> destination ;
926+ }
927+ else
928+ dest_in_root += strlen (status -> rootfs );
922929
923930 ret = libcriu_wrapper -> criu_add_ext_mount (dest_in_root , def -> mounts [i ]-> source );
924931 if (UNLIKELY (ret < 0 ))
0 commit comments