|
43 | 43 | # define CRIU_CHECKPOINT_LOG_FILE "dump.log" |
44 | 44 | # define CRIU_RESTORE_LOG_FILE "restore.log" |
45 | 45 | # define DESCRIPTORS_FILENAME "descriptors.json" |
| 46 | +# define CRIU_RUNC_CONFIG_FILE "/etc/criu/runc.conf" |
| 47 | +# define CRIU_CRUN_CONFIG_FILE "/etc/criu/crun.conf" |
46 | 48 |
|
47 | 49 | # define CRIU_EXT_NETNS "extRootNetNS" |
48 | 50 | # define CRIU_EXT_PIDNS "extRootPidNS" |
@@ -99,6 +101,7 @@ struct libcriu_wrapper_s |
99 | 101 | void (*criu_set_work_dir_fd) (int fd); |
100 | 102 | int (*criu_set_lsm_profile) (const char *name); |
101 | 103 | int (*criu_set_lsm_mount_context) (const char *name); |
| 104 | + int (*criu_set_config_file) (const char *path); |
102 | 105 | }; |
103 | 106 |
|
104 | 107 | static struct libcriu_wrapper_s *libcriu_wrapper; |
@@ -194,6 +197,8 @@ load_wrapper (struct libcriu_wrapper_s **wrapper_out, libcrun_error_t *err) |
194 | 197 | LOAD_CRIU_FUNCTION (criu_set_work_dir_fd, false); |
195 | 198 | LOAD_CRIU_FUNCTION (criu_set_lsm_profile, false); |
196 | 199 | LOAD_CRIU_FUNCTION (criu_set_lsm_mount_context, false); |
| 200 | + /* criu_set_config_file was added to libcriu in v4.2 */ |
| 201 | + LOAD_CRIU_FUNCTION (criu_set_config_file, true); |
197 | 202 |
|
198 | 203 | libcriu_wrapper = *wrapper_out = wrapper; |
199 | 204 | wrapper = NULL; |
@@ -460,6 +465,36 @@ checkpoint_cgroup_v1_mount (runtime_spec_schema_config_schema *def, libcrun_erro |
460 | 465 | return 0; |
461 | 466 | } |
462 | 467 |
|
| 468 | +static int |
| 469 | +handle_criu_config_file (libcrun_container_t *container, libcrun_error_t *err) |
| 470 | +{ |
| 471 | + const char *criu_config_annotation; |
| 472 | + const char *config_file = CRIU_RUNC_CONFIG_FILE; |
| 473 | + |
| 474 | + criu_config_annotation = find_annotation (container, "org.criu.config"); |
| 475 | + |
| 476 | + if (libcriu_wrapper->criu_set_config_file == NULL) |
| 477 | + { |
| 478 | + if (criu_config_annotation) |
| 479 | + return crun_make_error (err, 0, "libcriu RPC config files supported in CRIU >= 4.2"); |
| 480 | + return 0; |
| 481 | + } |
| 482 | + |
| 483 | + if (criu_config_annotation) |
| 484 | + { |
| 485 | + config_file = CRIU_CRUN_CONFIG_FILE; |
| 486 | + } |
| 487 | + else if (access (CRIU_CRUN_CONFIG_FILE, F_OK) == 0) |
| 488 | + { |
| 489 | + config_file = CRIU_CRUN_CONFIG_FILE; |
| 490 | + } |
| 491 | + |
| 492 | + libcriu_wrapper->criu_set_config_file (config_file); |
| 493 | + |
| 494 | + return 0; |
| 495 | +} |
| 496 | + |
| 497 | + |
463 | 498 | int |
464 | 499 | libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, libcrun_container_t *container, |
465 | 500 | libcrun_checkpoint_restore_t *cr_options, libcrun_error_t *err) |
@@ -522,6 +557,10 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib |
522 | 557 | /* Set up logging. */ |
523 | 558 | libcriu_wrapper->criu_set_log_level (4); |
524 | 559 | libcriu_wrapper->criu_set_log_file (CRIU_CHECKPOINT_LOG_FILE); |
| 560 | + |
| 561 | + /* Set up CRIU config file */ |
| 562 | + handle_criu_config_file(container, err); |
| 563 | + |
525 | 564 | /* Setting the pid early as we can skip a lot of checkpoint setup if |
526 | 565 | * we just do a pre-dump. The PID needs to be set always. Do it here. |
527 | 566 | * The main process of the container is the process CRIU will checkpoint |
@@ -1098,6 +1137,9 @@ libcrun_container_restore_linux_criu (libcrun_container_status_t *status, libcru |
1098 | 1137 | # endif |
1099 | 1138 | } |
1100 | 1139 |
|
| 1140 | + /* Set up CRIU config file */ |
| 1141 | + handle_criu_config_file(container, err); |
| 1142 | + |
1101 | 1143 | /* Tell CRIU if cgroup v1 needs to be handled. */ |
1102 | 1144 | ret = restore_cgroup_v1_mount (def, err); |
1103 | 1145 | if (UNLIKELY (ret < 0)) |
|
0 commit comments