mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
images/inventory: add field for enabled plugins
This patch extends the inventory image with a `plugins` field that contains an array of plugins which were used during checkpoint, for example, to save GPU state. In particular, the CUDA and AMDGPU plugins are added to this field only when the checkpoint contains GPU state. This allows to disable unnecessary plugins during restore, show appropriate error messages if required CRIU plugin are missing, and migrate a process that does not use GPU from a GPU-enabled system to CPU-only environment. We use the `optional plugins_entry` for backwards compatibility. This entry allows us to distinguish between *unset* and *missing* field: - When the field is missing, it indicates that the checkpoint was created with a previous version of CRIU, and all plugins should be *enabled* during restore. - When the field is empty, it indicates that no plugins were used during checkpointing. Thus, all plugins can be *disabled* during restore. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
committed by
Andrei Vagin
parent
87b5ac9d9f
commit
adf2c5be96
@@ -38,6 +38,8 @@
|
||||
*/
|
||||
bool plugin_disabled = false;
|
||||
|
||||
bool plugin_added_to_inventory = false;
|
||||
|
||||
struct pid_info {
|
||||
int pid;
|
||||
char checkpointed;
|
||||
@@ -319,7 +321,7 @@ int cuda_plugin_checkpoint_devices(int pid)
|
||||
k_rtsigset_t save_sigset;
|
||||
|
||||
if (plugin_disabled) {
|
||||
return 0;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
restore_tid = get_cuda_restore_tid(pid);
|
||||
@@ -354,6 +356,15 @@ int cuda_plugin_checkpoint_devices(int pid)
|
||||
pr_err("Failed to restore process after error %s on pid %d\n", msg_buf, pid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!status && !plugin_added_to_inventory) {
|
||||
status = add_inventory_plugin(CR_PLUGIN_DESC.name);
|
||||
if (status)
|
||||
pr_err("Failed to add CUDA plugin to inventory image\n");
|
||||
else
|
||||
plugin_added_to_inventory = true;
|
||||
}
|
||||
|
||||
interrupt:
|
||||
int_ret = interrupt_restore_thread(restore_tid, &save_sigset);
|
||||
|
||||
@@ -367,7 +378,7 @@ int cuda_plugin_pause_devices(int pid)
|
||||
char msg_buf[CUDA_CKPT_BUF_SIZE];
|
||||
|
||||
if (plugin_disabled) {
|
||||
return 0;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
restore_tid = get_cuda_restore_tid(pid);
|
||||
@@ -463,6 +474,13 @@ int cuda_plugin_init(int stage)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (stage == CR_PLUGIN_STAGE__RESTORE) {
|
||||
if (!check_and_remove_inventory_plugin(CR_PLUGIN_DESC.name, strlen(CR_PLUGIN_DESC.name))) {
|
||||
plugin_disabled = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fault_injected(FI_PLUGIN_CUDA_FORCE_ENABLE) && access("/dev/nvidiactl", F_OK)) {
|
||||
pr_info("/dev/nvidiactl doesn't exist. The CUDA plugin is disabled.\n");
|
||||
plugin_disabled = true;
|
||||
|
Reference in New Issue
Block a user